Skip to content

Commit 8859dfc

Browse files
authored
feat(dialog): move test harness out of experimental (#17104)
1 parent 170299b commit 8859dfc

File tree

9 files changed

+98
-68
lines changed

9 files changed

+98
-68
lines changed

src/material-experimental/mdc-dialog/harness/BUILD.bazel

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
4+
5+
ng_module(
6+
name = "testing",
7+
srcs = glob(
8+
["**/*.ts"],
9+
exclude = ["**/*.spec.ts"],
10+
),
11+
module_name = "@angular/material/dialog/testing",
12+
deps = [
13+
"//src/cdk/coercion",
14+
"//src/cdk/testing",
15+
"//src/material/dialog",
16+
],
17+
)
18+
19+
ng_test_library(
20+
name = "harness_tests_lib",
21+
srcs = ["shared.spec.ts"],
22+
deps = [
23+
":testing",
24+
"//src/cdk/overlay",
25+
"//src/cdk/testing",
26+
"//src/cdk/testing/testbed",
27+
"//src/material/dialog",
28+
"@npm//@angular/platform-browser",
29+
],
30+
)
31+
32+
ng_test_library(
33+
name = "unit_tests_lib",
34+
srcs = glob(
35+
["**/*.spec.ts"],
36+
exclude = ["shared.spec.ts"],
37+
),
38+
deps = [
39+
":harness_tests_lib",
40+
":testing",
41+
"//src/material/dialog",
42+
],
43+
)
44+
45+
ng_web_test_suite(
46+
name = "unit_tests",
47+
deps = [":unit_tests_lib"],
48+
)

src/material-experimental/mdc-dialog/harness/dialog-harness-filters.ts renamed to src/material/dialog/testing/dialog-harness-filters.ts

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

9-
import {BaseHarnessFilters} from '@angular/cdk/testing';
9+
import {BaseHarnessFilters} from '@angular/cdk/testing';
1010

1111
export interface DialogHarnessFilters extends BaseHarnessFilters {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {MatDialogModule} from '@angular/material/dialog';
2+
import {runHarnessTests} from '@angular/material/dialog/testing/shared.spec';
3+
import {MatDialogHarness} from './dialog-harness';
4+
5+
describe('Non-MDC-based MatDialogHarness', () => {
6+
runHarnessTests(MatDialogModule, MatDialogHarness);
7+
});

src/material/dialog/testing/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export * from './public-api';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
export * from './dialog-harness';
10+
export * from './dialog-harness-filters';

src/material-experimental/mdc-dialog/harness/dialog-harness.spec.ts renamed to src/material/dialog/testing/shared.spec.ts

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,29 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
77
import {OverlayContainer} from '@angular/cdk/overlay';
88
import {MatDialogHarness} from './dialog-harness';
99

10-
let fixture: ComponentFixture<DialogHarnessTest>;
11-
let loader: HarnessLoader;
12-
let dialogHarness: typeof MatDialogHarness;
13-
let overlayContainer: OverlayContainer;
14-
15-
describe('MatDialogHarness', () => {
16-
describe('non-MDC-based', () => {
17-
beforeEach(async () => {
18-
await TestBed
19-
.configureTestingModule({
20-
imports: [MatDialogModule, NoopAnimationsModule],
21-
declarations: [DialogHarnessTest],
22-
})
23-
.compileComponents();
24-
25-
fixture = TestBed.createComponent(DialogHarnessTest);
26-
fixture.detectChanges();
27-
loader = TestbedHarnessEnvironment.documentRootLoader(fixture);
28-
dialogHarness = MatDialogHarness;
29-
inject([OverlayContainer], (oc: OverlayContainer) => {
30-
overlayContainer = oc;
31-
})();
32-
});
33-
34-
runTests();
10+
/** Shared tests to run on both the original and MDC-based radio-button's. */
11+
export function runHarnessTests(
12+
dialogModule: typeof MatDialogModule, dialogHarness: typeof MatDialogHarness) {
13+
let fixture: ComponentFixture<DialogHarnessTest>;
14+
let loader: HarnessLoader;
15+
let overlayContainer: OverlayContainer;
16+
17+
beforeEach(async () => {
18+
await TestBed
19+
.configureTestingModule({
20+
imports: [MatDialogModule, NoopAnimationsModule],
21+
declarations: [DialogHarnessTest],
22+
})
23+
.compileComponents();
24+
25+
fixture = TestBed.createComponent(DialogHarnessTest);
26+
fixture.detectChanges();
27+
loader = TestbedHarnessEnvironment.documentRootLoader(fixture);
28+
inject([OverlayContainer], (oc: OverlayContainer) => {
29+
overlayContainer = oc;
30+
})();
3531
});
3632

37-
describe(
38-
'MDC-based',
39-
() => {
40-
// TODO: run tests for MDC based radio-button once implemented.
41-
});
42-
});
43-
44-
/** Shared tests to run on both the original and MDC-based radio-button's. */
45-
function runTests() {
4633
afterEach(() => {
4734
// Close all dialogs upon test exit. This is necessary because the "MatDialog"
4835
// service is not destroyed in TestBed automatically, and it could mean that

test/karma-system-config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ System.config({
112112
'@angular/material/core': 'dist/packages/material/core/index.js',
113113
'@angular/material/datepicker': 'dist/packages/material/datepicker/index.js',
114114
'@angular/material/dialog': 'dist/packages/material/dialog/index.js',
115+
'@angular/material/dialog/testing': 'dist/packages/material/dialog/testing/index.js',
116+
'@angular/material/dialog/testing/shared.spec': 'dist/packages/material/dialog/testing/shared.spec.js',
115117
'@angular/material/divider': 'dist/packages/material/divider/index.js',
116118
'@angular/material/expansion': 'dist/packages/material/expansion/index.js',
117119
'@angular/material/form-field': 'dist/packages/material/form-field/index.js',

0 commit comments

Comments
 (0)