File tree Expand file tree Collapse file tree 3 files changed +28
-0
lines changed
tools/public_api_guard/core Expand file tree Collapse file tree 3 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,25 @@ export function main() {
158
158
} ) ;
159
159
} ) ) ;
160
160
161
+ it ( 'should signal through whenRenderingDone when the fixture is stable' , async ( ( ) => {
162
+ const componentFixture = TestBed . createComponent ( AsyncComp ) ;
163
+
164
+ componentFixture . detectChanges ( ) ;
165
+ expect ( componentFixture . nativeElement ) . toHaveText ( '1' ) ;
166
+
167
+ const element = componentFixture . debugElement . children [ 0 ] ;
168
+ dispatchEvent ( element . nativeElement , 'click' ) ;
169
+ expect ( componentFixture . nativeElement ) . toHaveText ( '1' ) ;
170
+
171
+ // Component is updated asynchronously. Wait for the fixture to become stable
172
+ // before checking.
173
+ componentFixture . whenRenderingDone ( ) . then ( ( waited ) => {
174
+ expect ( waited ) . toBe ( true ) ;
175
+ componentFixture . detectChanges ( ) ;
176
+ expect ( componentFixture . nativeElement ) . toHaveText ( '11' ) ;
177
+ } ) ;
178
+ } ) ) ;
179
+
161
180
it ( 'should wait for macroTask(setTimeout) while checking for whenStable ' +
162
181
'(autoDetectChanges)' ,
163
182
async ( ( ) => {
Original file line number Diff line number Diff line change @@ -160,6 +160,14 @@ export class ComponentFixture<T> {
160
160
}
161
161
}
162
162
163
+ /**
164
+ * Get a promise that resolves when the ui state is stable following animations.
165
+ */
166
+ whenRenderingDone ( ) : Promise < any > {
167
+ // this is temporary until this is functional
168
+ return this . whenStable ( ) ;
169
+ }
170
+
163
171
/**
164
172
* Trigger component destruction.
165
173
*/
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ export declare class ComponentFixture<T> {
16
16
destroy ( ) : void ;
17
17
detectChanges ( checkNoChanges ?: boolean ) : void ;
18
18
isStable ( ) : boolean ;
19
+ whenRenderingDone ( ) : Promise < any > ;
19
20
whenStable ( ) : Promise < any > ;
20
21
}
21
22
You can’t perform that action at this time.
0 commit comments