MCPcopy
hub / github.com/angular/angular / expectStableTexts

Function expectStableTexts

packages/core/test/application_ref_spec.ts:946–964  ·  view source on GitHub ↗
(component: Type<any>, expected: string[])

Source from the content-addressed store, hash-verified

944 });
945
946 function expectStableTexts(component: Type<any>, expected: string[]) {
947 const fixture = TestBed.createComponent(component);
948 const appRef: ApplicationRef = TestBed.inject(ApplicationRef);
949 const zone: NgZone = TestBed.inject(NgZone);
950 appRef.attachView(fixture.componentRef.hostView);
951 zone.run(() => appRef.tick());
952
953 let i = 0;
954 const sub = appRef.isStable.subscribe({
955 next: (stable: boolean) => {
956 if (stable) {
957 expect(i).toBeLessThan(expected.length);
958 expect(fixture.nativeElement).toHaveText(expected[i++]);
959 stableCalled = true;
960 }
961 },
962 });
963 fixture.debugElement.injector.get(DestroyRef).onDestroy(() => sub.unsubscribe());
964 }
965
966 it('isStable should fire on synchronous component loading', waitForAsync(() => {
967 expectStableTexts(SyncComp, ['1']);

Callers 1

Calls 10

attachViewMethod · 0.80
toHaveTextMethod · 0.80
createComponentMethod · 0.65
injectMethod · 0.65
runMethod · 0.65
tickMethod · 0.65
subscribeMethod · 0.65
onDestroyMethod · 0.65
getMethod · 0.65
unsubscribeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…