/
githubmirror
/
components
Обзор
Документация
Войти
/
githubmirror
/
components
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/material/chips/testing/chip-set-harness.spec.ts
41 строка
1 KB
Kristiyan Kostadinov
build: add explicit change detection to tests (#33010)
30 мар 2026, 10:52
Не верифицирован
30 мар 2026, 10:52
7806398
Код
Авторство
О чём код?
import {HarnessLoader} from '@angular/cdk/testing'; import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed'; import {Component, ChangeDetectionStrategy} from '@angular/core'; import {ComponentFixture, TestBed} from '@angular/core/testing'; import {MatChipsModule} from '../index'; import {MatChipSetHarness} from './chip-set-harness'; describe('MatChipSetHarness', () => { let fixture: ComponentFixture<ChipSetHarnessTest>; let loader: HarnessLoader; beforeEach(() => { fixture = TestBed.createComponent(ChipSetHarnessTest); fixture.detectChanges(); loader = TestbedHarnessEnvironment.loader(fixture); }); it('should get correct number of set harnesses', async () => { const harnesses = await loader.getAllHarnesses(MatChipSetHarness); expect(harnesses.length).toBe(1); }); it('should get correct number of chips', async () => { const harnesses = await loader.getAllHarnesses(MatChipSetHarness); const chips = await harnesses[0].getChips(); expect(chips.length).toBe(3); }); }); @Component({ template: ` <mat-chip-set> <mat-chip> Chip A </mat-chip> <mat-chip> Chip B </mat-chip> <mat-chip> Chip C </mat-chip> </mat-chip-set> `, imports: [MatChipsModule], changeDetection: ChangeDetectionStrategy.Eager, }) class ChipSetHarnessTest {}