Skip to content

Commit 7ca079a

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

File tree

3 files changed

+50
-73
lines changed

3 files changed

+50
-73
lines changed

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ ng_module(
1515
)
1616

1717
ng_test_library(
18-
name = "harness_tests_lib",
19-
srcs = ["shared.spec.ts"],
18+
name = "unit_tests_lib",
19+
srcs = glob(["**/*.spec.ts"]),
2020
deps = [
2121
":testing",
2222
"//src/cdk/testing",
@@ -26,19 +26,6 @@ ng_test_library(
2626
],
2727
)
2828

29-
ng_test_library(
30-
name = "unit_tests_lib",
31-
srcs = glob(
32-
["**/*.spec.ts"],
33-
exclude = ["shared.spec.ts"],
34-
),
35-
deps = [
36-
":harness_tests_lib",
37-
":testing",
38-
"//src/material/progress-bar",
39-
],
40-
)
41-
4229
ng_web_test_suite(
4330
name = "unit_tests",
4431
deps = [
Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,51 @@
1-
import {MatProgressBarModule} from '../index';
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 {MatProgressBarModule} from '@angular/material/progress-bar';
26
import {MatProgressBarHarness} from './progress-bar-harness';
3-
import {runHarnessTests} from '@angular/material/progress-bar/testing/shared.spec';
47

5-
describe('MDC-based MatProgressBarHarness', () => {
6-
runHarnessTests(MatProgressBarModule, MatProgressBarHarness);
8+
describe('MatProgressBarHarness', () => {
9+
let fixture: ComponentFixture<ProgressBarHarnessTest>;
10+
let loader: HarnessLoader;
11+
12+
beforeEach(async () => {
13+
await TestBed.configureTestingModule({
14+
imports: [MatProgressBarModule],
15+
declarations: [ProgressBarHarnessTest],
16+
}).compileComponents();
17+
18+
fixture = TestBed.createComponent(ProgressBarHarnessTest);
19+
fixture.detectChanges();
20+
loader = TestbedHarnessEnvironment.loader(fixture);
21+
});
22+
23+
it('should load all progress bar harnesses', async () => {
24+
const progressBars = await loader.getAllHarnesses(MatProgressBarHarness);
25+
expect(progressBars.length).toBe(2);
26+
});
27+
28+
it('should get the value', async () => {
29+
fixture.componentInstance.value = 50;
30+
const [determinate, indeterminate] = await loader.getAllHarnesses(MatProgressBarHarness);
31+
expect(await determinate.getValue()).toBe(50);
32+
expect(await indeterminate.getValue()).toBe(null);
33+
});
34+
35+
it('should get the mode', async () => {
36+
const [determinate, indeterminate] = await loader.getAllHarnesses(MatProgressBarHarness);
37+
expect(await determinate.getMode()).toBe('determinate');
38+
expect(await indeterminate.getMode()).toBe('indeterminate');
39+
});
740
});
41+
42+
// TODO: Add and test progress bars with modes `buffer` and `query`.
43+
@Component({
44+
template: `
45+
<mat-progress-bar mode="determinate" [value]="value"></mat-progress-bar>
46+
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
47+
`,
48+
})
49+
class ProgressBarHarnessTest {
50+
value: number;
51+
}

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

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

0 commit comments

Comments
 (0)