1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import type {Config} from '@jest/types';
|
8 | import type {ModuleMocker} from 'jest-mock';
|
9 | import {StackTraceConfig} from 'jest-message-util';
|
10 |
|
11 | declare type Callback = (...args: Array<unknown>) => void;
|
12 |
|
13 | export declare class LegacyFakeTimers<TimerRef = unknown> {
|
14 | private _cancelledTicks;
|
15 | private readonly _config;
|
16 | private _disposed;
|
17 | private _fakeTimerAPIs;
|
18 | private _fakingTime;
|
19 | private _global;
|
20 | private _immediates;
|
21 | private readonly _maxLoops;
|
22 | private readonly _moduleMocker;
|
23 | private _now;
|
24 | private _ticks;
|
25 | private readonly _timerAPIs;
|
26 | private _timers;
|
27 | private _uuidCounter;
|
28 | private readonly _timerConfig;
|
29 | constructor({
|
30 | global,
|
31 | moduleMocker,
|
32 | timerConfig,
|
33 | config,
|
34 | maxLoops,
|
35 | }: {
|
36 | global: typeof globalThis;
|
37 | moduleMocker: ModuleMocker;
|
38 | timerConfig: TimerConfig<TimerRef>;
|
39 | config: StackTraceConfig;
|
40 | maxLoops?: number;
|
41 | });
|
42 | clearAllTimers(): void;
|
43 | dispose(): void;
|
44 | reset(): void;
|
45 | now(): number;
|
46 | runAllTicks(): void;
|
47 | runAllImmediates(): void;
|
48 | private _runImmediate;
|
49 | runAllTimers(): void;
|
50 | runOnlyPendingTimers(): void;
|
51 | advanceTimersToNextTimer(steps?: number): void;
|
52 | advanceTimersByTime(msToRun: number): void;
|
53 | runWithRealTimers(cb: Callback): void;
|
54 | useRealTimers(): void;
|
55 | useFakeTimers(): void;
|
56 | getTimerCount(): number;
|
57 | private _checkFakeTimers;
|
58 | private _createMocks;
|
59 | private _fakeClearTimer;
|
60 | private _fakeClearImmediate;
|
61 | private _fakeNextTick;
|
62 | private _fakeRequestAnimationFrame;
|
63 | private _fakeSetImmediate;
|
64 | private _fakeSetInterval;
|
65 | private _fakeSetTimeout;
|
66 | private _getNextTimerHandleAndExpiry;
|
67 | private _runTimerHandle;
|
68 | }
|
69 |
|
70 | export declare class ModernFakeTimers {
|
71 | private _clock;
|
72 | private readonly _config;
|
73 | private _fakingTime;
|
74 | private readonly _global;
|
75 | private readonly _fakeTimers;
|
76 | constructor({
|
77 | global,
|
78 | config,
|
79 | }: {
|
80 | global: typeof globalThis;
|
81 | config: Config.ProjectConfig;
|
82 | });
|
83 | clearAllTimers(): void;
|
84 | dispose(): void;
|
85 | runAllTimers(): void;
|
86 | runAllTimersAsync(): Promise<void>;
|
87 | runOnlyPendingTimers(): void;
|
88 | runOnlyPendingTimersAsync(): Promise<void>;
|
89 | advanceTimersToNextTimer(steps?: number): void;
|
90 | advanceTimersToNextTimerAsync(steps?: number): Promise<void>;
|
91 | advanceTimersByTime(msToRun: number): void;
|
92 | advanceTimersByTimeAsync(msToRun: number): Promise<void>;
|
93 | runAllTicks(): void;
|
94 | useRealTimers(): void;
|
95 | useFakeTimers(fakeTimersConfig?: Config.FakeTimersConfig): void;
|
96 | reset(): void;
|
97 | setSystemTime(now?: number | Date): void;
|
98 | getRealSystemTime(): number;
|
99 | now(): number;
|
100 | getTimerCount(): number;
|
101 | private _checkFakeTimers;
|
102 | private _toSinonFakeTimersConfig;
|
103 | }
|
104 |
|
105 | declare type TimerConfig<Ref> = {
|
106 | idToRef: (id: number) => Ref;
|
107 | refToId: (ref: Ref) => number | void;
|
108 | };
|
109 |
|
110 | export {};
|