Skip to content

Commit 33ba7d4

Browse files
committed
test(material/progress-spinner): combine shared tests
Since we only have one module, we don't need separate shared tests anymore.
1 parent 7c1fbf0 commit 33ba7d4

File tree

3 files changed

+56
-80
lines changed

3 files changed

+56
-80
lines changed

src/material/progress-spinner/testing/BUILD.bazel

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ filegroup(
2121
)
2222

2323
ng_test_library(
24-
name = "harness_tests_lib",
25-
srcs = ["shared.spec.ts"],
24+
name = "unit_tests_lib",
25+
srcs = glob(["**/*.spec.ts"]),
2626
deps = [
2727
":testing",
2828
"//src/cdk/testing",
@@ -32,19 +32,6 @@ ng_test_library(
3232
],
3333
)
3434

35-
ng_test_library(
36-
name = "unit_tests_lib",
37-
srcs = glob(
38-
["**/*.spec.ts"],
39-
exclude = ["shared.spec.ts"],
40-
),
41-
deps = [
42-
":harness_tests_lib",
43-
":testing",
44-
"//src/material/progress-spinner",
45-
],
46-
)
47-
4835
ng_web_test_suite(
4936
name = "unit_tests",
5037
deps = [
Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,57 @@
1-
import {runHarnessTests} from '@angular/material/progress-spinner/testing/shared.spec';
1+
import {Component} from '@angular/core';
2+
import {ComponentFixture, TestBed} from '@angular/core/testing';
3+
import {HarnessLoader} from '@angular/cdk/testing';
4+
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
5+
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
26
import {MatProgressSpinnerHarness} from './progress-spinner-harness';
3-
import {MatProgressSpinnerModule} from '../index';
47

5-
describe('MDC-based MatProgressSpinnerHarness', () => {
6-
runHarnessTests(MatProgressSpinnerModule, MatProgressSpinnerHarness);
8+
describe('MatProgressSpinnerHarness', () => {
9+
let fixture: ComponentFixture<ProgressSpinnerHarnessTest>;
10+
let loader: HarnessLoader;
11+
12+
beforeEach(async () => {
13+
await TestBed.configureTestingModule({
14+
imports: [MatProgressSpinnerModule],
15+
declarations: [ProgressSpinnerHarnessTest],
16+
}).compileComponents();
17+
18+
fixture = TestBed.createComponent(ProgressSpinnerHarnessTest);
19+
fixture.detectChanges();
20+
loader = TestbedHarnessEnvironment.loader(fixture);
21+
});
22+
23+
it('should load all progress spinner harnesses', async () => {
24+
const progressSpinners = await loader.getAllHarnesses(MatProgressSpinnerHarness);
25+
expect(progressSpinners.length).toBe(3);
26+
});
27+
28+
it('should get the value', async () => {
29+
fixture.componentInstance.value = 50;
30+
const [determinate, indeterminate, impliedIndeterminate] = await loader.getAllHarnesses(
31+
MatProgressSpinnerHarness,
32+
);
33+
expect(await determinate.getValue()).toBe(50);
34+
expect(await indeterminate.getValue()).toBe(null);
35+
expect(await impliedIndeterminate.getValue()).toBe(null);
36+
});
37+
38+
it('should get the mode', async () => {
39+
const [determinate, indeterminate, impliedIndeterminate] = await loader.getAllHarnesses(
40+
MatProgressSpinnerHarness,
41+
);
42+
expect(await determinate.getMode()).toBe('determinate');
43+
expect(await indeterminate.getMode()).toBe('indeterminate');
44+
expect(await impliedIndeterminate.getMode()).toBe('indeterminate');
45+
});
746
});
47+
48+
@Component({
49+
template: `
50+
<mat-progress-spinner mode="determinate" [value]="value"></mat-progress-spinner>
51+
<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>
52+
<mat-spinner></mat-spinner>
53+
`,
54+
})
55+
class ProgressSpinnerHarnessTest {
56+
value: number;
57+
}

src/material/progress-spinner/testing/shared.spec.ts

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

0 commit comments

Comments
 (0)