Skip to content

Commit

Permalink
feat(dialog): move test harness out of experimental (#17104)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Sep 17, 2019
1 parent 170299b commit 8859dfc
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 68 deletions.
33 changes: 0 additions & 33 deletions src/material-experimental/mdc-dialog/harness/BUILD.bazel

This file was deleted.

48 changes: 48 additions & 0 deletions src/material/dialog/testing/BUILD.bazel
@@ -0,0 +1,48 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")

ng_module(
name = "testing",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
module_name = "@angular/material/dialog/testing",
deps = [
"//src/cdk/coercion",
"//src/cdk/testing",
"//src/material/dialog",
],
)

ng_test_library(
name = "harness_tests_lib",
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/overlay",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/dialog",
"@npm//@angular/platform-browser",
],
)

ng_test_library(
name = "unit_tests_lib",
srcs = glob(
["**/*.spec.ts"],
exclude = ["shared.spec.ts"],
),
deps = [
":harness_tests_lib",
":testing",
"//src/material/dialog",
],
)

ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
Expand Up @@ -6,6 +6,6 @@
* found in the LICENSE file at https://angular.io/license
*/

import {BaseHarnessFilters} from '@angular/cdk/testing';
import {BaseHarnessFilters} from '@angular/cdk/testing';

export interface DialogHarnessFilters extends BaseHarnessFilters {}
7 changes: 7 additions & 0 deletions src/material/dialog/testing/dialog-harness.spec.ts
@@ -0,0 +1,7 @@
import {MatDialogModule} from '@angular/material/dialog';
import {runHarnessTests} from '@angular/material/dialog/testing/shared.spec';
import {MatDialogHarness} from './dialog-harness';

describe('Non-MDC-based MatDialogHarness', () => {
runHarnessTests(MatDialogModule, MatDialogHarness);
});
9 changes: 9 additions & 0 deletions src/material/dialog/testing/index.ts
@@ -0,0 +1,9 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export * from './public-api';
10 changes: 10 additions & 0 deletions src/material/dialog/testing/public-api.ts
@@ -0,0 +1,10 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export * from './dialog-harness';
export * from './dialog-harness-filters';
Expand Up @@ -7,42 +7,29 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {OverlayContainer} from '@angular/cdk/overlay';
import {MatDialogHarness} from './dialog-harness';

let fixture: ComponentFixture<DialogHarnessTest>;
let loader: HarnessLoader;
let dialogHarness: typeof MatDialogHarness;
let overlayContainer: OverlayContainer;

describe('MatDialogHarness', () => {
describe('non-MDC-based', () => {
beforeEach(async () => {
await TestBed
.configureTestingModule({
imports: [MatDialogModule, NoopAnimationsModule],
declarations: [DialogHarnessTest],
})
.compileComponents();

fixture = TestBed.createComponent(DialogHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.documentRootLoader(fixture);
dialogHarness = MatDialogHarness;
inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainer = oc;
})();
});

runTests();
/** Shared tests to run on both the original and MDC-based radio-button's. */
export function runHarnessTests(
dialogModule: typeof MatDialogModule, dialogHarness: typeof MatDialogHarness) {
let fixture: ComponentFixture<DialogHarnessTest>;
let loader: HarnessLoader;
let overlayContainer: OverlayContainer;

beforeEach(async () => {
await TestBed
.configureTestingModule({
imports: [MatDialogModule, NoopAnimationsModule],
declarations: [DialogHarnessTest],
})
.compileComponents();

fixture = TestBed.createComponent(DialogHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.documentRootLoader(fixture);
inject([OverlayContainer], (oc: OverlayContainer) => {
overlayContainer = oc;
})();
});

describe(
'MDC-based',
() => {
// TODO: run tests for MDC based radio-button once implemented.
});
});

/** Shared tests to run on both the original and MDC-based radio-button's. */
function runTests() {
afterEach(() => {
// Close all dialogs upon test exit. This is necessary because the "MatDialog"
// service is not destroyed in TestBed automatically, and it could mean that
Expand Down
2 changes: 2 additions & 0 deletions test/karma-system-config.js
Expand Up @@ -112,6 +112,8 @@ System.config({
'@angular/material/core': 'dist/packages/material/core/index.js',
'@angular/material/datepicker': 'dist/packages/material/datepicker/index.js',
'@angular/material/dialog': 'dist/packages/material/dialog/index.js',
'@angular/material/dialog/testing': 'dist/packages/material/dialog/testing/index.js',
'@angular/material/dialog/testing/shared.spec': 'dist/packages/material/dialog/testing/shared.spec.js',
'@angular/material/divider': 'dist/packages/material/divider/index.js',
'@angular/material/expansion': 'dist/packages/material/expansion/index.js',
'@angular/material/form-field': 'dist/packages/material/form-field/index.js',
Expand Down

0 comments on commit 8859dfc

Please sign in to comment.