(component: Type<any>, expected: string[])
| 860 | }); |
| 861 | |
| 862 | async function expectStableTexts(component: Type<any>, expected: string[]) { |
| 863 | const fixture = TestBed.createComponent(component); |
| 864 | const appRef: ApplicationRef = TestBed.inject(ApplicationRef); |
| 865 | const zone: NgZone = TestBed.inject(NgZone); |
| 866 | appRef.attachView(fixture.componentRef.hostView); |
| 867 | zone.run(() => appRef.tick()); |
| 868 | |
| 869 | let i = 0; |
| 870 | const {promise, resolve} = Promise.withResolvers<void>(); |
| 871 | const sub = appRef.isStable.subscribe({ |
| 872 | next: (stable: boolean) => { |
| 873 | if (stable) { |
| 874 | expect(i).toBeLessThan(expected.length); |
| 875 | expect(fixture.nativeElement).toHaveText(expected[i++]); |
| 876 | resolve(); |
| 877 | } |
| 878 | }, |
| 879 | }); |
| 880 | fixture.debugElement.injector.get(DestroyRef).onDestroy(() => sub.unsubscribe()); |
| 881 | await promise; |
| 882 | } |
| 883 | |
| 884 | it('isStable should fire on synchronous component loading', async () => { |
| 885 | await expectStableTexts(SyncComp, ['1']); |
no test coverage detected