Skip to content

Commit 35a484b

Browse files
mmalerbajelbourn
authored andcommitted
refactor: change input harness to standard structure (#17114)
Includes being under a `testing` directory and splitting up specs for MDC vs. legacy implementation The input harness should remain in experimental until the form-field harness is developed.
1 parent 3765433 commit 35a484b

File tree

9 files changed

+89
-64
lines changed

9 files changed

+89
-64
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,14 @@
8989

9090
# Material experimental package
9191
/src/material-experimental/* @jelbourn
92+
/src/material-experimental/input/** @devversion
9293
/src/material-experimental/mdc-autocomplete/** @crisbeto
9394
/src/material-experimental/mdc-button/** @andrewseguin
9495
/src/material-experimental/mdc-card/** @mmalerba
9596
/src/material-experimental/mdc-checkbox/** @mmalerba
9697
/src/material-experimental/mdc-chips/** @mmalerba
9798
/src/material-experimental/mdc-dialog/** @devversion
9899
/src/material-experimental/mdc-helpers/** @mmalerba
99-
# Note to implementer: please repossess
100-
/src/material-experimental/mdc-input/** @devversion
101100
/src/material-experimental/mdc-menu/** @crisbeto
102101
/src/material-experimental/mdc-select/** @crisbeto
103102
/src/material-experimental/mdc-progress-spinner/** @andrewseguin
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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-experimental/input/testing",
12+
deps = [
13+
"//src/cdk/coercion",
14+
"//src/cdk/testing",
15+
],
16+
)
17+
18+
ng_test_library(
19+
name = "harness_tests_lib",
20+
srcs = ["shared.spec.ts"],
21+
deps = [
22+
":testing",
23+
"//src/cdk/testing",
24+
"//src/cdk/testing/testbed",
25+
"//src/material/input",
26+
"@npm//@angular/forms",
27+
"@npm//@angular/platform-browser",
28+
],
29+
)
30+
31+
ng_test_library(
32+
name = "unit_tests_lib",
33+
srcs = glob(
34+
["**/*.spec.ts"],
35+
exclude = ["shared.spec.ts"],
36+
),
37+
deps = [
38+
":harness_tests_lib",
39+
":testing",
40+
"//src/material/input",
41+
],
42+
)
43+
44+
ng_web_test_suite(
45+
name = "unit_tests",
46+
deps = [":unit_tests_lib"],
47+
)
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {MatInputModule} from '@angular/material/input';
2+
import {MatInputHarness} from './input-harness';
3+
import {runHarnessTests} from './shared.spec';
4+
5+
describe('Non-MDC-based MatInputHarness', () => {
6+
runHarnessTests(MatInputModule, MatInputHarness);
7+
});
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 './input-harness';
10+
export * from './input-harness-filters';

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

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,27 @@ import {ComponentFixture, TestBed} from '@angular/core/testing';
55
import {ReactiveFormsModule} from '@angular/forms';
66
import {MatInputModule} from '@angular/material/input';
77
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
8-
98
import {MatInputHarness} from './input-harness';
109

11-
let fixture: ComponentFixture<InputHarnessTest>;
12-
let loader: HarnessLoader;
13-
let inputHarness: typeof MatInputHarness;
14-
15-
describe('MatInputHarness', () => {
16-
describe('non-MDC-based', () => {
17-
beforeEach(async () => {
18-
await TestBed
19-
.configureTestingModule({
20-
imports: [NoopAnimationsModule, MatInputModule, ReactiveFormsModule],
21-
declarations: [InputHarnessTest],
22-
})
23-
.compileComponents();
10+
/** Shared tests to run on both the original and MDC-based input's. */
11+
export function runHarnessTests(
12+
inputModule: typeof MatInputModule, inputHarness: typeof MatInputHarness) {
13+
let fixture: ComponentFixture<InputHarnessTest>;
14+
let loader: HarnessLoader;
2415

25-
fixture = TestBed.createComponent(InputHarnessTest);
26-
fixture.detectChanges();
27-
loader = TestbedHarnessEnvironment.loader(fixture);
28-
inputHarness = MatInputHarness;
29-
});
16+
beforeEach(async () => {
17+
await TestBed
18+
.configureTestingModule({
19+
imports: [NoopAnimationsModule, inputModule, ReactiveFormsModule],
20+
declarations: [InputHarnessTest],
21+
})
22+
.compileComponents();
3023

31-
runTests();
24+
fixture = TestBed.createComponent(InputHarnessTest);
25+
fixture.detectChanges();
26+
loader = TestbedHarnessEnvironment.loader(fixture);
3227
});
3328

34-
describe(
35-
'MDC-based',
36-
() => {
37-
// TODO: run tests for MDC based input once implemented.
38-
});
39-
});
40-
41-
/** Shared tests to run on both the original and MDC-based input's. */
42-
function runTests() {
4329
it('should load all input harnesses', async () => {
4430
const inputs = await loader.getAllHarnesses(inputHarness);
4531
expect(inputs.length).toBe(3);

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

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

0 commit comments

Comments
 (0)