|
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'; |
2 | 6 | import {MatProgressSpinnerHarness} from './progress-spinner-harness';
|
3 |
| -import {MatProgressSpinnerModule} from '../index'; |
4 | 7 |
|
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 | + }); |
7 | 46 | });
|
| 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 | +} |
0 commit comments