Skip to content

Commit

Permalink
chore(ivy): add static flag to more queries (#15252)
Browse files Browse the repository at this point in the history
This should fix the tests for AriaDescriber, AutofillMonitor, Portal,
BottomSheet, Autocomplete, and Drawer.
  • Loading branch information
kara authored and josephperrott committed Mar 7, 2019
1 parent 971ab53 commit 6977f18
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/cdk/a11y/aria-describer/aria-describer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('AriaDescriber', () => {
fixture = TestBed.createComponent(TestApp);
component = fixture.componentInstance;
ariaDescriber = component.ariaDescriber;
fixture.detectChanges();
});

afterEach(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/cdk/portal/portal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ class ArbitraryViewContainerRefComponent {
})
class PortalTestApp {
@ViewChildren(CdkPortal) portals: QueryList<CdkPortal>;
@ViewChild(CdkPortalOutlet) portalOutlet: CdkPortalOutlet;
@ViewChild('templateRef', { read: TemplateRef }) templateRef: TemplateRef<any>;
@ViewChild(CdkPortalOutlet, {static: true}) portalOutlet: CdkPortalOutlet;
@ViewChild('templateRef', { read: TemplateRef , static: true}) templateRef: TemplateRef<any>;

selectedPortal: Portal<any>|undefined;
fruit: string = 'Banana';
Expand Down Expand Up @@ -600,7 +600,7 @@ class PortalTestApp {
`,
})
class UnboundPortalTestApp {
@ViewChild(CdkPortalOutlet) portalOutlet: CdkPortalOutlet;
@ViewChild(CdkPortalOutlet, {static: true}) portalOutlet: CdkPortalOutlet;
}

// Create a real (non-test) NgModule as a workaround for
Expand Down
6 changes: 3 additions & 3 deletions src/cdk/text-field/autofill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ describe('cdkAutofill', () => {
})
class Inputs {
// Cast to `any` so we can stub out some methods in the tests.
@ViewChild('input1') input1: ElementRef<any>;
@ViewChild('input2') input2: ElementRef<any>;
@ViewChild('input3') input3: ElementRef<any>;
@ViewChild('input1', {static: true}) input1: ElementRef<any>;
@ViewChild('input2', {static: true}) input2: ElementRef<any>;
@ViewChild('input3', {static: true}) input3: ElementRef<any>;
}

@Component({
Expand Down
2 changes: 1 addition & 1 deletion src/lib/autocomplete/autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2352,7 +2352,7 @@ class SimpleAutocomplete implements OnDestroy {
openedSpy = jasmine.createSpy('autocomplete opened spy');
closedSpy = jasmine.createSpy('autocomplete closed spy');

@ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger;
@ViewChild(MatAutocompleteTrigger, {static: true}) trigger: MatAutocompleteTrigger;
@ViewChild(MatAutocomplete) panel: MatAutocomplete;
@ViewChild(MatFormField) formField: MatFormField;
@ViewChildren(MatOption) options: QueryList<MatOption>;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bottom-sheet/bottom-sheet-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class MatBottomSheetContainer extends BasePortalOutlet implements OnDestr
private _breakpointSubscription: Subscription;

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

/** The state of the bottom sheet animations. */
_animationState: 'void' | 'visible' | 'hidden' = 'void';
Expand Down
2 changes: 2 additions & 0 deletions src/lib/sidenav/drawer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ describe('MatDrawer', () => {
let fixture = TestBed.createComponent(BasicTestApp);
let drawer: MatDrawer = fixture.debugElement
.query(By.directive(MatDrawer)).componentInstance;
fixture.detectChanges();

let openButton = fixture.componentInstance.openButton.nativeElement;
let closeButton = fixture.componentInstance.closeButton.nativeElement;

Expand Down

0 comments on commit 6977f18

Please sign in to comment.