Skip to content

Commit d38798a

Browse files
authored
test: Remove MockNgZone (#28775)
1 parent 94c630c commit d38798a

File tree

6 files changed

+364
-141
lines changed

6 files changed

+364
-141
lines changed

src/cdk/testing/private/mock-ng-zone.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/cdk/testing/private/public-api.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
export * from './wrapped-error-message';
10-
export * from './mock-ng-zone';
119
export * from './text-dedent';
10+
export * from './wrapped-error-message';
1211

1312
// Re-exported for convenience.
1413
export * from '../testbed/fake-events';

src/material/chips/chip-grid.spec.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,19 @@ import {
1515
import {
1616
dispatchFakeEvent,
1717
dispatchKeyboardEvent,
18-
MockNgZone,
1918
patchElementFocus,
2019
typeInElement,
2120
} from '@angular/cdk/testing/private';
2221
import {
2322
Component,
2423
DebugElement,
25-
NgZone,
24+
EventEmitter,
2625
QueryList,
2726
Type,
2827
ViewChild,
2928
ViewChildren,
30-
EventEmitter,
3129
} from '@angular/core';
32-
import {ComponentFixture, fakeAsync, flush, TestBed, tick} from '@angular/core/testing';
30+
import {ComponentFixture, TestBed, fakeAsync, flush, tick} from '@angular/core/testing';
3331
import {FormControl, FormsModule, NgForm, ReactiveFormsModule, Validators} from '@angular/forms';
3432
import {MatFormFieldModule} from '@angular/material/form-field';
3533
import {MatInputModule} from '@angular/material/input';
@@ -42,7 +40,6 @@ describe('MDC-based MatChipGrid', () => {
4240
let chipGridNativeElement: HTMLElement;
4341
let chipGridInstance: MatChipGrid;
4442
let chips: QueryList<MatChipRow>;
45-
let zone: MockNgZone;
4643
let testComponent: StandardChipGrid;
4744
let directionality: {value: Direction; change: EventEmitter<Direction>};
4845
let primaryActions: NodeListOf<HTMLElement>;
@@ -194,7 +191,6 @@ describe('MDC-based MatChipGrid', () => {
194191
midItem.focus();
195192
(document.activeElement as HTMLElement).blur();
196193
tick();
197-
zone.simulateZoneExit();
198194

199195
// Destroy the middle item
200196
testComponent.chips.splice(2, 1);
@@ -720,7 +716,6 @@ describe('MDC-based MatChipGrid', () => {
720716
firstAction.blur();
721717
fixture.detectChanges();
722718
fixture.detectChanges();
723-
zone.simulateZoneExit();
724719
fixture.detectChanges();
725720
flush();
726721

@@ -1007,10 +1002,7 @@ describe('MDC-based MatChipGrid', () => {
10071002
MatInputModule,
10081003
animationsModule,
10091004
],
1010-
providers: [
1011-
{provide: NgZone, useFactory: () => (zone = new MockNgZone())},
1012-
{provide: Directionality, useValue: directionality},
1013-
],
1005+
providers: [{provide: Directionality, useValue: directionality}],
10141006
declarations: [component],
10151007
}).compileComponents();
10161008

src/material/chips/chip-listbox.spec.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,18 @@ import {END, HOME, LEFT_ARROW, RIGHT_ARROW, SPACE, TAB} from '@angular/cdk/keyco
33
import {
44
dispatchFakeEvent,
55
dispatchKeyboardEvent,
6-
MockNgZone,
76
patchElementFocus,
87
} from '@angular/cdk/testing/private';
98
import {
109
Component,
1110
DebugElement,
12-
NgZone,
11+
EventEmitter,
1312
QueryList,
1413
Type,
1514
ViewChild,
1615
ViewChildren,
17-
EventEmitter,
1816
} from '@angular/core';
19-
import {ComponentFixture, fakeAsync, flush, TestBed, tick} from '@angular/core/testing';
17+
import {ComponentFixture, TestBed, fakeAsync, flush, tick} from '@angular/core/testing';
2018
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
2119
import {By} from '@angular/platform-browser';
2220
import {MatChipListbox, MatChipOption, MatChipsModule} from './index';
@@ -28,7 +26,6 @@ describe('MDC-based MatChipListbox', () => {
2826
let chipListboxInstance: MatChipListbox;
2927
let testComponent: StandardChipListbox;
3028
let chips: QueryList<MatChipOption>;
31-
let zone: MockNgZone;
3229
let directionality: {value: Direction; change: EventEmitter<Direction>};
3330
let primaryActions: NodeListOf<HTMLElement>;
3431

@@ -223,7 +220,6 @@ describe('MDC-based MatChipListbox', () => {
223220
midItem.focus();
224221
(document.activeElement as HTMLElement).blur();
225222
tick();
226-
zone.simulateZoneExit();
227223

228224
// Destroy the middle item
229225
testComponent.chips.splice(2, 1);
@@ -850,10 +846,7 @@ describe('MDC-based MatChipListbox', () => {
850846

851847
TestBed.configureTestingModule({
852848
imports: [FormsModule, ReactiveFormsModule, MatChipsModule],
853-
providers: [
854-
{provide: NgZone, useFactory: () => (zone = new MockNgZone())},
855-
{provide: Directionality, useValue: directionality},
856-
],
849+
providers: [{provide: Directionality, useValue: directionality}],
857850
declarations: [component],
858851
}).compileComponents();
859852

tslint.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,6 @@
165165
"**/*.spec.ts",
166166
// TODO(mmalerba): following files to be cleaned up and removed from this list:
167167
"**/cdk/a11y/focus-trap/focus-trap.ts",
168-
"**/cdk/drag-drop/directives/drag.ts",
169-
"**/cdk/overlay/overlay-ref.ts",
170-
"**/cdk/table/coalesced-style-scheduler.ts",
171-
"**/cdk/table/table.ts",
172-
"**/material/autocomplete/autocomplete-trigger.ts",
173-
"**/material/chips/chip.ts",
174-
"**/material/form-field/form-field.ts",
175-
"**/material/menu/menu.ts",
176-
"**/material/sidenav/drawer.ts",
177168
"**/material/tabs/paginated-tab-header.ts"
178169
]
179170
]

0 commit comments

Comments
 (0)