Skip to content

Commit

Permalink
test: remove compileComponent calls (#29535)
Browse files Browse the repository at this point in the history
Calls to `compileComponent` aren't necessary in the vast majority of cases. These changes clean them up frm our codebase.
  • Loading branch information
crisbeto authored Aug 6, 2024
1 parent 78c6941 commit 4718718
Show file tree
Hide file tree
Showing 187 changed files with 438 additions and 625 deletions.
6 changes: 3 additions & 3 deletions src/cdk-experimental/combobox/combobox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Combobox', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkComboboxModule, ComboboxToggle],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Combobox', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkComboboxModule, ComboboxToggle],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -262,7 +262,7 @@ describe('Combobox', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkComboboxModule, ComboboxToggle],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk-experimental/popover-edit/popover-edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ describe('CDK Popover Edit', () => {
TestBed.configureTestingModule({
imports: [CdkTableModule, CdkPopoverEditModule, CommonModule, FormsModule, BidiModule],
declarations: [componentClass],
}).compileComponents();
});
fixture = TestBed.createComponent<BaseTestComponent>(componentClass);
component = fixture.componentInstance;
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('CdkVirtualScrollViewport', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [ScrollingModule, ExperimentalScrollingModule, AutoSizeVirtualScroll],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/cdk-experimental/selection/selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('CdkSelection', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkSelectionModule, ListWithMultiSelection],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -240,7 +240,7 @@ describe('CdkSelection with multiple = false', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkSelectionModule, ListWithSingleSelection],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -305,7 +305,7 @@ describe('cdkSelectionColumn', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkSelectionModule, CdkTableModule, MultiSelectTableWithSelectionColumn],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -399,7 +399,7 @@ describe('cdkSelectionColumn with multiple = false', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkSelectionModule, CdkTableModule, SingleSelectTableWithSelectionColumn],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('CdkTableScrollContainer', () => {
): ComponentFixture<T> {
TestBed.configureTestingModule({
imports: [CdkTableModule, CdkTableScrollContainerModule, componentType, ...declarations],
}).compileComponents();
});

return TestBed.createComponent<T>(componentType);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/a11y/aria-describer/aria-describer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('AriaDescriber', () => {
TestBed.configureTestingModule({
imports: [A11yModule, TestApp],
providers: [AriaDescriber, ...providers],
}).compileComponents();
});

fixture = TestBed.createComponent(TestApp);
component = fixture.componentInstance;
Expand Down
10 changes: 5 additions & 5 deletions src/cdk/a11y/focus-monitor/focus-monitor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('FocusMonitor', () => {
},
},
],
}).compileComponents();
});
});

beforeEach(inject([FocusMonitor], (fm: FocusMonitor) => {
Expand Down Expand Up @@ -478,7 +478,7 @@ describe('FocusMonitor with "eventual" detection', () => {
},
},
],
}).compileComponents();
});
});

beforeEach(inject([FocusMonitor], (fm: FocusMonitor) => {
Expand Down Expand Up @@ -515,7 +515,7 @@ describe('cdkMonitorFocus', () => {
FocusMonitorOnCommentNode,
ExportedFocusMonitor,
],
}).compileComponents();
});
});

describe('button with cdkMonitorElementFocus', () => {
Expand Down Expand Up @@ -827,7 +827,7 @@ describe('FocusMonitor observable stream', () => {
TestBed.configureTestingModule({
imports: [A11yModule, PlainButton],
providers: [{provide: Platform, useValue: fakePlatform}],
}).compileComponents();
});
});

beforeEach(inject([FocusMonitor], (fm: FocusMonitor) => {
Expand Down Expand Up @@ -864,7 +864,7 @@ describe('FocusMonitor input label detection', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [A11yModule, CheckboxWithLabel],
}).compileComponents();
});
});

beforeEach(inject([FocusMonitor], (fm: FocusMonitor) => {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/a11y/focus-monitor/focus-monitor.zone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('FocusMonitor observable stream Zone.js integration', () => {
TestBed.configureTestingModule({
imports: [A11yModule, PlainButton],
providers: [{provide: Platform, useValue: fakePlatform}, provideZoneChangeDetection()],
}).compileComponents();
});
});

beforeEach(inject([FocusMonitor], (fm: FocusMonitor) => {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/a11y/focus-trap/configurable-focus-trap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function createComponent<T>(
TestBed.configureTestingModule({
imports: [A11yModule, componentType],
providers: providers,
}).compileComponents();
});

return TestBed.createComponent<T>(componentType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function createComponent<T>(
TestBed.configureTestingModule({
imports: [A11yModule, componentType],
providers: providers,
}).compileComponents();
});

return TestBed.createComponent<T>(componentType);
}
Expand Down
2 changes: 0 additions & 2 deletions src/cdk/a11y/focus-trap/focus-trap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ describe('FocusTrap', () => {
FocusTrapWithAutoCaptureInShadowDom,
],
});

TestBed.compileComponents();
}));

describe('with default element', () => {
Expand Down
1 change: 0 additions & 1 deletion src/cdk/accordion/accordion-item.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ describe('CdkAccordionItem', () => {
ItemGroupWithAccordion,
],
});
TestBed.compileComponents();
}));

