Skip to content

Commit aea5d13

Browse files
authored
refactor(multiple): clean up entryComponents usages (#24019)
Cleans up all the usages of `entryComponents` since they aren't necessary anymore.
1 parent e749431 commit aea5d13

File tree

70 files changed

+193
-429
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+193
-429
lines changed

src/cdk-experimental/dialog/dialog.spec.ts

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
Directive,
1414
Inject,
1515
Injector,
16-
NgModule,
1716
TemplateRef,
1817
ViewChild,
1918
ViewContainerRef,
@@ -45,7 +44,16 @@ describe('Dialog', () => {
4544

4645
beforeEach(fakeAsync(() => {
4746
TestBed.configureTestingModule({
48-
imports: [DialogModule, DialogTestModule],
47+
imports: [DialogModule, NoopAnimationsModule],
48+
declarations: [
49+
ComponentWithChildViewContainer,
50+
ComponentWithTemplateRef,
51+
PizzaMsg,
52+
ContentElementDialog,
53+
DialogWithInjectedData,
54+
DialogWithoutFocusableElements,
55+
DirectiveWithViewContainer,
56+
],
4957
providers: [{provide: Location, useClass: SpyLocation}],
5058
});
5159

@@ -1138,7 +1146,7 @@ describe('Dialog with a parent Dialog', () => {
11381146

11391147
beforeEach(fakeAsync(() => {
11401148
TestBed.configureTestingModule({
1141-
imports: [DialogModule, DialogTestModule],
1149+
imports: [DialogModule, NoopAnimationsModule],
11421150
declarations: [ComponentThatProvidesMatDialog],
11431151
providers: [
11441152
{
@@ -1315,32 +1323,3 @@ class DialogWithoutFocusableElements {}
13151323
encapsulation: ViewEncapsulation.ShadowDom,
13161324
})
13171325
class ShadowDomComponent {}
1318-
1319-
// Create a real (non-test) NgModule as a workaround for
1320-
// https://github.com/angular/angular/issues/10760
1321-
const TEST_DIRECTIVES = [
1322-
ComponentWithChildViewContainer,
1323-
ComponentWithTemplateRef,
1324-
PizzaMsg,
1325-
DirectiveWithViewContainer,
1326-
ComponentWithOnPushViewContainer,
1327-
ContentElementDialog,
1328-
DialogWithInjectedData,
1329-
DialogWithoutFocusableElements,
1330-
ShadowDomComponent,
1331-
];
1332-
1333-
@NgModule({
1334-
imports: [DialogModule, NoopAnimationsModule],
1335-
exports: TEST_DIRECTIVES,
1336-
declarations: TEST_DIRECTIVES,
1337-
entryComponents: [
1338-
ComponentWithChildViewContainer,
1339-
ComponentWithTemplateRef,
1340-
PizzaMsg,
1341-
ContentElementDialog,
1342-
DialogWithInjectedData,
1343-
DialogWithoutFocusableElements,
1344-
],
1345-
})
1346-
class DialogTestModule {}

src/cdk/overlay/dispatchers/overlay-keyboard-dispatcher.spec.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {TestBed, inject} from '@angular/core/testing';
22
import {dispatchKeyboardEvent} from '../../testing/private';
33
import {ESCAPE} from '@angular/cdk/keycodes';
4-
import {Component, NgModule} from '@angular/core';
4+
import {Component} from '@angular/core';
55
import {OverlayModule, Overlay} from '../index';
66
import {OverlayKeyboardDispatcher} from './overlay-keyboard-dispatcher';
77
import {ComponentPortal} from '@angular/cdk/portal';
@@ -12,7 +12,8 @@ describe('OverlayKeyboardDispatcher', () => {
1212

1313
beforeEach(() => {
1414
TestBed.configureTestingModule({
15-
imports: [OverlayModule, TestComponentModule],
15+
imports: [OverlayModule],
16+
declarations: [TestComponent],
1617
});
1718

1819
inject([OverlayKeyboardDispatcher, Overlay], (kbd: OverlayKeyboardDispatcher, o: Overlay) => {
@@ -184,12 +185,3 @@ describe('OverlayKeyboardDispatcher', () => {
184185
template: 'Hello',
185186
})
186187
class TestComponent {}
187-
188-
// Create a real (non-test) NgModule as a workaround for
189-
// https://github.com/angular/angular/issues/10760
190-
@NgModule({
191-
exports: [TestComponent],
192-
declarations: [TestComponent],
193-
entryComponents: [TestComponent],
194-
})
195-
class TestComponentModule {}

src/cdk/overlay/dispatchers/overlay-outside-click-dispatcher.spec.ts

Lines changed: 83 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {TestBed, inject, fakeAsync} from '@angular/core/testing';
2-
import {Component, NgModule} from '@angular/core';
2+
import {Component} from '@angular/core';
33
import {dispatchFakeEvent, dispatchMouseEvent} from '../../testing/private';
44
import {OverlayModule, Overlay} from '../index';
55
import {OverlayOutsideClickDispatcher} from './overlay-outside-click-dispatcher';
@@ -11,7 +11,8 @@ describe('OverlayOutsideClickDispatcher', () => {
1111

1212
beforeEach(() => {
1313
TestBed.configureTestingModule({
14-
imports: [OverlayModule, TestComponentModule],
14+
imports: [OverlayModule],
15+
declarations: [TestComponent],
1516
});
1617

1718
inject(
@@ -186,78 +187,90 @@ describe('OverlayOutsideClickDispatcher', () => {
186187
overlayRef.dispose();
187188
});
188189

189-
it('should dispatch an event when a click is started outside the overlay and ' +
190-
'released outside of it', () => {
191-
const portal = new ComponentPortal(TestComponent);
192-
const overlayRef = overlay.create();
193-
overlayRef.attach(portal);
194-
const context = document.createElement('div');
195-
document.body.appendChild(context);
196-
197-
const spy = jasmine.createSpy('overlay mouse click event spy');
198-
overlayRef.outsidePointerEvents().subscribe(spy);
199-
200-
dispatchMouseEvent(context, 'pointerdown');
201-
context.click();
202-
expect(spy).toHaveBeenCalled();
203-
204-
context.remove();
205-
overlayRef.dispose();
206-
});
207-
208-
it('should not dispatch an event when a click is started inside the overlay and ' +
209-
'released inside of it', () => {
210-
const portal = new ComponentPortal(TestComponent);
211-
const overlayRef = overlay.create();
212-
overlayRef.attach(portal);
213-
214-
const spy = jasmine.createSpy('overlay mouse click event spy');
215-
overlayRef.outsidePointerEvents().subscribe(spy);
216-
217-
dispatchMouseEvent(overlayRef.overlayElement, 'pointerdown');
218-
overlayRef.overlayElement.click();
219-
expect(spy).not.toHaveBeenCalled();
220-
221-
overlayRef.dispose();
222-
});
223-
224-
it('should not dispatch an event when a click is started inside the overlay and ' +
225-
'released outside of it', () => {
226-
const portal = new ComponentPortal(TestComponent);
227-
const overlayRef = overlay.create();
228-
overlayRef.attach(portal);
229-
const context = document.createElement('div');
230-
document.body.appendChild(context);
231-
232-
const spy = jasmine.createSpy('overlay mouse click event spy');
233-
overlayRef.outsidePointerEvents().subscribe(spy);
234-
235-
dispatchMouseEvent(overlayRef.overlayElement, 'pointerdown');
236-
context.click();
237-
expect(spy).not.toHaveBeenCalled();
238-
239-
context.remove();
240-
overlayRef.dispose();
241-
});
190+
it(
191+
'should dispatch an event when a click is started outside the overlay and ' +
192+
'released outside of it',
193+
() => {
194+
const portal = new ComponentPortal(TestComponent);
195+
const overlayRef = overlay.create();
196+
overlayRef.attach(portal);
197+
const context = document.createElement('div');
198+
document.body.appendChild(context);
199+
200+
const spy = jasmine.createSpy('overlay mouse click event spy');
201+
overlayRef.outsidePointerEvents().subscribe(spy);
202+
203+
dispatchMouseEvent(context, 'pointerdown');
204+
context.click();
205+
expect(spy).toHaveBeenCalled();
242206

243-
it('should not dispatch an event when a click is started outside the overlay and ' +
244-
'released inside of it', () => {
245-
const portal = new ComponentPortal(TestComponent);
246-
const overlayRef = overlay.create();
247-
overlayRef.attach(portal);
248-
const context = document.createElement('div');
249-
document.body.appendChild(context);
207+
context.remove();
208+
overlayRef.dispose();
209+
},
210+
);
250211

251-
const spy = jasmine.createSpy('overlay mouse click event spy');
252-
overlayRef.outsidePointerEvents().subscribe(spy);
212+
it(
213+
'should not dispatch an event when a click is started inside the overlay and ' +
214+
'released inside of it',
215+
() => {
216+
const portal = new ComponentPortal(TestComponent);
217+
const overlayRef = overlay.create();
218+
overlayRef.attach(portal);
219+
220+
const spy = jasmine.createSpy('overlay mouse click event spy');
221+
overlayRef.outsidePointerEvents().subscribe(spy);
222+
223+
dispatchMouseEvent(overlayRef.overlayElement, 'pointerdown');
224+
overlayRef.overlayElement.click();
225+
expect(spy).not.toHaveBeenCalled();
226+
227+
overlayRef.dispose();
228+
},
229+
);
253230

254-
dispatchMouseEvent(context, 'pointerdown');
255-
overlayRef.overlayElement.click();
256-
expect(spy).not.toHaveBeenCalled();
231+
it(
232+
'should not dispatch an event when a click is started inside the overlay and ' +
233+
'released outside of it',
234+
() => {
235+
const portal = new ComponentPortal(TestComponent);
236+
const overlayRef = overlay.create();
237+
overlayRef.attach(portal);
238+
const context = document.createElement('div');
239+
document.body.appendChild(context);
240+
241+
const spy = jasmine.createSpy('overlay mouse click event spy');
242+
overlayRef.outsidePointerEvents().subscribe(spy);
243+
244+
dispatchMouseEvent(overlayRef.overlayElement, 'pointerdown');
245+
context.click();
246+
expect(spy).not.toHaveBeenCalled();
247+
248+
context.remove();
249+
overlayRef.dispose();
250+
},
251+
);
257252

258-
context.remove();
259-
overlayRef.dispose();
260-
});
253+
it(
254+
'should not dispatch an event when a click is started outside the overlay and ' +
255+
'released inside of it',
256+
() => {
257+
const portal = new ComponentPortal(TestComponent);
258+
const overlayRef = overlay.create();
259+
overlayRef.attach(portal);
260+
const context = document.createElement('div');
261+
document.body.appendChild(context);
262+
263+
const spy = jasmine.createSpy('overlay mouse click event spy');
264+
overlayRef.outsidePointerEvents().subscribe(spy);
265+
266+
dispatchMouseEvent(context, 'pointerdown');
267+
overlayRef.overlayElement.click();
268+
expect(spy).not.toHaveBeenCalled();
269+
270+
context.remove();
271+
overlayRef.dispose();
272+
},
273+
);
261274

262275
it('should dispatch an event when a context menu is triggered outside the overlay', () => {
263276
const portal = new ComponentPortal(TestComponent);
@@ -329,12 +342,3 @@ describe('OverlayOutsideClickDispatcher', () => {
329342
template: 'Hello',
330343
})
331344
class TestComponent {}
332-
333-
// Create a real (non-test) NgModule as a workaround for
334-
// https://github.com/angular/angular/issues/10760
335-
@NgModule({
336-
exports: [TestComponent],
337-
declarations: [TestComponent],
338-
entryComponents: [TestComponent],
339-
})
340-
class TestComponentModule {}

src/cdk/overlay/overlay.spec.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
} from '@angular/core/testing';
99
import {
1010
Component,
11-
NgModule,
1211
ViewChild,
1312
ViewContainerRef,
1413
ErrorHandler,
@@ -47,7 +46,8 @@ describe('Overlay', () => {
4746
waitForAsync(() => {
4847
dir = 'ltr';
4948
TestBed.configureTestingModule({
50-
imports: [OverlayModule, PortalModule, OverlayTestModule],
49+
imports: [OverlayModule, PortalModule],
50+
declarations: [PizzaMsg, TestComponentWithTemplatePortals],
5151
providers: [
5252
{
5353
provide: Directionality,
@@ -1080,17 +1080,6 @@ class TestComponentWithTemplatePortals {
10801080
constructor(public viewContainerRef: ViewContainerRef) {}
10811081
}
10821082

1083-
// Create a real (non-test) NgModule as a workaround for
1084-
// https://github.com/angular/angular/issues/10760
1085-
const TEST_COMPONENTS = [PizzaMsg, TestComponentWithTemplatePortals];
1086-
@NgModule({
1087-
imports: [OverlayModule, PortalModule],
1088-
exports: TEST_COMPONENTS,
1089-
declarations: TEST_COMPONENTS,
1090-
entryComponents: TEST_COMPONENTS,
1091-
})
1092-
class OverlayTestModule {}
1093-
10941083
class FakePositionStrategy implements PositionStrategy {
10951084
element: HTMLElement;
10961085

src/cdk/overlay/position/flexible-connected-position-strategy.spec.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {ComponentPortal, PortalModule} from '@angular/cdk/portal';
22
import {CdkScrollable, ScrollingModule, ViewportRuler} from '@angular/cdk/scrolling';
33
import {dispatchFakeEvent, MockNgZone} from '../../testing/private';
4-
import {Component, ElementRef, NgModule, NgZone} from '@angular/core';
4+
import {Component, ElementRef, NgZone} from '@angular/core';
55
import {fakeAsync, inject, TestBed, tick} from '@angular/core/testing';
66
import {Subscription} from 'rxjs';
77
import {map} from 'rxjs/operators';
@@ -28,7 +28,8 @@ describe('FlexibleConnectedPositionStrategy', () => {
2828

2929
beforeEach(() => {
3030
TestBed.configureTestingModule({
31-
imports: [ScrollingModule, OverlayModule, OverlayTestModule],
31+
imports: [ScrollingModule, OverlayModule, PortalModule],
32+
declarations: [TestOverlay],
3233
providers: [{provide: NgZone, useFactory: () => (zone = new MockNgZone())}],
3334
});
3435

@@ -2889,11 +2890,3 @@ function createOverflowContainerElement() {
28892890
`,
28902891
})
28912892
class TestOverlay {}
2892-
2893-
@NgModule({
2894-
imports: [OverlayModule, PortalModule],
2895-
exports: [TestOverlay],
2896-
declarations: [TestOverlay],
2897-
entryComponents: [TestOverlay],
2898-
})
2899-
class OverlayTestModule {}

src/cdk/overlay/position/global-position-strategy.spec.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {NgModule, NgZone, Component} from '@angular/core';
1+
import {NgZone, Component} from '@angular/core';
22
import {TestBed} from '@angular/core/testing';
33
import {MockNgZone} from '../../testing/private';
44
import {PortalModule, ComponentPortal} from '@angular/cdk/portal';
@@ -11,7 +11,8 @@ describe('GlobalPositonStrategy', () => {
1111

1212
beforeEach(() => {
1313
TestBed.configureTestingModule({
14-
imports: [GlobalOverlayTestModule],
14+
imports: [OverlayModule, PortalModule],
15+
declarations: [BlankPortal],
1516
providers: [{provide: NgZone, useFactory: () => (zone = new MockNgZone())}],
1617
});
1718

@@ -370,11 +371,3 @@ describe('GlobalPositonStrategy', () => {
370371

371372
@Component({template: ''})
372373
class BlankPortal {}
373-
374-
@NgModule({
375-
imports: [OverlayModule, PortalModule],
376-
exports: [BlankPortal],
377-
declarations: [BlankPortal],
378-
entryComponents: [BlankPortal],
379-
})
380-
class GlobalOverlayTestModule {}

0 commit comments

Comments
 (0)