Skip to content

Commit 26df035

Browse files
mmalerbajelbourn
authored andcommitted
feat(progress): move harnesses out of experimental (#17115)
1 parent fe6b413 commit 26df035

File tree

17 files changed

+201
-81
lines changed

17 files changed

+201
-81
lines changed

src/material-experimental/mdc-progress-bar/BUILD.bazel

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

src/material-experimental/mdc-progress-spinner/BUILD.bazel

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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/progress-bar/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/progress-bar",
26+
"@npm//@angular/platform-browser",
27+
],
28+
)
29+
30+
ng_test_library(
31+
name = "unit_tests_lib",
32+
srcs = glob(
33+
["**/*.spec.ts"],
34+
exclude = ["shared.spec.ts"],
35+
),
36+
deps = [
37+
":harness_tests_lib",
38+
":testing",
39+
"//src/material/progress-bar",
40+
],
41+
)
42+
43+
ng_web_test_suite(
44+
name = "unit_tests",
45+
deps = [":unit_tests_lib"],
46+
)
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
import {BaseHarnessFilters} from '@angular/cdk/testing';
10+
11+
export interface ProgressBarHarnessFilters extends BaseHarnessFilters {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {MatProgressBarModule} from '@angular/material/progress-bar';
2+
import {runHarnessTests} from '@angular/material/progress-bar/testing/shared.spec';
3+
import {MatProgressBarHarness} from './progress-bar-harness';
4+
5+
describe('MatProgressBarHarness', () => {
6+
runHarnessTests(MatProgressBarModule, MatProgressBarHarness);
7+
});

src/material-experimental/mdc-progress-bar/harness/progress-bar-harness.ts renamed to src/material/progress-bar/testing/progress-bar-harness.ts

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

9-
import {ComponentHarness} from '@angular/cdk/testing';
109
import {coerceNumberProperty} from '@angular/cdk/coercion';
10+
import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';
11+
import {ProgressBarHarnessFilters} from './progress-bar-harness-filters';
1112

1213
/**
1314
* Harness for interacting with a standard mat-progress-bar in tests.
@@ -16,6 +17,14 @@ import {coerceNumberProperty} from '@angular/cdk/coercion';
1617
export class MatProgressBarHarness extends ComponentHarness {
1718
static hostSelector = 'mat-progress-bar';
1819

20+
/**
21+
* Gets a `HarnessPredicate` that can be used to search for a progress bar with specific
22+
* attributes.
23+
*/
24+
static with(options: ProgressBarHarnessFilters = {}): HarnessPredicate<MatProgressBarHarness> {
25+
return new HarnessPredicate(MatProgressBarHarness, options);
26+
}
27+
1928
/** Gets a promise for the progress bar's value. */
2029
async getValue(): Promise<number|null> {
2130
const host = await this.host();
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 './progress-bar-harness';
10+
export * from './progress-bar-harness-filters';
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
33
import {Component} from '@angular/core';
44
import {ComponentFixture, TestBed} from '@angular/core/testing';
55
import {MatProgressBarModule} from '@angular/material/progress-bar';
6-
76
import {MatProgressBarHarness} from './progress-bar-harness';
87

9-
let fixture: ComponentFixture<ProgressBarHarnessTest>;
10-
let loader: HarnessLoader;
11-
let progressBarHarness: typeof MatProgressBarHarness;
8+
export function runHarnessTests(progressBarModule: typeof MatProgressBarModule,
9+
progressBarHarness: typeof MatProgressBarHarness) {
10+
let fixture: ComponentFixture<ProgressBarHarnessTest>;
11+
let loader: HarnessLoader;
1212

13-
describe('MatProgressBarHarness', () => {
1413
beforeEach(async () => {
1514
await TestBed
1615
.configureTestingModule({
@@ -22,13 +21,8 @@ describe('MatProgressBarHarness', () => {
2221
fixture = TestBed.createComponent(ProgressBarHarnessTest);
2322
fixture.detectChanges();
2423
loader = TestbedHarnessEnvironment.loader(fixture);
25-
progressBarHarness = MatProgressBarHarness;
2624
});
2725

28-
runTests();
29-
});
30-
31-
function runTests() {
3226
it('should load all progress bar harnesses', async () => {
3327
const progressBars = await loader.getAllHarnesses(progressBarHarness);
3428
expect(progressBars.length).toBe(2);
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/progress-spinner/testing",
12+
deps = [
13+
"//src/cdk/coercion",
14+
"//src/cdk/testing",
15+
"//src/material/progress-spinner",
16+
],
17+
)
18+
19+
ng_test_library(
20+
name = "harness_tests_lib",
21+
srcs = ["shared.spec.ts"],
22+
deps = [
23+
":testing",
24+
"//src/cdk/testing",
25+
"//src/cdk/testing/testbed",
26+
"//src/material/progress-spinner",
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/progress-spinner",
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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
import {BaseHarnessFilters} from '@angular/cdk/testing';
10+
11+
export interface ProgressSpinnerHarnessFilters extends BaseHarnessFilters {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
2+
import {runHarnessTests} from '@angular/material/progress-spinner/testing/shared.spec';
3+
import {MatProgressSpinnerHarness} from './progress-spinner-harness';
4+
5+
describe('Non-MDC-based MatProgressSpinnerHarness', () => {
6+
runHarnessTests(MatProgressSpinnerModule, MatProgressSpinnerHarness);
7+
});

src/material-experimental/mdc-progress-spinner/harness/progress-spinner-harness.ts renamed to src/material/progress-spinner/testing/progress-spinner-harness.ts

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

9-
import {ComponentHarness} from '@angular/cdk/testing';
10-
import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
119
import {coerceNumberProperty} from '@angular/cdk/coercion';
10+
import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';
11+
import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
12+
import {ProgressSpinnerHarnessFilters} from './progress-spinner-harness-filters';
1213

1314
/**
1415
* Harness for interacting with a standard mat-progress-spinner in tests.
@@ -17,6 +18,15 @@ import {coerceNumberProperty} from '@angular/cdk/coercion';
1718
export class MatProgressSpinnerHarness extends ComponentHarness {
1819
static hostSelector = 'mat-progress-spinner';
1920

21+
/**
22+
* Gets a `HarnessPredicate` that can be used to search for a progress bar with specific
23+
* attributes.
24+
*/
25+
static with(options: ProgressSpinnerHarnessFilters = {}):
26+
HarnessPredicate<MatProgressSpinnerHarness> {
27+
return new HarnessPredicate(MatProgressSpinnerHarness, options);
28+
}
29+
2030
/** Gets a promise for the progress spinner's value. */
2131
async getValue(): Promise<number|null> {
2232
const host = await this.host();
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 './progress-spinner-harness';
10+
export * from './progress-spinner-harness-filters';
Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
33
import {Component} from '@angular/core';
44
import {ComponentFixture, TestBed} from '@angular/core/testing';
55
import {MatProgressSpinnerModule, ProgressSpinnerMode} from '@angular/material/progress-spinner';
6-
76
import {MatProgressSpinnerHarness} from './progress-spinner-harness';
87

9-
let fixture: ComponentFixture<ProgressSpinnerHarnessTest>;
10-
let loader: HarnessLoader;
11-
let progressSpinnerHarness: typeof MatProgressSpinnerHarness;
8+
export function runHarnessTests(progressSpinnerModule: typeof MatProgressSpinnerModule,
9+
progressSpinnerHarness: typeof MatProgressSpinnerHarness) {
10+
let fixture: ComponentFixture<ProgressSpinnerHarnessTest>;
11+
let loader: HarnessLoader;
1212

13-
describe('MatProgressSpinnerHarness', () => {
1413
beforeEach(async () => {
1514
await TestBed
1615
.configureTestingModule({
@@ -22,13 +21,8 @@ describe('MatProgressSpinnerHarness', () => {
2221
fixture = TestBed.createComponent(ProgressSpinnerHarnessTest);
2322
fixture.detectChanges();
2423
loader = TestbedHarnessEnvironment.loader(fixture);
25-
progressSpinnerHarness = MatProgressSpinnerHarness;
2624
});
2725

28-
runTests();
29-
});
30-
31-
function runTests() {
3226
it('should load all progress spinner harnesses', async () => {
3327
const progressSpinners = await loader.getAllHarnesses(progressSpinnerHarness);
3428
expect(progressSpinners.length).toBe(2);

test/karma-system-config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ System.config({
126126
'@angular/material/menu/testing/shared.spec': 'dist/packages/material/menu/testing/shared.spec.js',
127127
'@angular/material/paginator': 'dist/packages/material/paginator/index.js',
128128
'@angular/material/progress-bar': 'dist/packages/material/progress-bar/index.js',
129+
'@angular/material/progress-bar/testing': 'dist/packages/material/progress-bar/testing/index.js',
130+
'@angular/material/progress-bar/testing/shared.spec': 'dist/packages/material/progress-bar/testing/shared.spec.js',
129131
'@angular/material/progress-spinner': 'dist/packages/material/progress-spinner/index.js',
132+
'@angular/material/progress-spinner/testing': 'dist/packages/material/progress-spinner/testing/index.js',
133+
'@angular/material/progress-spinner/testing/shared.spec': 'dist/packages/material/progress-spinner/testing/shared.spec.js',
130134
'@angular/material/radio': 'dist/packages/material/radio/index.js',
131135
'@angular/material/select': 'dist/packages/material/select/index.js',
132136
'@angular/material/sidenav': 'dist/packages/material/sidenav/index.js',

0 commit comments

Comments
 (0)