|
1 | 1 | import {LiveAnnouncer} from '@angular/cdk/a11y';
|
2 | 2 | import {OverlayContainer} from '@angular/cdk/overlay';
|
3 | 3 | import {
|
| 4 | + ChangeDetectionStrategy, |
4 | 5 | Component,
|
5 | 6 | Directive,
|
6 | 7 | Inject,
|
7 | 8 | TemplateRef,
|
8 | 9 | ViewChild,
|
9 | 10 | ViewContainerRef,
|
| 11 | + signal, |
10 | 12 | } from '@angular/core';
|
11 | 13 | import {ComponentFixture, fakeAsync, flush, inject, TestBed, tick} from '@angular/core/testing';
|
12 | 14 | import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
@@ -358,7 +360,7 @@ describe('MatSnackBar', () => {
|
358 | 360 | viewContainerFixture.detectChanges();
|
359 | 361 | expect(overlayContainerElement.childElementCount).toBeGreaterThan(0);
|
360 | 362 |
|
361 |
| - viewContainerFixture.componentInstance.childComponentExists = false; |
| 363 | + viewContainerFixture.componentInstance.childComponentExists.set(false); |
362 | 364 | viewContainerFixture.detectChanges();
|
363 | 365 | flush();
|
364 | 366 |
|
@@ -403,6 +405,9 @@ describe('MatSnackBar', () => {
|
403 | 405 | const dismissCompleteSpy = jasmine.createSpy('dismiss complete spy');
|
404 | 406 |
|
405 | 407 | viewContainerFixture.detectChanges();
|
| 408 | + |
| 409 | + const containerElement = document.querySelector('mat-snack-bar-container')!; |
| 410 | + expect(containerElement.classList).toContain('ng-animating'); |
406 | 411 | const container1 = snackBarRef.containerInstance as MatSnackBarContainer;
|
407 | 412 | expect(container1._animationState)
|
408 | 413 | .withContext(`Expected the animation state would be 'visible'.`)
|
@@ -1102,14 +1107,15 @@ class DirectiveWithViewContainer {
|
1102 | 1107 |
|
1103 | 1108 | @Component({
|
1104 | 1109 | selector: 'arbitrary-component',
|
1105 |
| - template: `@if (childComponentExists) {<dir-with-view-container></dir-with-view-container>}`, |
| 1110 | + template: `@if (childComponentExists()) {<dir-with-view-container></dir-with-view-container>}`, |
1106 | 1111 | standalone: true,
|
1107 | 1112 | imports: [DirectiveWithViewContainer],
|
| 1113 | + changeDetection: ChangeDetectionStrategy.OnPush, |
1108 | 1114 | })
|
1109 | 1115 | class ComponentWithChildViewContainer {
|
1110 | 1116 | @ViewChild(DirectiveWithViewContainer) childWithViewContainer: DirectiveWithViewContainer;
|
1111 | 1117 |
|
1112 |
| - childComponentExists: boolean = true; |
| 1118 | + childComponentExists = signal(true); |
1113 | 1119 |
|
1114 | 1120 | get childViewContainer() {
|
1115 | 1121 | return this.childWithViewContainer.viewContainerRef;
|
|
0 commit comments