Skip to content

Commit 5e34770

Browse files
committed
fix(material/dialog): remove dialog deps on legacy-dialog
1 parent 1ade334 commit 5e34770

File tree

6 files changed

+28
-34
lines changed

6 files changed

+28
-34
lines changed

src/material/dialog/dialog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ To access the data in your dialog component, you have to use the MAT_DIALOG_DATA
6565

6666
```ts
6767
import {Component, Inject} from '@angular/core';
68-
import {MAT_DIALOG_DATA} from '@angular/material/legacy-dialog';
68+
import {MAT_DIALOG_DATA} from '@angular/material/dialog';
6969

7070
@Component({
7171
selector: 'your-dialog',

src/material/dialog/testing/BUILD.bazel

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ ng_test_library(
3030
exclude = ["shared.spec.ts"],
3131
),
3232
deps = [
33+
":harness_tests_lib",
3334
":testing",
3435
"//src/material/dialog",
35-
"//src/material/legacy-dialog/testing:harness_tests_lib",
3636
"@npm//@angular/platform-browser",
3737
],
3838
)
@@ -43,3 +43,16 @@ ng_web_test_suite(
4343
":unit_tests_lib",
4444
],
4545
)
46+
47+
ng_test_library(
48+
name = "harness_tests_lib",
49+
srcs = ["shared.spec.ts"],
50+
deps = [
51+
":testing",
52+
"//src/cdk/overlay",
53+
"//src/cdk/testing",
54+
"//src/cdk/testing/testbed",
55+
"//src/material/dialog",
56+
"@npm//@angular/platform-browser",
57+
],
58+
)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {MatDialog, MatDialogModule} from '@angular/material/dialog';
2-
import {runHarnessTests} from '@angular/material/legacy-dialog/testing/shared.spec';
2+
import {runHarnessTests} from './shared.spec';
33
import {MatDialogHarness} from './dialog-harness';
44

55
describe('MDC-based MatDialog', () => {
6-
runHarnessTests(MatDialogModule, MatDialogHarness as any, MatDialog as any);
6+
runHarnessTests(MatDialogModule, MatDialogHarness, MatDialog);
77
});

src/material/legacy-dialog/testing/shared.spec.ts renamed to src/material/dialog/testing/shared.spec.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ import {HarnessLoader} from '@angular/cdk/testing';
22
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
33
import {Component, TemplateRef, ViewChild} from '@angular/core';
44
import {ComponentFixture, TestBed} from '@angular/core/testing';
5-
import {
6-
MatLegacyDialog,
7-
MatLegacyDialogModule,
8-
MatLegacyDialogConfig,
9-
} from '@angular/material/legacy-dialog';
5+
import {MatDialog, MatDialogModule, MatDialogConfig} from '@angular/material/dialog';
106
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
11-
import {MatLegacyDialogHarness} from './dialog-harness';
7+
import {MatDialogHarness} from './dialog-harness';
128

139
/** Shared tests to run on both the original and MDC-based dialog's. */
1410
export function runHarnessTests(
15-
dialogModule: typeof MatLegacyDialogModule,
16-
dialogHarness: typeof MatLegacyDialogHarness,
17-
dialogService: typeof MatLegacyDialog,
11+
dialogModule: typeof MatDialogModule,
12+
dialogHarness: typeof MatDialogHarness,
13+
dialogService: typeof MatDialog,
1814
) {
1915
let fixture: ComponentFixture<DialogHarnessTest>;
2016
let loader: HarnessLoader;
@@ -25,9 +21,7 @@ export function runHarnessTests(
2521
// the existing instance of the specified dialog service. This allows us to run these
2622
// tests for the MDC-based version of the dialog too.
2723
const providers =
28-
dialogService !== MatLegacyDialog
29-
? [{provide: MatLegacyDialog, useExisting: dialogService}]
30-
: undefined;
24+
dialogService !== MatDialog ? [{provide: MatDialog, useExisting: dialogService}] : undefined;
3125
await TestBed.configureTestingModule({
3226
imports: [dialogModule, NoopAnimationsModule],
3327
declarations: [DialogHarnessTest],
@@ -138,9 +132,9 @@ export function runHarnessTests(
138132
class DialogHarnessTest {
139133
@ViewChild(TemplateRef) dialogTmpl: TemplateRef<any>;
140134

141-
constructor(readonly dialog: MatLegacyDialog) {}
135+
constructor(readonly dialog: MatDialog) {}
142136

143-
open(config?: MatLegacyDialogConfig) {
137+
open(config?: MatDialogConfig) {
144138
return this.dialog.open(this.dialogTmpl, config);
145139
}
146140
}

src/material/legacy-dialog/testing/BUILD.bazel

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,15 @@ filegroup(
2525
srcs = glob(["**/*.ts"]),
2626
)
2727

28-
ng_test_library(
29-
name = "harness_tests_lib",
30-
srcs = ["shared.spec.ts"],
31-
deps = [
32-
":testing",
33-
"//src/cdk/overlay",
34-
"//src/cdk/testing",
35-
"//src/cdk/testing/testbed",
36-
"//src/material/legacy-dialog",
37-
"@npm//@angular/platform-browser",
38-
],
39-
)
40-
4128
ng_test_library(
4229
name = "unit_tests_lib",
4330
srcs = glob(
4431
["**/*.spec.ts"],
4532
exclude = ["shared.spec.ts"],
4633
),
4734
deps = [
48-
":harness_tests_lib",
4935
":testing",
36+
"//src/material/dialog/testing:harness_tests_lib",
5037
"//src/material/legacy-dialog",
5138
"@npm//@angular/platform-browser",
5239
],
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {MatLegacyDialog, MatLegacyDialogModule} from '@angular/material/legacy-dialog';
2-
import {runHarnessTests} from '@angular/material/legacy-dialog/testing/shared.spec';
2+
import {runHarnessTests} from '@angular/material/dialog/testing/shared.spec';
33
import {MatLegacyDialogHarness} from './dialog-harness';
44

55
describe('Non-MDC-based MatDialogHarness', () => {
6-
runHarnessTests(MatLegacyDialogModule, MatLegacyDialogHarness, MatLegacyDialog);
6+
runHarnessTests(MatLegacyDialogModule, MatLegacyDialogHarness as any, MatLegacyDialog as any);
77
});

0 commit comments

Comments
 (0)