MCPcopy Create free account
hub / github.com/angular/angular / expectStableTexts

Function expectStableTexts

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

Source from the content-addressed store, hash-verified

937 });
938
939 function expectStableTexts(component: Type<any>, expected: string[]) {
940 const fixture = TestBed.createComponent(component);
941 const appRef: ApplicationRef = TestBed.inject(ApplicationRef);
942 const zone: NgZone = TestBed.inject(NgZone);
943 appRef.attachView(fixture.componentRef.hostView);
944 zone.run(() => appRef.tick());
945
946 let i = 0;
947 const sub = appRef.isStable.subscribe({
948 next: (stable: boolean) => {
949 if (stable) {
950 expect(i).toBeLessThan(expected.length);
951 expect(fixture.nativeElement).toHaveText(expected[i++]);
952 stableCalled = true;
953 }
954 },
955 });
956 fixture.debugElement.injector.get(DestroyRef).onDestroy(() => sub.unsubscribe());
957 }
958
959 it('isStable should fire on synchronous component loading', waitForAsync(() => {
960 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