Skip to content

Commit 7ee4193

Browse files
karajelbourn
authored andcommitted
chore(ivy): add static flag to more queries (#15252)
This should fix the tests for AriaDescriber, AutofillMonitor, Portal, BottomSheet, Autocomplete, and Drawer.
1 parent c502f78 commit 7ee4193

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

src/cdk/a11y/aria-describer/aria-describer.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ describe('AriaDescriber', () => {
2020
fixture = TestBed.createComponent(TestApp);
2121
component = fixture.componentInstance;
2222
ariaDescriber = component.ariaDescriber;
23+
fixture.detectChanges();
2324
});
2425

2526
afterEach(() => {

src/cdk/portal/portal.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,8 @@ class ArbitraryViewContainerRefComponent {
563563
})
564564
class PortalTestApp {
565565
@ViewChildren(CdkPortal) portals: QueryList<CdkPortal>;
566-
@ViewChild(CdkPortalOutlet) portalOutlet: CdkPortalOutlet;
567-
@ViewChild('templateRef', { read: TemplateRef }) templateRef: TemplateRef<any>;
566+
@ViewChild(CdkPortalOutlet, {static: true}) portalOutlet: CdkPortalOutlet;
567+
@ViewChild('templateRef', { read: TemplateRef , static: true}) templateRef: TemplateRef<any>;
568568

569569
selectedPortal: Portal<any>|undefined;
570570
fruit: string = 'Banana';
@@ -600,7 +600,7 @@ class PortalTestApp {
600600
`,
601601
})
602602
class UnboundPortalTestApp {
603-
@ViewChild(CdkPortalOutlet) portalOutlet: CdkPortalOutlet;
603+
@ViewChild(CdkPortalOutlet, {static: true}) portalOutlet: CdkPortalOutlet;
604604
}
605605

606606
// Create a real (non-test) NgModule as a workaround for

src/cdk/text-field/autofill.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ describe('cdkAutofill', () => {
217217
})
218218
class Inputs {
219219
// Cast to `any` so we can stub out some methods in the tests.
220-
@ViewChild('input1') input1: ElementRef<any>;
221-
@ViewChild('input2') input2: ElementRef<any>;
222-
@ViewChild('input3') input3: ElementRef<any>;
220+
@ViewChild('input1', {static: true}) input1: ElementRef<any>;
221+
@ViewChild('input2', {static: true}) input2: ElementRef<any>;
222+
@ViewChild('input3', {static: true}) input3: ElementRef<any>;
223223
}
224224

225225
@Component({

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ class SimpleAutocomplete implements OnDestroy {
22882288
openedSpy = jasmine.createSpy('autocomplete opened spy');
22892289
closedSpy = jasmine.createSpy('autocomplete closed spy');
22902290

2291-
@ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger;
2291+
@ViewChild(MatAutocompleteTrigger, {static: true}) trigger: MatAutocompleteTrigger;
22922292
@ViewChild(MatAutocomplete) panel: MatAutocomplete;
22932293
@ViewChild(MatFormField) formField: MatFormField;
22942294
@ViewChildren(MatOption) options: QueryList<MatOption>;

src/lib/bottom-sheet/bottom-sheet-container.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class MatBottomSheetContainer extends BasePortalOutlet implements OnDestr
6363
private _breakpointSubscription: Subscription;
6464

6565
/** The portal outlet inside of this container into which the content will be loaded. */
66-
@ViewChild(CdkPortalOutlet) _portalOutlet: CdkPortalOutlet;
66+
@ViewChild(CdkPortalOutlet, {static: true}) _portalOutlet: CdkPortalOutlet;
6767

6868
/** The state of the bottom sheet animations. */
6969
_animationState: 'void' | 'visible' | 'hidden' = 'void';

src/lib/sidenav/drawer.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ describe('MatDrawer', () => {
282282
let fixture = TestBed.createComponent(BasicTestApp);
283283
let drawer: MatDrawer = fixture.debugElement
284284
.query(By.directive(MatDrawer)).componentInstance;
285+
fixture.detectChanges();
286+
285287
let openButton = fixture.componentInstance.openButton.nativeElement;
286288
let closeButton = fixture.componentInstance.closeButton.nativeElement;
287289

0 commit comments

Comments
 (0)