(component: Type<any>, expected: string[])
| 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']); |
no test coverage detected
searching dependent graphs…