/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/material/progress-spinner/testing/progress-spinner-harness.spec.ts
52 строки
2 KB
Kristiyan Kostadinov
build: add explicit change detection to tests (#33010)
30 мар 2026, 10:52
Не верифицирован
30 мар 2026, 10:52
7806398
Код
Авторство
О чём код?
import {Component, signal, ChangeDetectionStrategy} from '@angular/core'; import {ComponentFixture, TestBed} from '@angular/core/testing'; import {HarnessLoader} from '@angular/cdk/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; import {MatProgressSpinnerModule} from '../progress-spinner-module'; import {MatProgressSpinnerHarness} from './progress-spinner-harness'; describe('MatProgressSpinnerHarness', () => { let fixture: ComponentFixture<ProgressSpinnerHarnessTest>; let loader: HarnessLoader; beforeEach(() => { fixture = TestBed.createComponent(ProgressSpinnerHarnessTest); fixture.detectChanges(); loader = TestbedHarnessEnvironment.loader(fixture); }); it('should load all progress spinner harnesses', async () => { const progressSpinners = await loader.getAllHarnesses(MatProgressSpinnerHarness); expect(progressSpinners.length).toBe(3); }); it('should get the value', async () => { fixture.componentInstance.value.set(50); const [determinate, indeterminate, impliedIndeterminate] = await loader.getAllHarnesses(MatProgressSpinnerHarness); expect(await determinate.getValue()).toBe(50); expect(await indeterminate.getValue()).toBe(null); expect(await impliedIndeterminate.getValue()).toBe(null); }); it('should get the mode', async () => { const [determinate, indeterminate, impliedIndeterminate] = await loader.getAllHarnesses(MatProgressSpinnerHarness); expect(await determinate.getMode()).toBe('determinate'); expect(await indeterminate.getMode()).toBe('indeterminate'); expect(await impliedIndeterminate.getMode()).toBe('indeterminate'); }); }); @Component({ template: ` <mat-progress-spinner mode="determinate" [value]="value()"></mat-progress-spinner> <mat-progress-spinner mode="indeterminate"></mat-progress-spinner> <mat-spinner></mat-spinner> `, imports: [MatProgressSpinnerModule], changeDetection: ChangeDetectionStrategy.Eager, }) class ProgressSpinnerHarnessTest { value = signal(0); }