|
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'; |
2 | 6 | import {MatProgressBarHarness} from './progress-bar-harness';
|
3 |
| -import {runHarnessTests} from '@angular/material/progress-bar/testing/shared.spec'; |
4 | 7 |
|
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 | + }); |
7 | 40 | });
|
| 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 | +} |
0 commit comments