1
|
/**
|
2
|
* Clears out the shared fake async zone for a test.
|
3
|
* To be called in a global `beforeEach`.
|
4
|
*
|
5
|
* @experimental
|
6
|
*/
|
7
|
export declare function resetFakeAsyncZone(): void;
|
8
|
/**
|
9
|
* Wraps a function to be executed in the fakeAsync zone:
|
10
|
* - microtasks are manually executed by calling `flushMicrotasks()`,
|
11
|
* - timers are synchronous, `tick()` simulates the asynchronous passage of time.
|
12
|
*
|
13
|
* If there are any pending timers at the end of the function, an exception will be thrown.
|
14
|
*
|
15
|
* Can be used to wrap inject() calls.
|
16
|
*
|
17
|
* ## Example
|
18
|
*
|
19
|
* {@example testing/ts/fake_async.ts region='basic'}
|
20
|
*
|
21
|
* @param fn
|
22
|
* @returns {Function} The function wrapped to be executed in the fakeAsync zone
|
23
|
*
|
24
|
* @experimental
|
25
|
*/
|
26
|
export declare function fakeAsync(fn: Function): (...args: any[]) => any;
|
27
|
/**
|
28
|
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone.
|
29
|
*
|
30
|
* The microtasks queue is drained at the very start of this function and after any timer callback
|
31
|
* has been executed.
|
32
|
*
|
33
|
* ## Example
|
34
|
*
|
35
|
* {@example testing/ts/fake_async.ts region='basic'}
|
36
|
*
|
37
|
* @experimental
|
38
|
*/
|
39
|
export declare function tick(millis?: number): void;
|
40
|
/**
|
41
|
* Simulates the asynchronous passage of time for the timers in the fakeAsync zone by
|
42
|
* draining the macrotask queue until it is empty. The returned value is the milliseconds
|
43
|
* of time that would have been elapsed.
|
44
|
*
|
45
|
* @param maxTurns
|
46
|
* @returns {number} The simulated time elapsed, in millis.
|
47
|
*
|
48
|
* @experimental
|
49
|
*/
|
50
|
export declare function flush(maxTurns?: number): number;
|
51
|
/**
|
52
|
* Discard all remaining periodic tasks.
|
53
|
*
|
54
|
* @experimental
|
55
|
*/
|
56
|
export declare function discardPeriodicTasks(): void;
|
57
|
/**
|
58
|
* Flush any pending microtasks.
|
59
|
*
|
60
|
* @experimental
|
61
|
*/
|
62
|
export declare function flushMicrotasks(): void;
|