describe('single item', () => {
Expand Down
1 change: 0 additions & 1 deletion src/cdk/accordion/accordion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe('CdkAccordion', () => {
TestBed.configureTestingModule({
imports: [BrowserAnimationsModule, CdkAccordionModule, SetOfItems, NestedItems],
});
TestBed.compileComponents();
}));

it('should ensure only one item is expanded at a time', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/cdk/bidi/directionality.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Directionality', () => {
ElementWithPredefinedUppercaseDir,
],
providers: [{provide: DIR_DOCUMENT, useFactory: () => fakeDocument}],
}).compileComponents();
});
}));

describe('Service', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/cdk/clipboard/copy-to-clipboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ describe('CdkCopyToClipboard', () => {
TestBed.configureTestingModule({
imports: [ClipboardModule, CopyToClipboardHost],
});

TestBed.compileComponents();
}));

beforeEach(() => {
Expand Down
3 changes: 0 additions & 3 deletions src/cdk/dialog/dialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ describe('Dialog', () => {
],
});

TestBed.compileComponents();

dialog = TestBed.inject(Dialog);
mockLocation = TestBed.inject(Location) as SpyLocation;
overlay = TestBed.inject(Overlay);
Expand Down Expand Up @@ -1131,7 +1129,6 @@ describe('Dialog with a parent Dialog', () => {
],
});

TestBed.compileComponents();
parentDialog = TestBed.inject(Dialog);
fixture = TestBed.createComponent(ComponentThatProvidesMatDialog);
childDialog = fixture.componentInstance.dialog;
Expand Down
1 change: 0 additions & 1 deletion src/cdk/drag-drop/directives/test-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function createComponent<T>(
});
}

TestBed.compileComponents();
return TestBed.createComponent<T>(componentType);
}

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/drag-drop/drag-drop-registry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('DragDropRegistry', () => {
beforeEach(fakeAsync(() => {
TestBed.configureTestingModule({
imports: [DragDropModule, BlankComponent],
}).compileComponents();
});

fixture = TestBed.createComponent(BlankComponent);
fixture.detectChanges();
Expand Down
1 change: 0 additions & 1 deletion src/cdk/drag-drop/drag-drop.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('DragDrop', () => {
imports: [DragDropModule, TestComponent],
});

TestBed.compileComponents();
service = TestBed.inject(DragDrop);
}));

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/listbox/listbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function setupComponent<T, O = string>(component: Type<T>, imports: any[] = [])
TestBed.configureTestingModule({
imports: [CdkListboxModule, ...imports],
declarations: [component],
}).compileComponents();
});
const fixture = TestBed.createComponent(component);
fixture.detectChanges();

Expand Down
12 changes: 6 additions & 6 deletions src/cdk/menu/context-menu-trigger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('CdkContextMenuTrigger', () => {
TestBed.configureTestingModule({
imports: [CdkMenuModule],
declarations: [SimpleContextMenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -152,7 +152,7 @@ describe('CdkContextMenuTrigger', () => {
TestBed.configureTestingModule({
imports: [CdkMenuModule],
declarations: [NestedContextMenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -267,7 +267,7 @@ describe('CdkContextMenuTrigger', () => {
TestBed.configureTestingModule({
imports: [CdkMenuModule],
declarations: [ContextMenuWithSubmenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -298,7 +298,7 @@ describe('CdkContextMenuTrigger', () => {
TestBed.configureTestingModule({
imports: [CdkMenuModule],
declarations: [ContextMenuWithMenuBarAndInlineMenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('CdkContextMenuTrigger', () => {
TestBed.configureTestingModule({
imports: [CdkMenuModule],
declarations: [componentClass],
}).compileComponents();
});

const fixture = TestBed.createComponent(componentClass);
fixture.detectChanges();
Expand All @@ -428,7 +428,7 @@ describe('CdkContextMenuTrigger', () => {
TestBed.configureTestingModule({
imports: [CdkMenuModule],
declarations: [ContextTriggerWithData],
}).compileComponents();
});

const fixture = TestBed.createComponent(ContextTriggerWithData);
fixture.componentInstance.menuData = {message: 'Hello!'};
Expand Down
14 changes: 7 additions & 7 deletions src/cdk/menu/menu-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('MenuBar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MenuBarRadioGroup],
}).compileComponents();
});

fixture = TestBed.createComponent(MenuBarRadioGroup);
fixture.detectChanges();
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('MenuBar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MultiMenuWithSubmenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -531,7 +531,7 @@ describe('MenuBar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MultiMenuWithSubmenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -658,7 +658,7 @@ describe('MenuBar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MenuWithCheckboxes],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -724,7 +724,7 @@ describe('MenuBar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MenuWithRadioButtons],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -779,7 +779,7 @@ describe('MenuBar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MenuBarWithMenusAndInlineMenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down Expand Up @@ -898,7 +898,7 @@ describe('MenuBar', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MultiMenuWithSubmenu],
}).compileComponents();
});
}));

beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/menu/menu-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('MenuGroup', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, CheckboxMenu],
}).compileComponents();
});

fixture = TestBed.createComponent(CheckboxMenu);
fixture.detectChanges();
Expand All @@ -41,7 +41,7 @@ describe('MenuGroup', () => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [CdkMenuModule, MenuWithMultipleRadioGroups],
}).compileComponents();
});

fixture = TestBed.createComponent(MenuWithMultipleRadioGroups);
fixture.detectChanges();
Expand Down
Loading

0 comments on commit 4718718

Please sign in to comment.