@assistant-ui/react 0.8.16 → 0.8.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +1 -0
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +1 -0
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.js +3 -3
- package/dist/runtimes/edge/streams/toolResultStream.js.map +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.mjs +1 -1
- package/dist/runtimes/edge/streams/toolResultStream.mjs.map +1 -1
- package/dist/tests/setup.js +2272 -1930
- package/dist/tests/setup.js.map +1 -1
- package/dist/tests/setup.mjs +2277 -1935
- package/dist/tests/setup.mjs.map +1 -1
- package/package.json +11 -11
- package/src/api/ThreadRuntime.ts +1 -0
- package/src/runtimes/edge/streams/toolResultStream.ts +1 -1
package/dist/tests/setup.mjs
CHANGED
@@ -1,19 +1,14 @@
|
|
1
|
-
// ../../node_modules/.pnpm/vitest@1.
|
2
|
-
import {
|
3
|
-
|
4
|
-
|
5
|
-
import
|
6
|
-
import { createChainable } from "@vitest/runner/utils.mjs";
|
7
|
-
import { noop } from "@vitest/utils.mjs";
|
8
|
-
|
9
|
-
// ../../node_modules/.pnpm/vitest@1.6.1_@types+node@22.13.1_lightningcss@1.29.1_terser@5.38.1/node_modules/vitest/dist/vendor/index.SMVOaj7F.js
|
10
|
-
import { relative } from "pathe.mjs";
|
11
|
-
import "@vitest/runner/utils.mjs";
|
12
|
-
import "@vitest/utils.mjs";
|
1
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
|
2
|
+
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from "@vitest/expect.mjs";
|
3
|
+
import { getCurrentTest } from "@vitest/runner.mjs";
|
4
|
+
import { getNames, getTestName } from "@vitest/runner/utils.mjs";
|
5
|
+
import * as chai$1 from "chai.mjs";
|
13
6
|
|
14
|
-
// ../../node_modules/.pnpm/vitest@1.
|
7
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/chunks/utils.CtocqOoE.js
|
8
|
+
import { getSafeTimers } from "@vitest/utils.mjs";
|
9
|
+
var NAME_WORKER_STATE = "__vitest_worker__";
|
15
10
|
function getWorkerState() {
|
16
|
-
const workerState = globalThis
|
11
|
+
const workerState = globalThis[NAME_WORKER_STATE];
|
17
12
|
if (!workerState) {
|
18
13
|
const errorMsg = 'Vitest failed to access its internal state.\n\nOne of the following is possible:\n- "vitest" is imported directly without running "vitest" command\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
|
19
14
|
throw new Error(errorMsg);
|
@@ -22,103 +17,66 @@ function getWorkerState() {
|
|
22
17
|
}
|
23
18
|
function getCurrentEnvironment() {
|
24
19
|
const state = getWorkerState();
|
25
|
-
return state
|
26
|
-
}
|
27
|
-
|
28
|
-
// ../../node_modules/.pnpm/vitest@1.6.1_@types+node@22.13.1_lightningcss@1.29.1_terser@5.38.1/node_modules/vitest/dist/vendor/index.SMVOaj7F.js
|
29
|
-
function getRunMode() {
|
30
|
-
return getWorkerState().config.mode;
|
20
|
+
return state?.environment.name;
|
31
21
|
}
|
32
|
-
function
|
33
|
-
return
|
22
|
+
function isChildProcess() {
|
23
|
+
return typeof process !== "undefined" && !!process.send;
|
34
24
|
}
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
benchFns.set(task, fn2);
|
50
|
-
benchOptsMap.set(task, options);
|
51
|
-
}
|
52
|
-
);
|
53
|
-
function createBenchmark(fn2) {
|
54
|
-
const benchmark = createChainable(
|
55
|
-
["skip", "only", "todo"],
|
56
|
-
fn2
|
57
|
-
);
|
58
|
-
benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
|
59
|
-
benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
|
60
|
-
return benchmark;
|
25
|
+
function resetModules(modules, resetMocks = false) {
|
26
|
+
const skipPaths = [
|
27
|
+
/\/vitest\/dist\//,
|
28
|
+
/\/vite-node\/dist\//,
|
29
|
+
/vitest-virtual-\w+\/dist/,
|
30
|
+
/@vitest\/dist/,
|
31
|
+
...!resetMocks ? [/^mock:/] : []
|
32
|
+
];
|
33
|
+
modules.forEach((mod, path) => {
|
34
|
+
if (skipPaths.some((re) => re.test(path))) {
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
modules.invalidateModule(mod);
|
38
|
+
});
|
61
39
|
}
|
62
|
-
function
|
63
|
-
|
40
|
+
function waitNextTick() {
|
41
|
+
const { setTimeout } = getSafeTimers();
|
42
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
64
43
|
}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
const
|
71
|
-
|
72
|
-
|
73
|
-
|
44
|
+
async function waitForImportsToResolve() {
|
45
|
+
await waitNextTick();
|
46
|
+
const state = getWorkerState();
|
47
|
+
const promises = [];
|
48
|
+
let resolvingCount = 0;
|
49
|
+
for (const mod of state.moduleCache.values()) {
|
50
|
+
if (mod.promise && !mod.evaluated) {
|
51
|
+
promises.push(mod.promise);
|
52
|
+
}
|
53
|
+
if (mod.resolving) {
|
54
|
+
resolvingCount++;
|
55
|
+
}
|
74
56
|
}
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
function isFirstRun() {
|
81
|
-
let firstRun = false;
|
82
|
-
runOnce(() => {
|
83
|
-
firstRun = true;
|
84
|
-
}, "__vitest_first_run__");
|
85
|
-
return firstRun;
|
57
|
+
if (!promises.length && !resolvingCount) {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
await Promise.allSettled(promises);
|
61
|
+
await waitForImportsToResolve();
|
86
62
|
}
|
87
63
|
|
88
|
-
// ../../node_modules/.pnpm/vitest@1.
|
89
|
-
import
|
64
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
|
65
|
+
import { getSafeTimers as getSafeTimers2, assertTypes, createSimpleStackTrace } from "@vitest/utils.mjs";
|
90
66
|
|
91
|
-
// ../../node_modules/.pnpm/vitest@1.
|
67
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
|
92
68
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
93
69
|
function getDefaultExportFromCjs(x) {
|
94
70
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
95
71
|
}
|
96
72
|
|
97
|
-
// ../../node_modules/.pnpm/vitest@1.
|
98
|
-
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT as GLOBAL_EXPECT$1, ASYMMETRIC_MATCHERS_OBJECT as ASYMMETRIC_MATCHERS_OBJECT$1, getState, setState, addCustomEqualityTesters } from "@vitest/expect.mjs";
|
73
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
|
99
74
|
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from "@vitest/snapshot.mjs";
|
100
|
-
import { getNames as getNames2 } from "@vitest/runner/utils.mjs";
|
101
75
|
import "@vitest/utils/error.mjs";
|
102
|
-
import {
|
103
|
-
|
104
|
-
// ../../node_modules/.pnpm/vitest@1.6.1_@types+node@22.13.1_lightningcss@1.29.1_terser@5.38.1/node_modules/vitest/dist/vendor/tasks.IknbGB2n.js
|
105
|
-
import { getNames, getTests } from "@vitest/runner/utils.mjs";
|
106
|
-
import "@vitest/utils.mjs";
|
107
|
-
function getFullName(task, separator = " > ") {
|
108
|
-
return getNames(task).join(separator);
|
109
|
-
}
|
110
|
-
|
111
|
-
// ../../node_modules/.pnpm/vitest@1.6.1_@types+node@22.13.1_lightningcss@1.29.1_terser@5.38.1/node_modules/vitest/dist/vendor/vi.YFlodzP_.js
|
112
|
-
import { getSafeTimers, assertTypes, createSimpleStackTrace } from "@vitest/utils.mjs";
|
76
|
+
import { fn, spyOn, mocks, isMockFunction } from "@vitest/spy.mjs";
|
113
77
|
import { parseSingleStack } from "@vitest/utils/source-map.mjs";
|
114
78
|
|
115
|
-
// ../../node_modules/.pnpm/vitest@1.
|
116
|
-
import "@vitest/utils.mjs";
|
117
|
-
function isChildProcess() {
|
118
|
-
return typeof process !== "undefined" && !!process.send;
|
119
|
-
}
|
120
|
-
|
121
|
-
// ../../node_modules/.pnpm/vitest@1.6.1_@types+node@22.13.1_lightningcss@1.29.1_terser@5.38.1/node_modules/vitest/dist/vendor/date.Ns1pGd_X.js
|
79
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/chunks/date.CDOsz-HY.js
|
122
80
|
var RealDate = Date;
|
123
81
|
var now = null;
|
124
82
|
var MockDate = class _MockDate extends RealDate {
|
@@ -127,10 +85,11 @@ var MockDate = class _MockDate extends RealDate {
|
|
127
85
|
let date;
|
128
86
|
switch (arguments.length) {
|
129
87
|
case 0:
|
130
|
-
if (now !== null)
|
88
|
+
if (now !== null) {
|
131
89
|
date = new RealDate(now.valueOf());
|
132
|
-
else
|
90
|
+
} else {
|
133
91
|
date = new RealDate();
|
92
|
+
}
|
134
93
|
break;
|
135
94
|
case 1:
|
136
95
|
date = new RealDate(y);
|
@@ -160,8 +119,9 @@ MockDate.toString = function() {
|
|
160
119
|
};
|
161
120
|
function mockDate(date) {
|
162
121
|
const dateObj = new RealDate(date.valueOf());
|
163
|
-
if (Number.isNaN(dateObj.getTime()))
|
122
|
+
if (Number.isNaN(dateObj.getTime())) {
|
164
123
|
throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
|
124
|
+
}
|
165
125
|
globalThis.Date = MockDate;
|
166
126
|
now = dateObj.valueOf();
|
167
127
|
}
|
@@ -169,177 +129,265 @@ function resetDate() {
|
|
169
129
|
globalThis.Date = RealDate;
|
170
130
|
}
|
171
131
|
|
172
|
-
// ../../node_modules/.pnpm/vitest@1.
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
132
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/chunks/vi.B-PuvDzu.js
|
133
|
+
var unsupported = [
|
134
|
+
"matchSnapshot",
|
135
|
+
"toMatchSnapshot",
|
136
|
+
"toMatchInlineSnapshot",
|
137
|
+
"toThrowErrorMatchingSnapshot",
|
138
|
+
"toThrowErrorMatchingInlineSnapshot",
|
139
|
+
"throws",
|
140
|
+
"Throw",
|
141
|
+
"throw",
|
142
|
+
"toThrow",
|
143
|
+
"toThrowError"
|
144
|
+
];
|
145
|
+
function createExpectPoll(expect2) {
|
146
|
+
return function poll(fn2, options = {}) {
|
147
|
+
const state = getWorkerState();
|
148
|
+
const defaults = state.config.expect?.poll ?? {};
|
149
|
+
const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
|
150
|
+
const assertion = expect2(null, message).withContext({ poll: true });
|
151
|
+
fn2 = fn2.bind(assertion);
|
152
|
+
const test2 = chai$1.util.flag(assertion, "vitest-test");
|
153
|
+
if (!test2) {
|
154
|
+
throw new Error("expect.poll() must be called inside a test");
|
155
|
+
}
|
156
|
+
const proxy = new Proxy(assertion, { get(target, key, receiver) {
|
157
|
+
const assertionFunction = Reflect.get(target, key, receiver);
|
158
|
+
if (typeof assertionFunction !== "function") {
|
159
|
+
return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
|
160
|
+
}
|
161
|
+
if (key === "assert") {
|
162
|
+
return assertionFunction;
|
163
|
+
}
|
164
|
+
if (typeof key === "string" && unsupported.includes(key)) {
|
165
|
+
throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
|
166
|
+
}
|
167
|
+
return function(...args) {
|
168
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
169
|
+
const promise = () => new Promise((resolve, reject) => {
|
170
|
+
let intervalId;
|
171
|
+
let timeoutId;
|
172
|
+
let lastError;
|
173
|
+
const { setTimeout, clearTimeout } = getSafeTimers2();
|
174
|
+
const check = async () => {
|
175
|
+
try {
|
176
|
+
chai$1.util.flag(assertion, "_name", key);
|
177
|
+
const obj = await fn2();
|
178
|
+
chai$1.util.flag(assertion, "object", obj);
|
179
|
+
resolve(await assertionFunction.call(assertion, ...args));
|
180
|
+
clearTimeout(intervalId);
|
181
|
+
clearTimeout(timeoutId);
|
182
|
+
} catch (err) {
|
183
|
+
lastError = err;
|
184
|
+
if (!chai$1.util.flag(assertion, "_isLastPollAttempt")) {
|
185
|
+
intervalId = setTimeout(check, interval);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
};
|
189
|
+
timeoutId = setTimeout(() => {
|
190
|
+
clearTimeout(intervalId);
|
191
|
+
chai$1.util.flag(assertion, "_isLastPollAttempt", true);
|
192
|
+
const rejectWithCause = (cause) => {
|
193
|
+
reject(copyStackTrace$1(new Error("Matcher did not succeed in time.", { cause }), STACK_TRACE_ERROR));
|
194
|
+
};
|
195
|
+
check().then(() => rejectWithCause(lastError)).catch((e) => rejectWithCause(e));
|
196
|
+
}, timeout);
|
197
|
+
check();
|
198
|
+
});
|
199
|
+
let awaited = false;
|
200
|
+
test2.onFinished ??= [];
|
201
|
+
test2.onFinished.push(() => {
|
202
|
+
if (!awaited) {
|
203
|
+
const negated = chai$1.util.flag(assertion, "negate") ? "not." : "";
|
204
|
+
const name = chai$1.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)";
|
205
|
+
const assertionString = `expect.${name}.${negated}${String(key)}()`;
|
206
|
+
const error = new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
|
207
|
+
|
208
|
+
await ${assertionString}
|
209
|
+
`);
|
210
|
+
throw copyStackTrace$1(error, STACK_TRACE_ERROR);
|
211
|
+
}
|
212
|
+
});
|
213
|
+
let resultPromise;
|
214
|
+
return {
|
215
|
+
then(onFulfilled, onRejected) {
|
216
|
+
awaited = true;
|
217
|
+
return (resultPromise ||= promise()).then(onFulfilled, onRejected);
|
218
|
+
},
|
219
|
+
catch(onRejected) {
|
220
|
+
return (resultPromise ||= promise()).catch(onRejected);
|
221
|
+
},
|
222
|
+
finally(onFinally) {
|
223
|
+
return (resultPromise ||= promise()).finally(onFinally);
|
224
|
+
},
|
225
|
+
[Symbol.toStringTag]: "Promise"
|
226
|
+
};
|
227
|
+
};
|
228
|
+
} });
|
229
|
+
return proxy;
|
230
|
+
};
|
195
231
|
}
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
const promises = [];
|
200
|
-
let resolvingCount = 0;
|
201
|
-
for (const mod of state.moduleCache.values()) {
|
202
|
-
if (mod.promise && !mod.evaluated)
|
203
|
-
promises.push(mod.promise);
|
204
|
-
if (mod.resolving)
|
205
|
-
resolvingCount++;
|
232
|
+
function copyStackTrace$1(target, source) {
|
233
|
+
if (source.stack !== void 0) {
|
234
|
+
target.stack = source.stack.replace(source.message, target.message);
|
206
235
|
}
|
207
|
-
|
208
|
-
return;
|
209
|
-
await Promise.allSettled(promises);
|
210
|
-
await waitForImportsToResolve();
|
236
|
+
return target;
|
211
237
|
}
|
212
238
|
function commonjsRequire(path) {
|
213
239
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
214
240
|
}
|
215
|
-
var chaiSubset = { exports: {} };
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
var actual = utils.flag(this, "object");
|
229
|
-
var showDiff = chai4.config.showDiff;
|
230
|
-
assertionPrototype.assert.call(
|
231
|
-
this,
|
232
|
-
compare(expected, actual),
|
233
|
-
"expected #{act} to contain subset #{exp}",
|
234
|
-
"expected #{act} to not contain subset #{exp}",
|
235
|
-
expected,
|
236
|
-
actual,
|
237
|
-
showDiff
|
238
|
-
);
|
239
|
-
});
|
240
|
-
chai4.assert.containSubset = function(val, exp, msg) {
|
241
|
-
new chai4.Assertion(val, msg).to.be.containSubset(exp);
|
242
|
-
};
|
243
|
-
function compare(expected, actual) {
|
244
|
-
if (expected === actual) {
|
245
|
-
return true;
|
246
|
-
}
|
247
|
-
if (typeof actual !== typeof expected) {
|
248
|
-
return false;
|
249
|
-
}
|
250
|
-
if (typeof expected !== "object" || expected === null) {
|
251
|
-
return expected === actual;
|
252
|
-
}
|
253
|
-
if (!!expected && !actual) {
|
254
|
-
return false;
|
241
|
+
var chaiSubset$1 = { exports: {} };
|
242
|
+
var chaiSubset = chaiSubset$1.exports;
|
243
|
+
var hasRequiredChaiSubset;
|
244
|
+
function requireChaiSubset() {
|
245
|
+
if (hasRequiredChaiSubset) return chaiSubset$1.exports;
|
246
|
+
hasRequiredChaiSubset = 1;
|
247
|
+
(function(module, exports) {
|
248
|
+
(function() {
|
249
|
+
(function(chaiSubset2) {
|
250
|
+
if (typeof commonjsRequire === "function" && true && true) {
|
251
|
+
return module.exports = chaiSubset2;
|
252
|
+
} else {
|
253
|
+
return chai.use(chaiSubset2);
|
255
254
|
}
|
256
|
-
|
257
|
-
|
255
|
+
})(function(chai3, utils) {
|
256
|
+
var Assertion2 = chai3.Assertion;
|
257
|
+
var assertionPrototype = Assertion2.prototype;
|
258
|
+
Assertion2.addMethod("containSubset", function(expected) {
|
259
|
+
var actual = utils.flag(this, "object");
|
260
|
+
var showDiff = chai3.config.showDiff;
|
261
|
+
assertionPrototype.assert.call(
|
262
|
+
this,
|
263
|
+
compare(expected, actual),
|
264
|
+
"expected #{act} to contain subset #{exp}",
|
265
|
+
"expected #{act} to not contain subset #{exp}",
|
266
|
+
expected,
|
267
|
+
actual,
|
268
|
+
showDiff
|
269
|
+
);
|
270
|
+
});
|
271
|
+
chai3.assert.containSubset = function(val, exp, msg) {
|
272
|
+
new chai3.Assertion(val, msg).to.be.containSubset(exp);
|
273
|
+
};
|
274
|
+
function compare(expected, actual) {
|
275
|
+
if (expected === actual) {
|
276
|
+
return true;
|
277
|
+
}
|
278
|
+
if (typeof actual !== typeof expected) {
|
258
279
|
return false;
|
259
280
|
}
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
});
|
265
|
-
});
|
266
|
-
}
|
267
|
-
if (expected instanceof Date) {
|
268
|
-
if (actual instanceof Date) {
|
269
|
-
return expected.getTime() === actual.getTime();
|
270
|
-
} else {
|
281
|
+
if (typeof expected !== "object" || expected === null) {
|
282
|
+
return expected === actual;
|
283
|
+
}
|
284
|
+
if (!!expected && !actual) {
|
271
285
|
return false;
|
272
286
|
}
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
return
|
287
|
+
if (Array.isArray(expected)) {
|
288
|
+
if (typeof actual.length !== "number") {
|
289
|
+
return false;
|
290
|
+
}
|
291
|
+
var aa = Array.prototype.slice.call(actual);
|
292
|
+
return expected.every(function(exp) {
|
293
|
+
return aa.some(function(act) {
|
294
|
+
return compare(exp, act);
|
295
|
+
});
|
296
|
+
});
|
279
297
|
}
|
280
|
-
if (
|
281
|
-
|
298
|
+
if (expected instanceof Date) {
|
299
|
+
if (actual instanceof Date) {
|
300
|
+
return expected.getTime() === actual.getTime();
|
301
|
+
} else {
|
302
|
+
return false;
|
303
|
+
}
|
282
304
|
}
|
283
|
-
return
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
}
|
289
|
-
|
305
|
+
return Object.keys(expected).every(function(key) {
|
306
|
+
var eo = expected[key];
|
307
|
+
var ao = actual[key];
|
308
|
+
if (typeof eo === "object" && eo !== null && ao !== null) {
|
309
|
+
return compare(eo, ao);
|
310
|
+
}
|
311
|
+
if (typeof eo === "function") {
|
312
|
+
return eo(ao);
|
313
|
+
}
|
314
|
+
return ao === eo;
|
315
|
+
});
|
316
|
+
}
|
317
|
+
});
|
318
|
+
}).call(chaiSubset);
|
319
|
+
})(chaiSubset$1);
|
320
|
+
return chaiSubset$1.exports;
|
321
|
+
}
|
322
|
+
var chaiSubsetExports = requireChaiSubset();
|
290
323
|
var Subset = /* @__PURE__ */ getDefaultExportFromCjs(chaiSubsetExports);
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
const matchers = /* @__PURE__ */ Object.create(null);
|
298
|
-
const customEqualityTesters = [];
|
299
|
-
const assymetricMatchers = /* @__PURE__ */ Object.create(null);
|
300
|
-
Object.defineProperty(globalThis, MATCHERS_OBJECT, {
|
301
|
-
get: () => globalState
|
302
|
-
});
|
303
|
-
Object.defineProperty(globalThis, JEST_MATCHERS_OBJECT, {
|
304
|
-
configurable: true,
|
305
|
-
get: () => ({
|
306
|
-
state: globalState.get(globalThis[GLOBAL_EXPECT]),
|
307
|
-
matchers,
|
308
|
-
customEqualityTesters
|
309
|
-
})
|
310
|
-
});
|
311
|
-
Object.defineProperty(globalThis, ASYMMETRIC_MATCHERS_OBJECT, {
|
312
|
-
get: () => assymetricMatchers
|
313
|
-
});
|
324
|
+
function createAssertionMessage(util2, assertion, hasArgs) {
|
325
|
+
const not = util2.flag(assertion, "negate") ? "not." : "";
|
326
|
+
const name = `${util2.flag(assertion, "_name")}(${"expected"})`;
|
327
|
+
const promiseName = util2.flag(assertion, "promise");
|
328
|
+
const promise = promiseName ? `.${promiseName}` : "";
|
329
|
+
return `expect(actual)${promise}.${not}${name}`;
|
314
330
|
}
|
315
|
-
function recordAsyncExpect(
|
316
|
-
|
331
|
+
function recordAsyncExpect(_test, promise, assertion, error) {
|
332
|
+
const test2 = _test;
|
333
|
+
if (test2 && promise instanceof Promise) {
|
317
334
|
promise = promise.finally(() => {
|
318
|
-
|
319
|
-
|
320
|
-
|
335
|
+
if (!test2.promises) {
|
336
|
+
return;
|
337
|
+
}
|
338
|
+
const index = test2.promises.indexOf(promise);
|
339
|
+
if (index !== -1) {
|
340
|
+
test2.promises.splice(index, 1);
|
341
|
+
}
|
342
|
+
});
|
343
|
+
if (!test2.promises) {
|
344
|
+
test2.promises = [];
|
345
|
+
}
|
346
|
+
test2.promises.push(promise);
|
347
|
+
let resolved = false;
|
348
|
+
test2.onFinished ??= [];
|
349
|
+
test2.onFinished.push(() => {
|
350
|
+
if (!resolved) {
|
351
|
+
const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
|
352
|
+
const stack = processor(error.stack);
|
353
|
+
console.warn([
|
354
|
+
`Promise returned by \`${assertion}\` was not awaited. `,
|
355
|
+
"Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
|
356
|
+
"Please remember to await the assertion.\n",
|
357
|
+
stack
|
358
|
+
].join(""));
|
359
|
+
}
|
321
360
|
});
|
322
|
-
|
323
|
-
|
324
|
-
|
361
|
+
return {
|
362
|
+
then(onFulfilled, onRejected) {
|
363
|
+
resolved = true;
|
364
|
+
return promise.then(onFulfilled, onRejected);
|
365
|
+
},
|
366
|
+
catch(onRejected) {
|
367
|
+
return promise.catch(onRejected);
|
368
|
+
},
|
369
|
+
finally(onFinally) {
|
370
|
+
return promise.finally(onFinally);
|
371
|
+
},
|
372
|
+
[Symbol.toStringTag]: "Promise"
|
373
|
+
};
|
325
374
|
}
|
326
375
|
return promise;
|
327
376
|
}
|
328
377
|
var _client;
|
329
378
|
function getSnapshotClient() {
|
330
379
|
if (!_client) {
|
331
|
-
_client = new SnapshotClient({
|
332
|
-
|
333
|
-
|
334
|
-
}
|
335
|
-
});
|
380
|
+
_client = new SnapshotClient({ isEqual: (received, expected) => {
|
381
|
+
return equals(received, expected, [iterableEquality, subsetEquality]);
|
382
|
+
} });
|
336
383
|
}
|
337
384
|
return _client;
|
338
385
|
}
|
339
386
|
function getError(expected, promise) {
|
340
387
|
if (typeof expected !== "function") {
|
341
|
-
if (!promise)
|
388
|
+
if (!promise) {
|
342
389
|
throw new Error(`expected must be a function, received ${typeof expected}`);
|
390
|
+
}
|
343
391
|
return expected;
|
344
392
|
}
|
345
393
|
try {
|
@@ -349,177 +397,167 @@ function getError(expected, promise) {
|
|
349
397
|
}
|
350
398
|
throw new Error("snapshot function didn't throw");
|
351
399
|
}
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
return {
|
358
|
-
filepath: (_a = test3.file) == null ? void 0 : _a.filepath,
|
359
|
-
name: getNames2(test3).slice(1).join(" > ")
|
360
|
-
};
|
400
|
+
function getTestNames(test2) {
|
401
|
+
return {
|
402
|
+
filepath: test2.file.filepath,
|
403
|
+
name: getNames(test2).slice(1).join(" > "),
|
404
|
+
testId: test2.id
|
361
405
|
};
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
const expected = utils.flag(this, "object");
|
371
|
-
const test3 = utils.flag(this, "vitest-test");
|
372
|
-
if (typeof properties === "string" && typeof message === "undefined") {
|
373
|
-
message = properties;
|
374
|
-
properties = void 0;
|
375
|
-
}
|
376
|
-
const errorMessage = utils.flag(this, "message");
|
377
|
-
getSnapshotClient().assert({
|
378
|
-
received: expected,
|
379
|
-
message,
|
380
|
-
isInline: false,
|
381
|
-
properties,
|
382
|
-
errorMessage,
|
383
|
-
...getTestNames(test3)
|
384
|
-
});
|
385
|
-
}
|
386
|
-
);
|
406
|
+
}
|
407
|
+
var SnapshotPlugin = (chai3, utils) => {
|
408
|
+
function getTest(assertionName, obj) {
|
409
|
+
const test2 = utils.flag(obj, "vitest-test");
|
410
|
+
if (!test2) {
|
411
|
+
throw new Error(`'${assertionName}' cannot be used without test context`);
|
412
|
+
}
|
413
|
+
return test2;
|
387
414
|
}
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
function(file, message) {
|
392
|
-
const isNot = utils.flag(this, "negate");
|
393
|
-
if (isNot)
|
394
|
-
throw new Error('toMatchFileSnapshot cannot be used with "not"');
|
395
|
-
const expected = utils.flag(this, "object");
|
396
|
-
const test3 = utils.flag(this, "vitest-test");
|
397
|
-
const errorMessage = utils.flag(this, "message");
|
398
|
-
const promise = getSnapshotClient().assertRaw({
|
399
|
-
received: expected,
|
400
|
-
message,
|
401
|
-
isInline: false,
|
402
|
-
rawSnapshot: {
|
403
|
-
file
|
404
|
-
},
|
405
|
-
errorMessage,
|
406
|
-
...getTestNames(test3)
|
407
|
-
});
|
408
|
-
return recordAsyncExpect(test3, promise);
|
409
|
-
}
|
410
|
-
);
|
411
|
-
utils.addMethod(
|
412
|
-
chai4.Assertion.prototype,
|
413
|
-
"toMatchInlineSnapshot",
|
414
|
-
function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
415
|
-
var _a;
|
415
|
+
for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
|
416
|
+
utils.addMethod(chai3.Assertion.prototype, key, function(properties, message) {
|
417
|
+
utils.flag(this, "_name", key);
|
416
418
|
const isNot = utils.flag(this, "negate");
|
417
|
-
if (isNot)
|
418
|
-
throw new Error(
|
419
|
-
|
420
|
-
const isInsideEach = test3 && (test3.each || ((_a = test3.suite) == null ? void 0 : _a.each));
|
421
|
-
if (isInsideEach)
|
422
|
-
throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
419
|
+
if (isNot) {
|
420
|
+
throw new Error(`${key} cannot be used with "not"`);
|
421
|
+
}
|
423
422
|
const expected = utils.flag(this, "object");
|
424
|
-
const
|
425
|
-
if (typeof properties === "string") {
|
426
|
-
message =
|
427
|
-
inlineSnapshot = properties;
|
423
|
+
const test2 = getTest(key, this);
|
424
|
+
if (typeof properties === "string" && typeof message === "undefined") {
|
425
|
+
message = properties;
|
428
426
|
properties = void 0;
|
429
427
|
}
|
430
|
-
if (inlineSnapshot)
|
431
|
-
inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
432
428
|
const errorMessage = utils.flag(this, "message");
|
433
429
|
getSnapshotClient().assert({
|
434
430
|
received: expected,
|
435
431
|
message,
|
436
|
-
isInline:
|
432
|
+
isInline: false,
|
437
433
|
properties,
|
438
|
-
inlineSnapshot,
|
439
|
-
error,
|
440
|
-
errorMessage,
|
441
|
-
...getTestNames(test3)
|
442
|
-
});
|
443
|
-
}
|
444
|
-
);
|
445
|
-
utils.addMethod(
|
446
|
-
chai4.Assertion.prototype,
|
447
|
-
"toThrowErrorMatchingSnapshot",
|
448
|
-
function(message) {
|
449
|
-
const isNot = utils.flag(this, "negate");
|
450
|
-
if (isNot)
|
451
|
-
throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
|
452
|
-
const expected = utils.flag(this, "object");
|
453
|
-
const test3 = utils.flag(this, "vitest-test");
|
454
|
-
const promise = utils.flag(this, "promise");
|
455
|
-
const errorMessage = utils.flag(this, "message");
|
456
|
-
getSnapshotClient().assert({
|
457
|
-
received: getError(expected, promise),
|
458
|
-
message,
|
459
434
|
errorMessage,
|
460
|
-
...getTestNames(
|
435
|
+
...getTestNames(test2)
|
461
436
|
});
|
462
|
-
}
|
463
|
-
|
464
|
-
utils.addMethod(
|
465
|
-
|
466
|
-
"
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
"
|
496
|
-
|
497
|
-
|
437
|
+
});
|
438
|
+
}
|
439
|
+
utils.addMethod(chai3.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
|
440
|
+
utils.flag(this, "_name", "toMatchFileSnapshot");
|
441
|
+
const isNot = utils.flag(this, "negate");
|
442
|
+
if (isNot) {
|
443
|
+
throw new Error('toMatchFileSnapshot cannot be used with "not"');
|
444
|
+
}
|
445
|
+
const error = new Error("resolves");
|
446
|
+
const expected = utils.flag(this, "object");
|
447
|
+
const test2 = getTest("toMatchFileSnapshot", this);
|
448
|
+
const errorMessage = utils.flag(this, "message");
|
449
|
+
const promise = getSnapshotClient().assertRaw({
|
450
|
+
received: expected,
|
451
|
+
message,
|
452
|
+
isInline: false,
|
453
|
+
rawSnapshot: { file },
|
454
|
+
errorMessage,
|
455
|
+
...getTestNames(test2)
|
456
|
+
});
|
457
|
+
return recordAsyncExpect(test2, promise, createAssertionMessage(utils, this), error);
|
458
|
+
});
|
459
|
+
utils.addMethod(chai3.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
460
|
+
utils.flag(this, "_name", "toMatchInlineSnapshot");
|
461
|
+
const isNot = utils.flag(this, "negate");
|
462
|
+
if (isNot) {
|
463
|
+
throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
464
|
+
}
|
465
|
+
const test2 = getTest("toMatchInlineSnapshot", this);
|
466
|
+
const isInsideEach = test2.each || test2.suite?.each;
|
467
|
+
if (isInsideEach) {
|
468
|
+
throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
469
|
+
}
|
470
|
+
const expected = utils.flag(this, "object");
|
471
|
+
const error = utils.flag(this, "error");
|
472
|
+
if (typeof properties === "string") {
|
473
|
+
message = inlineSnapshot;
|
474
|
+
inlineSnapshot = properties;
|
475
|
+
properties = void 0;
|
476
|
+
}
|
477
|
+
if (inlineSnapshot) {
|
478
|
+
inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
479
|
+
}
|
480
|
+
const errorMessage = utils.flag(this, "message");
|
481
|
+
getSnapshotClient().assert({
|
482
|
+
received: expected,
|
483
|
+
message,
|
484
|
+
isInline: true,
|
485
|
+
properties,
|
486
|
+
inlineSnapshot,
|
487
|
+
error,
|
488
|
+
errorMessage,
|
489
|
+
...getTestNames(test2)
|
490
|
+
});
|
491
|
+
});
|
492
|
+
utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
|
493
|
+
utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
|
494
|
+
const isNot = utils.flag(this, "negate");
|
495
|
+
if (isNot) {
|
496
|
+
throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
|
497
|
+
}
|
498
|
+
const expected = utils.flag(this, "object");
|
499
|
+
const test2 = getTest("toThrowErrorMatchingSnapshot", this);
|
500
|
+
const promise = utils.flag(this, "promise");
|
501
|
+
const errorMessage = utils.flag(this, "message");
|
502
|
+
getSnapshotClient().assert({
|
503
|
+
received: getError(expected, promise),
|
504
|
+
message,
|
505
|
+
errorMessage,
|
506
|
+
...getTestNames(test2)
|
507
|
+
});
|
508
|
+
});
|
509
|
+
utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
|
510
|
+
const isNot = utils.flag(this, "negate");
|
511
|
+
if (isNot) {
|
512
|
+
throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
|
513
|
+
}
|
514
|
+
const test2 = getTest("toThrowErrorMatchingInlineSnapshot", this);
|
515
|
+
const isInsideEach = test2.each || test2.suite?.each;
|
516
|
+
if (isInsideEach) {
|
517
|
+
throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
518
|
+
}
|
519
|
+
const expected = utils.flag(this, "object");
|
520
|
+
const error = utils.flag(this, "error");
|
521
|
+
const promise = utils.flag(this, "promise");
|
522
|
+
const errorMessage = utils.flag(this, "message");
|
523
|
+
if (inlineSnapshot) {
|
524
|
+
inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
525
|
+
}
|
526
|
+
getSnapshotClient().assert({
|
527
|
+
received: getError(expected, promise),
|
528
|
+
message,
|
529
|
+
inlineSnapshot,
|
530
|
+
isInline: true,
|
531
|
+
error,
|
532
|
+
errorMessage,
|
533
|
+
...getTestNames(test2)
|
534
|
+
});
|
535
|
+
});
|
536
|
+
utils.addMethod(chai3.expect, "addSnapshotSerializer", addSerializer);
|
498
537
|
};
|
499
538
|
chai$1.use(JestExtend);
|
500
539
|
chai$1.use(JestChaiExpect);
|
501
540
|
chai$1.use(Subset);
|
502
541
|
chai$1.use(SnapshotPlugin);
|
503
542
|
chai$1.use(JestAsymmetricMatchers);
|
504
|
-
function createExpect(
|
505
|
-
var _a;
|
543
|
+
function createExpect(test2) {
|
506
544
|
const expect2 = (value, message) => {
|
507
545
|
const { assertionCalls } = getState(expect2);
|
508
|
-
setState({ assertionCalls: assertionCalls + 1
|
509
|
-
const
|
510
|
-
const _test =
|
511
|
-
if (_test)
|
512
|
-
return
|
513
|
-
else
|
514
|
-
return
|
546
|
+
setState({ assertionCalls: assertionCalls + 1 }, expect2);
|
547
|
+
const assert3 = chai$1.expect(value, message);
|
548
|
+
const _test = test2 || getCurrentTest();
|
549
|
+
if (_test) {
|
550
|
+
return assert3.withTest(_test);
|
551
|
+
} else {
|
552
|
+
return assert3;
|
553
|
+
}
|
515
554
|
};
|
516
555
|
Object.assign(expect2, chai$1.expect);
|
517
|
-
Object.assign(expect2, globalThis[ASYMMETRIC_MATCHERS_OBJECT
|
556
|
+
Object.assign(expect2, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
518
557
|
expect2.getState = () => getState(expect2);
|
519
558
|
expect2.setState = (state) => setState(state, expect2);
|
520
|
-
const globalState = getState(globalThis[GLOBAL_EXPECT
|
559
|
+
const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
|
521
560
|
setState({
|
522
|
-
// this should also add "snapshotState" that is added conditionally
|
523
561
|
...globalState,
|
524
562
|
assertionCalls: 0,
|
525
563
|
isExpectingAssertions: false,
|
@@ -527,25 +565,25 @@ function createExpect(test3) {
|
|
527
565
|
expectedAssertionsNumber: null,
|
528
566
|
expectedAssertionsNumberErrorGen: null,
|
529
567
|
environment: getCurrentEnvironment(),
|
530
|
-
testPath
|
531
|
-
|
568
|
+
get testPath() {
|
569
|
+
return getWorkerState().filepath;
|
570
|
+
},
|
571
|
+
currentTestName: test2 ? getTestName(test2) : globalState.currentTestName
|
532
572
|
}, expect2);
|
533
573
|
expect2.extend = (matchers) => chai$1.expect.extend(expect2, matchers);
|
534
574
|
expect2.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
535
575
|
expect2.soft = (...args) => {
|
536
|
-
|
537
|
-
expect2.setState({
|
538
|
-
soft: true
|
539
|
-
});
|
540
|
-
return assert22;
|
576
|
+
return expect2(...args).withContext({ soft: true });
|
541
577
|
};
|
578
|
+
expect2.poll = createExpectPoll(expect2);
|
542
579
|
expect2.unreachable = (message) => {
|
543
580
|
chai$1.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
|
544
581
|
};
|
545
582
|
function assertions(expected) {
|
546
583
|
const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect2.getState().assertionCalls}`);
|
547
|
-
if (Error.captureStackTrace)
|
584
|
+
if (Error.captureStackTrace) {
|
548
585
|
Error.captureStackTrace(errorGen(), assertions);
|
586
|
+
}
|
549
587
|
expect2.setState({
|
550
588
|
expectedAssertionsNumber: expected,
|
551
589
|
expectedAssertionsNumberErrorGen: errorGen
|
@@ -553,8 +591,9 @@ function createExpect(test3) {
|
|
553
591
|
}
|
554
592
|
function hasAssertions() {
|
555
593
|
const error = new Error("expected any number of assertion, but got none");
|
556
|
-
if (Error.captureStackTrace)
|
594
|
+
if (Error.captureStackTrace) {
|
557
595
|
Error.captureStackTrace(error, hasAssertions);
|
596
|
+
}
|
558
597
|
expect2.setState({
|
559
598
|
isExpectingAssertions: true,
|
560
599
|
isExpectingAssertionsError: error
|
@@ -562,1461 +601,1833 @@ function createExpect(test3) {
|
|
562
601
|
}
|
563
602
|
chai$1.util.addMethod(expect2, "assertions", assertions);
|
564
603
|
chai$1.util.addMethod(expect2, "hasAssertions", hasAssertions);
|
604
|
+
expect2.extend(customMatchers);
|
565
605
|
return expect2;
|
566
606
|
}
|
567
607
|
var globalExpect = createExpect();
|
568
|
-
Object.defineProperty(globalThis, GLOBAL_EXPECT
|
608
|
+
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
569
609
|
value: globalExpect,
|
570
610
|
writable: true,
|
571
611
|
configurable: true
|
572
612
|
});
|
573
|
-
var
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
globalObject
|
613
|
+
var fakeTimersSrc = {};
|
614
|
+
var global2;
|
615
|
+
var hasRequiredGlobal;
|
616
|
+
function requireGlobal() {
|
617
|
+
if (hasRequiredGlobal) return global2;
|
618
|
+
hasRequiredGlobal = 1;
|
619
|
+
var globalObject;
|
620
|
+
if (typeof commonjsGlobal !== "undefined") {
|
621
|
+
globalObject = commonjsGlobal;
|
622
|
+
} else if (typeof window !== "undefined") {
|
623
|
+
globalObject = window;
|
624
|
+
} else {
|
625
|
+
globalObject = self;
|
626
|
+
}
|
627
|
+
global2 = globalObject;
|
628
|
+
return global2;
|
580
629
|
}
|
581
|
-
var
|
582
|
-
var
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
throwsOnProto
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
"caller",
|
597
|
-
"callee",
|
598
|
-
"arguments"
|
599
|
-
];
|
600
|
-
if (throwsOnProto) {
|
601
|
-
disallowedProperties.push("__proto__");
|
630
|
+
var throwsOnProto_1;
|
631
|
+
var hasRequiredThrowsOnProto;
|
632
|
+
function requireThrowsOnProto() {
|
633
|
+
if (hasRequiredThrowsOnProto) return throwsOnProto_1;
|
634
|
+
hasRequiredThrowsOnProto = 1;
|
635
|
+
let throwsOnProto;
|
636
|
+
try {
|
637
|
+
const object2 = {};
|
638
|
+
object2.__proto__;
|
639
|
+
throwsOnProto = false;
|
640
|
+
} catch (_) {
|
641
|
+
throwsOnProto = true;
|
642
|
+
}
|
643
|
+
throwsOnProto_1 = throwsOnProto;
|
644
|
+
return throwsOnProto_1;
|
602
645
|
}
|
603
|
-
var copyPrototypeMethods
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
646
|
+
var copyPrototypeMethods;
|
647
|
+
var hasRequiredCopyPrototypeMethods;
|
648
|
+
function requireCopyPrototypeMethods() {
|
649
|
+
if (hasRequiredCopyPrototypeMethods) return copyPrototypeMethods;
|
650
|
+
hasRequiredCopyPrototypeMethods = 1;
|
651
|
+
var call = Function.call;
|
652
|
+
var throwsOnProto = requireThrowsOnProto();
|
653
|
+
var disallowedProperties = [
|
654
|
+
// ignore size because it throws from Map
|
655
|
+
"size",
|
656
|
+
"caller",
|
657
|
+
"callee",
|
658
|
+
"arguments"
|
659
|
+
];
|
660
|
+
if (throwsOnProto) {
|
661
|
+
disallowedProperties.push("__proto__");
|
662
|
+
}
|
663
|
+
copyPrototypeMethods = function copyPrototypeMethods2(prototype) {
|
664
|
+
return Object.getOwnPropertyNames(prototype).reduce(
|
665
|
+
function(result, name) {
|
666
|
+
if (disallowedProperties.includes(name)) {
|
667
|
+
return result;
|
668
|
+
}
|
669
|
+
if (typeof prototype[name] !== "function") {
|
670
|
+
return result;
|
671
|
+
}
|
672
|
+
result[name] = call.bind(prototype[name]);
|
610
673
|
return result;
|
611
|
-
}
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
);
|
617
|
-
};
|
618
|
-
var copyPrototype$5 = copyPrototypeMethods;
|
619
|
-
var array = copyPrototype$5(Array.prototype);
|
620
|
-
var every$1 = array.every;
|
621
|
-
function hasCallsLeft(callMap, spy) {
|
622
|
-
if (callMap[spy.id] === void 0) {
|
623
|
-
callMap[spy.id] = 0;
|
624
|
-
}
|
625
|
-
return callMap[spy.id] < spy.callCount;
|
626
|
-
}
|
627
|
-
function checkAdjacentCalls(callMap, spy, index, spies) {
|
628
|
-
var calledBeforeNext = true;
|
629
|
-
if (index !== spies.length - 1) {
|
630
|
-
calledBeforeNext = spy.calledBefore(spies[index + 1]);
|
631
|
-
}
|
632
|
-
if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
|
633
|
-
callMap[spy.id] += 1;
|
634
|
-
return true;
|
635
|
-
}
|
636
|
-
return false;
|
674
|
+
},
|
675
|
+
/* @__PURE__ */ Object.create(null)
|
676
|
+
);
|
677
|
+
};
|
678
|
+
return copyPrototypeMethods;
|
637
679
|
}
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
680
|
+
var array;
|
681
|
+
var hasRequiredArray;
|
682
|
+
function requireArray() {
|
683
|
+
if (hasRequiredArray) return array;
|
684
|
+
hasRequiredArray = 1;
|
685
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
686
|
+
array = copyPrototype(Array.prototype);
|
687
|
+
return array;
|
642
688
|
}
|
643
|
-
var calledInOrder_1
|
644
|
-
var
|
645
|
-
|
646
|
-
|
689
|
+
var calledInOrder_1;
|
690
|
+
var hasRequiredCalledInOrder;
|
691
|
+
function requireCalledInOrder() {
|
692
|
+
if (hasRequiredCalledInOrder) return calledInOrder_1;
|
693
|
+
hasRequiredCalledInOrder = 1;
|
694
|
+
var every2 = requireArray().every;
|
695
|
+
function hasCallsLeft(callMap, spy) {
|
696
|
+
if (callMap[spy.id] === void 0) {
|
697
|
+
callMap[spy.id] = 0;
|
698
|
+
}
|
699
|
+
return callMap[spy.id] < spy.callCount;
|
700
|
+
}
|
701
|
+
function checkAdjacentCalls(callMap, spy, index, spies) {
|
702
|
+
var calledBeforeNext = true;
|
703
|
+
if (index !== spies.length - 1) {
|
704
|
+
calledBeforeNext = spy.calledBefore(spies[index + 1]);
|
705
|
+
}
|
706
|
+
if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
|
707
|
+
callMap[spy.id] += 1;
|
708
|
+
return true;
|
709
|
+
}
|
710
|
+
return false;
|
647
711
|
}
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
// (i.e. toString will say 'spy' rather than 'myFunc').
|
653
|
-
(String(func).match(/function ([^\s(]+)/) || [])[1];
|
654
|
-
} catch (e) {
|
655
|
-
return "";
|
712
|
+
function calledInOrder(spies) {
|
713
|
+
var callMap = {};
|
714
|
+
var _spies = arguments.length > 1 ? arguments : spies;
|
715
|
+
return every2(_spies, checkAdjacentCalls.bind(null, callMap));
|
656
716
|
}
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
717
|
+
calledInOrder_1 = calledInOrder;
|
718
|
+
return calledInOrder_1;
|
719
|
+
}
|
720
|
+
var className_1;
|
721
|
+
var hasRequiredClassName;
|
722
|
+
function requireClassName() {
|
723
|
+
if (hasRequiredClassName) return className_1;
|
724
|
+
hasRequiredClassName = 1;
|
725
|
+
function className(value) {
|
726
|
+
const name = value.constructor && value.constructor.name;
|
727
|
+
return name || null;
|
728
|
+
}
|
729
|
+
className_1 = className;
|
730
|
+
return className_1;
|
668
731
|
}
|
669
|
-
var className_1 = className;
|
670
732
|
var deprecated = {};
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
733
|
+
var hasRequiredDeprecated;
|
734
|
+
function requireDeprecated() {
|
735
|
+
if (hasRequiredDeprecated) return deprecated;
|
736
|
+
hasRequiredDeprecated = 1;
|
737
|
+
(function(exports) {
|
738
|
+
exports.wrap = function(func, msg) {
|
739
|
+
var wrapped = function() {
|
740
|
+
exports.printWarning(msg);
|
741
|
+
return func.apply(this, arguments);
|
742
|
+
};
|
743
|
+
if (func.prototype) {
|
744
|
+
wrapped.prototype = func.prototype;
|
745
|
+
}
|
746
|
+
return wrapped;
|
747
|
+
};
|
748
|
+
exports.defaultMsg = function(packageName, funcName) {
|
749
|
+
return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
|
676
750
|
};
|
677
|
-
|
678
|
-
|
751
|
+
exports.printWarning = function(msg) {
|
752
|
+
if (typeof process === "object" && process.emitWarning) {
|
753
|
+
process.emitWarning(msg);
|
754
|
+
} else if (console.info) {
|
755
|
+
console.info(msg);
|
756
|
+
} else {
|
757
|
+
console.log(msg);
|
758
|
+
}
|
759
|
+
};
|
760
|
+
})(deprecated);
|
761
|
+
return deprecated;
|
762
|
+
}
|
763
|
+
var every;
|
764
|
+
var hasRequiredEvery;
|
765
|
+
function requireEvery() {
|
766
|
+
if (hasRequiredEvery) return every;
|
767
|
+
hasRequiredEvery = 1;
|
768
|
+
every = function every2(obj, fn2) {
|
769
|
+
var pass = true;
|
770
|
+
try {
|
771
|
+
obj.forEach(function() {
|
772
|
+
if (!fn2.apply(this, arguments)) {
|
773
|
+
throw new Error();
|
774
|
+
}
|
775
|
+
});
|
776
|
+
} catch (e) {
|
777
|
+
pass = false;
|
679
778
|
}
|
680
|
-
return
|
779
|
+
return pass;
|
681
780
|
};
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
781
|
+
return every;
|
782
|
+
}
|
783
|
+
var functionName;
|
784
|
+
var hasRequiredFunctionName;
|
785
|
+
function requireFunctionName() {
|
786
|
+
if (hasRequiredFunctionName) return functionName;
|
787
|
+
hasRequiredFunctionName = 1;
|
788
|
+
functionName = function functionName2(func) {
|
789
|
+
if (!func) {
|
790
|
+
return "";
|
791
|
+
}
|
792
|
+
try {
|
793
|
+
return func.displayName || func.name || // Use function decomposition as a last resort to get function
|
794
|
+
// name. Does not rely on function decomposition to work - if it
|
795
|
+
// doesn't debugging will be slightly less informative
|
796
|
+
// (i.e. toString will say 'spy' rather than 'myFunc').
|
797
|
+
(String(func).match(/function ([^\s(]+)/) || [])[1];
|
798
|
+
} catch (e) {
|
799
|
+
return "";
|
692
800
|
}
|
693
801
|
};
|
694
|
-
|
695
|
-
var every = function every2(obj, fn2) {
|
696
|
-
var pass = true;
|
697
|
-
try {
|
698
|
-
obj.forEach(function() {
|
699
|
-
if (!fn2.apply(this, arguments)) {
|
700
|
-
throw new Error();
|
701
|
-
}
|
702
|
-
});
|
703
|
-
} catch (e) {
|
704
|
-
pass = false;
|
705
|
-
}
|
706
|
-
return pass;
|
707
|
-
};
|
708
|
-
var sort = array.sort;
|
709
|
-
var slice = array.slice;
|
710
|
-
function comparator(a, b) {
|
711
|
-
var aCall = a.getCall(0);
|
712
|
-
var bCall = b.getCall(0);
|
713
|
-
var aId = aCall && aCall.callId || -1;
|
714
|
-
var bId = bCall && bCall.callId || -1;
|
715
|
-
return aId < bId ? -1 : 1;
|
802
|
+
return functionName;
|
716
803
|
}
|
717
|
-
|
718
|
-
|
804
|
+
var orderByFirstCall_1;
|
805
|
+
var hasRequiredOrderByFirstCall;
|
806
|
+
function requireOrderByFirstCall() {
|
807
|
+
if (hasRequiredOrderByFirstCall) return orderByFirstCall_1;
|
808
|
+
hasRequiredOrderByFirstCall = 1;
|
809
|
+
var sort = requireArray().sort;
|
810
|
+
var slice = requireArray().slice;
|
811
|
+
function comparator(a, b) {
|
812
|
+
var aCall = a.getCall(0);
|
813
|
+
var bCall = b.getCall(0);
|
814
|
+
var aId = aCall && aCall.callId || -1;
|
815
|
+
var bId = bCall && bCall.callId || -1;
|
816
|
+
return aId < bId ? -1 : 1;
|
817
|
+
}
|
818
|
+
function orderByFirstCall(spies) {
|
819
|
+
return sort(slice(spies), comparator);
|
820
|
+
}
|
821
|
+
orderByFirstCall_1 = orderByFirstCall;
|
822
|
+
return orderByFirstCall_1;
|
719
823
|
}
|
720
|
-
var
|
721
|
-
var
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
var copyPrototype
|
726
|
-
|
727
|
-
|
728
|
-
var set = copyPrototype$1(Set.prototype);
|
729
|
-
var copyPrototype = copyPrototypeMethods;
|
730
|
-
var string = copyPrototype(String.prototype);
|
731
|
-
var prototypes = {
|
732
|
-
array,
|
733
|
-
function: _function,
|
734
|
-
map,
|
735
|
-
object,
|
736
|
-
set,
|
737
|
-
string
|
738
|
-
};
|
739
|
-
var typeDetect = { exports: {} };
|
740
|
-
(function(module, exports) {
|
741
|
-
(function(global3, factory) {
|
742
|
-
module.exports = factory();
|
743
|
-
})(commonjsGlobal, function() {
|
744
|
-
var promiseExists = typeof Promise === "function";
|
745
|
-
var globalObject2 = typeof self === "object" ? self : commonjsGlobal;
|
746
|
-
var symbolExists = typeof Symbol !== "undefined";
|
747
|
-
var mapExists = typeof Map !== "undefined";
|
748
|
-
var setExists = typeof Set !== "undefined";
|
749
|
-
var weakMapExists = typeof WeakMap !== "undefined";
|
750
|
-
var weakSetExists = typeof WeakSet !== "undefined";
|
751
|
-
var dataViewExists = typeof DataView !== "undefined";
|
752
|
-
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
|
753
|
-
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
|
754
|
-
var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
|
755
|
-
var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
|
756
|
-
var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries());
|
757
|
-
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries());
|
758
|
-
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
|
759
|
-
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
760
|
-
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
|
761
|
-
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
|
762
|
-
var toStringLeftSliceLength = 8;
|
763
|
-
var toStringRightSliceLength = -1;
|
764
|
-
function typeDetect2(obj) {
|
765
|
-
var typeofObj = typeof obj;
|
766
|
-
if (typeofObj !== "object") {
|
767
|
-
return typeofObj;
|
768
|
-
}
|
769
|
-
if (obj === null) {
|
770
|
-
return "null";
|
771
|
-
}
|
772
|
-
if (obj === globalObject2) {
|
773
|
-
return "global";
|
774
|
-
}
|
775
|
-
if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
|
776
|
-
return "Array";
|
777
|
-
}
|
778
|
-
if (typeof window === "object" && window !== null) {
|
779
|
-
if (typeof window.location === "object" && obj === window.location) {
|
780
|
-
return "Location";
|
781
|
-
}
|
782
|
-
if (typeof window.document === "object" && obj === window.document) {
|
783
|
-
return "Document";
|
784
|
-
}
|
785
|
-
if (typeof window.navigator === "object") {
|
786
|
-
if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) {
|
787
|
-
return "MimeTypeArray";
|
788
|
-
}
|
789
|
-
if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) {
|
790
|
-
return "PluginArray";
|
791
|
-
}
|
792
|
-
}
|
793
|
-
if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
|
794
|
-
if (obj.tagName === "BLOCKQUOTE") {
|
795
|
-
return "HTMLQuoteElement";
|
796
|
-
}
|
797
|
-
if (obj.tagName === "TD") {
|
798
|
-
return "HTMLTableDataCellElement";
|
799
|
-
}
|
800
|
-
if (obj.tagName === "TH") {
|
801
|
-
return "HTMLTableHeaderCellElement";
|
802
|
-
}
|
803
|
-
}
|
804
|
-
}
|
805
|
-
var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
|
806
|
-
if (typeof stringTag === "string") {
|
807
|
-
return stringTag;
|
808
|
-
}
|
809
|
-
var objPrototype = Object.getPrototypeOf(obj);
|
810
|
-
if (objPrototype === RegExp.prototype) {
|
811
|
-
return "RegExp";
|
812
|
-
}
|
813
|
-
if (objPrototype === Date.prototype) {
|
814
|
-
return "Date";
|
815
|
-
}
|
816
|
-
if (promiseExists && objPrototype === Promise.prototype) {
|
817
|
-
return "Promise";
|
818
|
-
}
|
819
|
-
if (setExists && objPrototype === Set.prototype) {
|
820
|
-
return "Set";
|
821
|
-
}
|
822
|
-
if (mapExists && objPrototype === Map.prototype) {
|
823
|
-
return "Map";
|
824
|
-
}
|
825
|
-
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
826
|
-
return "WeakSet";
|
827
|
-
}
|
828
|
-
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
829
|
-
return "WeakMap";
|
830
|
-
}
|
831
|
-
if (dataViewExists && objPrototype === DataView.prototype) {
|
832
|
-
return "DataView";
|
833
|
-
}
|
834
|
-
if (mapExists && objPrototype === mapIteratorPrototype) {
|
835
|
-
return "Map Iterator";
|
836
|
-
}
|
837
|
-
if (setExists && objPrototype === setIteratorPrototype) {
|
838
|
-
return "Set Iterator";
|
839
|
-
}
|
840
|
-
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
841
|
-
return "Array Iterator";
|
842
|
-
}
|
843
|
-
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
844
|
-
return "String Iterator";
|
845
|
-
}
|
846
|
-
if (objPrototype === null) {
|
847
|
-
return "Object";
|
848
|
-
}
|
849
|
-
return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
|
850
|
-
}
|
851
|
-
return typeDetect2;
|
852
|
-
});
|
853
|
-
})(typeDetect);
|
854
|
-
var typeDetectExports = typeDetect.exports;
|
855
|
-
var type = typeDetectExports;
|
856
|
-
var typeOf = function typeOf2(value) {
|
857
|
-
return type(value).toLowerCase();
|
858
|
-
};
|
859
|
-
function valueToString(value) {
|
860
|
-
if (value && value.toString) {
|
861
|
-
return value.toString();
|
862
|
-
}
|
863
|
-
return String(value);
|
824
|
+
var _function;
|
825
|
+
var hasRequired_function;
|
826
|
+
function require_function() {
|
827
|
+
if (hasRequired_function) return _function;
|
828
|
+
hasRequired_function = 1;
|
829
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
830
|
+
_function = copyPrototype(Function.prototype);
|
831
|
+
return _function;
|
864
832
|
}
|
865
|
-
var
|
866
|
-
var
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
var
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
833
|
+
var map;
|
834
|
+
var hasRequiredMap;
|
835
|
+
function requireMap() {
|
836
|
+
if (hasRequiredMap) return map;
|
837
|
+
hasRequiredMap = 1;
|
838
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
839
|
+
map = copyPrototype(Map.prototype);
|
840
|
+
return map;
|
841
|
+
}
|
842
|
+
var object;
|
843
|
+
var hasRequiredObject;
|
844
|
+
function requireObject() {
|
845
|
+
if (hasRequiredObject) return object;
|
846
|
+
hasRequiredObject = 1;
|
847
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
848
|
+
object = copyPrototype(Object.prototype);
|
849
|
+
return object;
|
850
|
+
}
|
851
|
+
var set;
|
852
|
+
var hasRequiredSet;
|
853
|
+
function requireSet() {
|
854
|
+
if (hasRequiredSet) return set;
|
855
|
+
hasRequiredSet = 1;
|
856
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
857
|
+
set = copyPrototype(Set.prototype);
|
858
|
+
return set;
|
859
|
+
}
|
860
|
+
var string;
|
861
|
+
var hasRequiredString;
|
862
|
+
function requireString() {
|
863
|
+
if (hasRequiredString) return string;
|
864
|
+
hasRequiredString = 1;
|
865
|
+
var copyPrototype = requireCopyPrototypeMethods();
|
866
|
+
string = copyPrototype(String.prototype);
|
867
|
+
return string;
|
868
|
+
}
|
869
|
+
var prototypes;
|
870
|
+
var hasRequiredPrototypes;
|
871
|
+
function requirePrototypes() {
|
872
|
+
if (hasRequiredPrototypes) return prototypes;
|
873
|
+
hasRequiredPrototypes = 1;
|
874
|
+
prototypes = {
|
875
|
+
array: requireArray(),
|
876
|
+
function: require_function(),
|
877
|
+
map: requireMap(),
|
878
|
+
object: requireObject(),
|
879
|
+
set: requireSet(),
|
880
|
+
string: requireString()
|
881
|
+
};
|
882
|
+
return prototypes;
|
883
|
+
}
|
884
|
+
var typeDetect$1 = { exports: {} };
|
885
|
+
var typeDetect = typeDetect$1.exports;
|
886
|
+
var hasRequiredTypeDetect;
|
887
|
+
function requireTypeDetect() {
|
888
|
+
if (hasRequiredTypeDetect) return typeDetect$1.exports;
|
889
|
+
hasRequiredTypeDetect = 1;
|
890
|
+
(function(module, exports) {
|
891
|
+
(function(global3, factory) {
|
892
|
+
module.exports = factory();
|
893
|
+
})(typeDetect, function() {
|
894
|
+
var promiseExists = typeof Promise === "function";
|
895
|
+
var globalObject = typeof self === "object" ? self : commonjsGlobal;
|
896
|
+
var symbolExists = typeof Symbol !== "undefined";
|
897
|
+
var mapExists = typeof Map !== "undefined";
|
898
|
+
var setExists = typeof Set !== "undefined";
|
899
|
+
var weakMapExists = typeof WeakMap !== "undefined";
|
900
|
+
var weakSetExists = typeof WeakSet !== "undefined";
|
901
|
+
var dataViewExists = typeof DataView !== "undefined";
|
902
|
+
var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
|
903
|
+
var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
|
904
|
+
var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
|
905
|
+
var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
|
906
|
+
var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries());
|
907
|
+
var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries());
|
908
|
+
var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
|
909
|
+
var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
|
910
|
+
var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
|
911
|
+
var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
|
912
|
+
var toStringLeftSliceLength = 8;
|
913
|
+
var toStringRightSliceLength = -1;
|
914
|
+
function typeDetect2(obj) {
|
915
|
+
var typeofObj = typeof obj;
|
916
|
+
if (typeofObj !== "object") {
|
917
|
+
return typeofObj;
|
918
|
+
}
|
919
|
+
if (obj === null) {
|
920
|
+
return "null";
|
921
|
+
}
|
922
|
+
if (obj === globalObject) {
|
923
|
+
return "global";
|
924
|
+
}
|
925
|
+
if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) {
|
926
|
+
return "Array";
|
927
|
+
}
|
928
|
+
if (typeof window === "object" && window !== null) {
|
929
|
+
if (typeof window.location === "object" && obj === window.location) {
|
930
|
+
return "Location";
|
931
|
+
}
|
932
|
+
if (typeof window.document === "object" && obj === window.document) {
|
933
|
+
return "Document";
|
934
|
+
}
|
935
|
+
if (typeof window.navigator === "object") {
|
936
|
+
if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) {
|
937
|
+
return "MimeTypeArray";
|
938
|
+
}
|
939
|
+
if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) {
|
940
|
+
return "PluginArray";
|
941
|
+
}
|
942
|
+
}
|
943
|
+
if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
|
944
|
+
if (obj.tagName === "BLOCKQUOTE") {
|
945
|
+
return "HTMLQuoteElement";
|
946
|
+
}
|
947
|
+
if (obj.tagName === "TD") {
|
948
|
+
return "HTMLTableDataCellElement";
|
949
|
+
}
|
950
|
+
if (obj.tagName === "TH") {
|
951
|
+
return "HTMLTableHeaderCellElement";
|
952
|
+
}
|
953
|
+
}
|
954
|
+
}
|
955
|
+
var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
|
956
|
+
if (typeof stringTag === "string") {
|
957
|
+
return stringTag;
|
958
|
+
}
|
959
|
+
var objPrototype = Object.getPrototypeOf(obj);
|
960
|
+
if (objPrototype === RegExp.prototype) {
|
961
|
+
return "RegExp";
|
962
|
+
}
|
963
|
+
if (objPrototype === Date.prototype) {
|
964
|
+
return "Date";
|
965
|
+
}
|
966
|
+
if (promiseExists && objPrototype === Promise.prototype) {
|
967
|
+
return "Promise";
|
968
|
+
}
|
969
|
+
if (setExists && objPrototype === Set.prototype) {
|
970
|
+
return "Set";
|
971
|
+
}
|
972
|
+
if (mapExists && objPrototype === Map.prototype) {
|
973
|
+
return "Map";
|
974
|
+
}
|
975
|
+
if (weakSetExists && objPrototype === WeakSet.prototype) {
|
976
|
+
return "WeakSet";
|
977
|
+
}
|
978
|
+
if (weakMapExists && objPrototype === WeakMap.prototype) {
|
979
|
+
return "WeakMap";
|
980
|
+
}
|
981
|
+
if (dataViewExists && objPrototype === DataView.prototype) {
|
982
|
+
return "DataView";
|
983
|
+
}
|
984
|
+
if (mapExists && objPrototype === mapIteratorPrototype) {
|
985
|
+
return "Map Iterator";
|
986
|
+
}
|
987
|
+
if (setExists && objPrototype === setIteratorPrototype) {
|
988
|
+
return "Set Iterator";
|
989
|
+
}
|
990
|
+
if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
|
991
|
+
return "Array Iterator";
|
992
|
+
}
|
993
|
+
if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
|
994
|
+
return "String Iterator";
|
995
|
+
}
|
996
|
+
if (objPrototype === null) {
|
997
|
+
return "Object";
|
998
|
+
}
|
999
|
+
return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
|
1000
|
+
}
|
1001
|
+
return typeDetect2;
|
1002
|
+
});
|
1003
|
+
})(typeDetect$1);
|
1004
|
+
return typeDetect$1.exports;
|
885
1005
|
}
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
1006
|
+
var typeOf;
|
1007
|
+
var hasRequiredTypeOf;
|
1008
|
+
function requireTypeOf() {
|
1009
|
+
if (hasRequiredTypeOf) return typeOf;
|
1010
|
+
hasRequiredTypeOf = 1;
|
1011
|
+
var type = requireTypeDetect();
|
1012
|
+
typeOf = function typeOf2(value) {
|
1013
|
+
return type(value).toLowerCase();
|
891
1014
|
};
|
892
|
-
|
893
|
-
|
1015
|
+
return typeOf;
|
1016
|
+
}
|
1017
|
+
var valueToString_1;
|
1018
|
+
var hasRequiredValueToString;
|
1019
|
+
function requireValueToString() {
|
1020
|
+
if (hasRequiredValueToString) return valueToString_1;
|
1021
|
+
hasRequiredValueToString = 1;
|
1022
|
+
function valueToString(value) {
|
1023
|
+
if (value && value.toString) {
|
1024
|
+
return value.toString();
|
1025
|
+
}
|
1026
|
+
return String(value);
|
1027
|
+
}
|
1028
|
+
valueToString_1 = valueToString;
|
1029
|
+
return valueToString_1;
|
1030
|
+
}
|
1031
|
+
var lib;
|
1032
|
+
var hasRequiredLib;
|
1033
|
+
function requireLib() {
|
1034
|
+
if (hasRequiredLib) return lib;
|
1035
|
+
hasRequiredLib = 1;
|
1036
|
+
lib = {
|
1037
|
+
global: requireGlobal(),
|
1038
|
+
calledInOrder: requireCalledInOrder(),
|
1039
|
+
className: requireClassName(),
|
1040
|
+
deprecated: requireDeprecated(),
|
1041
|
+
every: requireEvery(),
|
1042
|
+
functionName: requireFunctionName(),
|
1043
|
+
orderByFirstCall: requireOrderByFirstCall(),
|
1044
|
+
prototypes: requirePrototypes(),
|
1045
|
+
typeOf: requireTypeOf(),
|
1046
|
+
valueToString: requireValueToString()
|
894
1047
|
};
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
const
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
_global.clearTimeout(timeoutResult);
|
912
|
-
const NativeDate = _global.Date;
|
913
|
-
const NativeIntl = _global.Intl;
|
914
|
-
let uniqueTimerId = idCounterStart;
|
915
|
-
function isNumberFinite(num) {
|
916
|
-
if (Number.isFinite) {
|
917
|
-
return Number.isFinite(num);
|
918
|
-
}
|
919
|
-
return isFinite(num);
|
920
|
-
}
|
921
|
-
let isNearInfiniteLimit = false;
|
922
|
-
function checkIsNearInfiniteLimit(clock, i) {
|
923
|
-
if (clock.loopLimit && i === clock.loopLimit - 1) {
|
924
|
-
isNearInfiniteLimit = true;
|
1048
|
+
return lib;
|
1049
|
+
}
|
1050
|
+
var hasRequiredFakeTimersSrc;
|
1051
|
+
function requireFakeTimersSrc() {
|
1052
|
+
if (hasRequiredFakeTimersSrc) return fakeTimersSrc;
|
1053
|
+
hasRequiredFakeTimersSrc = 1;
|
1054
|
+
const globalObject = requireLib().global;
|
1055
|
+
let timersModule, timersPromisesModule;
|
1056
|
+
if (typeof __vitest_required__ !== "undefined") {
|
1057
|
+
try {
|
1058
|
+
timersModule = __vitest_required__.timers;
|
1059
|
+
} catch (e) {
|
1060
|
+
}
|
1061
|
+
try {
|
1062
|
+
timersPromisesModule = __vitest_required__.timersPromises;
|
1063
|
+
} catch (e) {
|
925
1064
|
}
|
926
1065
|
}
|
927
|
-
function
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
let
|
938
|
-
|
939
|
-
|
1066
|
+
function withGlobal(_global) {
|
1067
|
+
const maxTimeout = Math.pow(2, 31) - 1;
|
1068
|
+
const idCounterStart = 1e12;
|
1069
|
+
const NOOP = function() {
|
1070
|
+
return void 0;
|
1071
|
+
};
|
1072
|
+
const NOOP_ARRAY = function() {
|
1073
|
+
return [];
|
1074
|
+
};
|
1075
|
+
const isPresent = {};
|
1076
|
+
let timeoutResult, addTimerReturnsObject = false;
|
1077
|
+
if (_global.setTimeout) {
|
1078
|
+
isPresent.setTimeout = true;
|
1079
|
+
timeoutResult = _global.setTimeout(NOOP, 0);
|
1080
|
+
addTimerReturnsObject = typeof timeoutResult === "object";
|
1081
|
+
}
|
1082
|
+
isPresent.clearTimeout = Boolean(_global.clearTimeout);
|
1083
|
+
isPresent.setInterval = Boolean(_global.setInterval);
|
1084
|
+
isPresent.clearInterval = Boolean(_global.clearInterval);
|
1085
|
+
isPresent.hrtime = _global.process && typeof _global.process.hrtime === "function";
|
1086
|
+
isPresent.hrtimeBigint = isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
|
1087
|
+
isPresent.nextTick = _global.process && typeof _global.process.nextTick === "function";
|
1088
|
+
const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
|
1089
|
+
isPresent.performance = _global.performance && typeof _global.performance.now === "function";
|
1090
|
+
const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
|
1091
|
+
const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
|
1092
|
+
isPresent.queueMicrotask = _global.hasOwnProperty("queueMicrotask");
|
1093
|
+
isPresent.requestAnimationFrame = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
|
1094
|
+
isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
|
1095
|
+
isPresent.requestIdleCallback = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
|
1096
|
+
isPresent.cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
|
1097
|
+
isPresent.setImmediate = _global.setImmediate && typeof _global.setImmediate === "function";
|
1098
|
+
isPresent.clearImmediate = _global.clearImmediate && typeof _global.clearImmediate === "function";
|
1099
|
+
isPresent.Intl = _global.Intl && typeof _global.Intl === "object";
|
1100
|
+
if (_global.clearTimeout) {
|
1101
|
+
_global.clearTimeout(timeoutResult);
|
1102
|
+
}
|
1103
|
+
const NativeDate = _global.Date;
|
1104
|
+
const NativeIntl = isPresent.Intl ? Object.defineProperties(
|
1105
|
+
/* @__PURE__ */ Object.create(null),
|
1106
|
+
Object.getOwnPropertyDescriptors(_global.Intl)
|
1107
|
+
) : void 0;
|
1108
|
+
let uniqueTimerId = idCounterStart;
|
1109
|
+
if (NativeDate === void 0) {
|
940
1110
|
throw new Error(
|
941
|
-
"
|
1111
|
+
"The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)"
|
942
1112
|
);
|
943
1113
|
}
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
1114
|
+
isPresent.Date = true;
|
1115
|
+
class FakePerformanceEntry {
|
1116
|
+
constructor(name, entryType, startTime, duration) {
|
1117
|
+
this.name = name;
|
1118
|
+
this.entryType = entryType;
|
1119
|
+
this.startTime = startTime;
|
1120
|
+
this.duration = duration;
|
1121
|
+
}
|
1122
|
+
toJSON() {
|
1123
|
+
return JSON.stringify({ ...this });
|
948
1124
|
}
|
949
|
-
ms += parsed * Math.pow(60, l - i - 1);
|
950
1125
|
}
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;
|
957
|
-
return Math.floor(positiveRemainder);
|
958
|
-
}
|
959
|
-
function getEpoch(epoch) {
|
960
|
-
if (!epoch) {
|
961
|
-
return 0;
|
1126
|
+
function isNumberFinite(num) {
|
1127
|
+
if (Number.isFinite) {
|
1128
|
+
return Number.isFinite(num);
|
1129
|
+
}
|
1130
|
+
return isFinite(num);
|
962
1131
|
}
|
963
|
-
|
964
|
-
|
1132
|
+
let isNearInfiniteLimit = false;
|
1133
|
+
function checkIsNearInfiniteLimit(clock, i) {
|
1134
|
+
if (clock.loopLimit && i === clock.loopLimit - 1) {
|
1135
|
+
isNearInfiniteLimit = true;
|
1136
|
+
}
|
965
1137
|
}
|
966
|
-
|
967
|
-
|
1138
|
+
function resetIsNearInfiniteLimit() {
|
1139
|
+
isNearInfiniteLimit = false;
|
968
1140
|
}
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
1141
|
+
function parseTime(str) {
|
1142
|
+
if (!str) {
|
1143
|
+
return 0;
|
1144
|
+
}
|
1145
|
+
const strings = str.split(":");
|
1146
|
+
const l = strings.length;
|
1147
|
+
let i = l;
|
1148
|
+
let ms = 0;
|
1149
|
+
let parsed;
|
1150
|
+
if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
|
1151
|
+
throw new Error(
|
1152
|
+
"tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits"
|
1153
|
+
);
|
1154
|
+
}
|
1155
|
+
while (i--) {
|
1156
|
+
parsed = parseInt(strings[i], 10);
|
1157
|
+
if (parsed >= 60) {
|
1158
|
+
throw new Error(`Invalid time ${str}`);
|
1159
|
+
}
|
1160
|
+
ms += parsed * Math.pow(60, l - i - 1);
|
1161
|
+
}
|
1162
|
+
return ms * 1e3;
|
980
1163
|
}
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
clockMethodPattern = new RegExp(
|
987
|
-
`\\s+at (Object\\.)?(?:${Object.keys(clock).join("|")})\\s+`
|
988
|
-
);
|
1164
|
+
function nanoRemainder(msFloat) {
|
1165
|
+
const modulo = 1e6;
|
1166
|
+
const remainder = msFloat * 1e6 % modulo;
|
1167
|
+
const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;
|
1168
|
+
return Math.floor(positiveRemainder);
|
989
1169
|
}
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
if (matchedComputedTarget) {
|
994
|
-
matchedLineIndex = i;
|
995
|
-
return true;
|
1170
|
+
function getEpoch(epoch) {
|
1171
|
+
if (!epoch) {
|
1172
|
+
return 0;
|
996
1173
|
}
|
997
|
-
|
998
|
-
|
999
|
-
matchedLineIndex = i;
|
1000
|
-
return false;
|
1174
|
+
if (typeof epoch.getTime === "function") {
|
1175
|
+
return epoch.getTime();
|
1001
1176
|
}
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1177
|
+
if (typeof epoch === "number") {
|
1178
|
+
return epoch;
|
1179
|
+
}
|
1180
|
+
throw new TypeError("now should be milliseconds since UNIX epoch");
|
1181
|
+
}
|
1182
|
+
function inRange(from, to, timer) {
|
1183
|
+
return timer && timer.callAt >= from && timer.callAt <= to;
|
1184
|
+
}
|
1185
|
+
function getInfiniteLoopError(clock, job) {
|
1186
|
+
const infiniteLoopError = new Error(
|
1187
|
+
`Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`
|
1188
|
+
);
|
1189
|
+
if (!job.error) {
|
1190
|
+
return infiniteLoopError;
|
1191
|
+
}
|
1192
|
+
const computedTargetPattern = /target\.*[<|(|[].*?[>|\]|)]\s*/;
|
1193
|
+
let clockMethodPattern = new RegExp(
|
1194
|
+
String(Object.keys(clock).join("|"))
|
1195
|
+
);
|
1196
|
+
if (addTimerReturnsObject) {
|
1197
|
+
clockMethodPattern = new RegExp(
|
1198
|
+
`\\s+at (Object\\.)?(?:${Object.keys(clock).join("|")})\\s+`
|
1199
|
+
);
|
1200
|
+
}
|
1201
|
+
let matchedLineIndex = -1;
|
1202
|
+
job.error.stack.split("\n").some(function(line, i) {
|
1203
|
+
const matchedComputedTarget = line.match(computedTargetPattern);
|
1204
|
+
if (matchedComputedTarget) {
|
1205
|
+
matchedLineIndex = i;
|
1206
|
+
return true;
|
1207
|
+
}
|
1208
|
+
const matchedClockMethod = line.match(clockMethodPattern);
|
1209
|
+
if (matchedClockMethod) {
|
1210
|
+
matchedLineIndex = i;
|
1211
|
+
return false;
|
1212
|
+
}
|
1213
|
+
return matchedLineIndex >= 0;
|
1214
|
+
});
|
1215
|
+
const stack = `${infiniteLoopError}
|
1005
1216
|
${job.type || "Microtask"} - ${job.func.name || "anonymous"}
|
1006
1217
|
${job.error.stack.split("\n").slice(matchedLineIndex + 1).join("\n")}`;
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
}
|
1013
|
-
return infiniteLoopError;
|
1014
|
-
}
|
1015
|
-
function mirrorDateProperties(target, source) {
|
1016
|
-
let prop;
|
1017
|
-
for (prop in source) {
|
1018
|
-
if (source.hasOwnProperty(prop)) {
|
1019
|
-
target[prop] = source[prop];
|
1218
|
+
try {
|
1219
|
+
Object.defineProperty(infiniteLoopError, "stack", {
|
1220
|
+
value: stack
|
1221
|
+
});
|
1222
|
+
} catch (e) {
|
1020
1223
|
}
|
1224
|
+
return infiniteLoopError;
|
1021
1225
|
}
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1226
|
+
function createDate() {
|
1227
|
+
class ClockDate extends NativeDate {
|
1228
|
+
/**
|
1229
|
+
* @param {number} year
|
1230
|
+
* @param {number} month
|
1231
|
+
* @param {number} date
|
1232
|
+
* @param {number} hour
|
1233
|
+
* @param {number} minute
|
1234
|
+
* @param {number} second
|
1235
|
+
* @param {number} ms
|
1236
|
+
* @returns void
|
1237
|
+
*/
|
1238
|
+
// eslint-disable-next-line no-unused-vars
|
1239
|
+
constructor(year, month, date, hour, minute, second, ms) {
|
1240
|
+
if (arguments.length === 0) {
|
1241
|
+
super(ClockDate.clock.now);
|
1242
|
+
} else {
|
1243
|
+
super(...arguments);
|
1244
|
+
}
|
1245
|
+
Object.defineProperty(this, "constructor", {
|
1246
|
+
value: NativeDate,
|
1247
|
+
enumerable: false
|
1248
|
+
});
|
1249
|
+
}
|
1250
|
+
static [Symbol.hasInstance](instance) {
|
1251
|
+
return instance instanceof NativeDate;
|
1252
|
+
}
|
1253
|
+
}
|
1254
|
+
ClockDate.isFake = true;
|
1255
|
+
if (NativeDate.now) {
|
1256
|
+
ClockDate.now = function now2() {
|
1257
|
+
return ClockDate.clock.now;
|
1258
|
+
};
|
1259
|
+
}
|
1260
|
+
if (NativeDate.toSource) {
|
1261
|
+
ClockDate.toSource = function toSource() {
|
1262
|
+
return NativeDate.toSource();
|
1263
|
+
};
|
1264
|
+
}
|
1265
|
+
ClockDate.toString = function toString() {
|
1266
|
+
return NativeDate.toString();
|
1025
1267
|
};
|
1026
|
-
|
1027
|
-
|
1268
|
+
const ClockDateProxy = new Proxy(ClockDate, {
|
1269
|
+
// handler for [[Call]] invocations (i.e. not using `new`)
|
1270
|
+
apply() {
|
1271
|
+
if (this instanceof ClockDate) {
|
1272
|
+
throw new TypeError(
|
1273
|
+
"A Proxy should only capture `new` calls with the `construct` handler. This is not supposed to be possible, so check the logic."
|
1274
|
+
);
|
1275
|
+
}
|
1276
|
+
return new NativeDate(ClockDate.clock.now).toString();
|
1277
|
+
}
|
1278
|
+
});
|
1279
|
+
return ClockDateProxy;
|
1028
1280
|
}
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1281
|
+
function createIntl() {
|
1282
|
+
const ClockIntl = {};
|
1283
|
+
Object.getOwnPropertyNames(NativeIntl).forEach(
|
1284
|
+
(property) => ClockIntl[property] = NativeIntl[property]
|
1285
|
+
);
|
1286
|
+
ClockIntl.DateTimeFormat = function(...args) {
|
1287
|
+
const realFormatter = new NativeIntl.DateTimeFormat(...args);
|
1288
|
+
const formatter = {};
|
1289
|
+
["formatRange", "formatRangeToParts", "resolvedOptions"].forEach(
|
1290
|
+
(method) => {
|
1291
|
+
formatter[method] = realFormatter[method].bind(realFormatter);
|
1292
|
+
}
|
1293
|
+
);
|
1294
|
+
["format", "formatToParts"].forEach((method) => {
|
1295
|
+
formatter[method] = function(date) {
|
1296
|
+
return realFormatter[method](date || ClockIntl.clock.now);
|
1297
|
+
};
|
1298
|
+
});
|
1299
|
+
return formatter;
|
1032
1300
|
};
|
1033
|
-
|
1034
|
-
|
1301
|
+
ClockIntl.DateTimeFormat.prototype = Object.create(
|
1302
|
+
NativeIntl.DateTimeFormat.prototype
|
1303
|
+
);
|
1304
|
+
ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;
|
1305
|
+
return ClockIntl;
|
1035
1306
|
}
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
target.prototype = source.prototype;
|
1040
|
-
target.parse = source.parse;
|
1041
|
-
target.UTC = source.UTC;
|
1042
|
-
target.prototype.toUTCString = source.prototype.toUTCString;
|
1043
|
-
target.isFake = true;
|
1044
|
-
return target;
|
1045
|
-
}
|
1046
|
-
function createDate() {
|
1047
|
-
function ClockDate(year, month, date, hour, minute, second, ms) {
|
1048
|
-
if (!(this instanceof ClockDate)) {
|
1049
|
-
return new NativeDate(ClockDate.clock.now).toString();
|
1050
|
-
}
|
1051
|
-
switch (arguments.length) {
|
1052
|
-
case 0:
|
1053
|
-
return new NativeDate(ClockDate.clock.now);
|
1054
|
-
case 1:
|
1055
|
-
return new NativeDate(year);
|
1056
|
-
case 2:
|
1057
|
-
return new NativeDate(year, month);
|
1058
|
-
case 3:
|
1059
|
-
return new NativeDate(year, month, date);
|
1060
|
-
case 4:
|
1061
|
-
return new NativeDate(year, month, date, hour);
|
1062
|
-
case 5:
|
1063
|
-
return new NativeDate(year, month, date, hour, minute);
|
1064
|
-
case 6:
|
1065
|
-
return new NativeDate(
|
1066
|
-
year,
|
1067
|
-
month,
|
1068
|
-
date,
|
1069
|
-
hour,
|
1070
|
-
minute,
|
1071
|
-
second
|
1072
|
-
);
|
1073
|
-
default:
|
1074
|
-
return new NativeDate(
|
1075
|
-
year,
|
1076
|
-
month,
|
1077
|
-
date,
|
1078
|
-
hour,
|
1079
|
-
minute,
|
1080
|
-
second,
|
1081
|
-
ms
|
1082
|
-
);
|
1307
|
+
function enqueueJob(clock, job) {
|
1308
|
+
if (!clock.jobs) {
|
1309
|
+
clock.jobs = [];
|
1083
1310
|
}
|
1311
|
+
clock.jobs.push(job);
|
1084
1312
|
}
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
(
|
1094
|
-
|
1313
|
+
function runJobs(clock) {
|
1314
|
+
if (!clock.jobs) {
|
1315
|
+
return;
|
1316
|
+
}
|
1317
|
+
for (let i = 0; i < clock.jobs.length; i++) {
|
1318
|
+
const job = clock.jobs[i];
|
1319
|
+
job.func.apply(null, job.args);
|
1320
|
+
checkIsNearInfiniteLimit(clock, i);
|
1321
|
+
if (clock.loopLimit && i > clock.loopLimit) {
|
1322
|
+
throw getInfiniteLoopError(clock, job);
|
1095
1323
|
}
|
1096
|
-
|
1097
|
-
|
1098
|
-
formatter[method] = function(date) {
|
1099
|
-
return realFormatter[method](date || ClockIntl.clock.now);
|
1100
|
-
};
|
1101
|
-
});
|
1102
|
-
return formatter;
|
1103
|
-
};
|
1104
|
-
ClockIntl.DateTimeFormat.prototype = Object.create(
|
1105
|
-
NativeIntl.DateTimeFormat.prototype
|
1106
|
-
);
|
1107
|
-
ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;
|
1108
|
-
return ClockIntl;
|
1109
|
-
}
|
1110
|
-
function enqueueJob(clock, job) {
|
1111
|
-
if (!clock.jobs) {
|
1324
|
+
}
|
1325
|
+
resetIsNearInfiniteLimit();
|
1112
1326
|
clock.jobs = [];
|
1113
1327
|
}
|
1114
|
-
clock
|
1115
|
-
|
1116
|
-
|
1117
|
-
if (!clock.jobs) {
|
1118
|
-
return;
|
1119
|
-
}
|
1120
|
-
for (let i = 0; i < clock.jobs.length; i++) {
|
1121
|
-
const job = clock.jobs[i];
|
1122
|
-
job.func.apply(null, job.args);
|
1123
|
-
checkIsNearInfiniteLimit(clock, i);
|
1124
|
-
if (clock.loopLimit && i > clock.loopLimit) {
|
1125
|
-
throw getInfiniteLoopError(clock, job);
|
1328
|
+
function addTimer(clock, timer) {
|
1329
|
+
if (timer.func === void 0) {
|
1330
|
+
throw new Error("Callback must be provided to timer calls");
|
1126
1331
|
}
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
throw new Error("Callback must be provided to timer calls");
|
1134
|
-
}
|
1135
|
-
if (addTimerReturnsObject) {
|
1136
|
-
if (typeof timer.func !== "function") {
|
1137
|
-
throw new TypeError(
|
1138
|
-
`[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`
|
1139
|
-
);
|
1332
|
+
if (addTimerReturnsObject) {
|
1333
|
+
if (typeof timer.func !== "function") {
|
1334
|
+
throw new TypeError(
|
1335
|
+
`[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`
|
1336
|
+
);
|
1337
|
+
}
|
1140
1338
|
}
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
timer.delay = parseInt(timer.delay, 10);
|
1149
|
-
}
|
1150
|
-
if (!isNumberFinite(timer.delay)) {
|
1151
|
-
timer.delay = 0;
|
1152
|
-
}
|
1153
|
-
timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
|
1154
|
-
timer.delay = Math.max(0, timer.delay);
|
1155
|
-
}
|
1156
|
-
if (timer.hasOwnProperty("interval")) {
|
1157
|
-
timer.type = "Interval";
|
1158
|
-
timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
|
1159
|
-
}
|
1160
|
-
if (timer.hasOwnProperty("animation")) {
|
1161
|
-
timer.type = "AnimationFrame";
|
1162
|
-
timer.animation = true;
|
1163
|
-
}
|
1164
|
-
if (timer.hasOwnProperty("idleCallback")) {
|
1165
|
-
timer.type = "IdleCallback";
|
1166
|
-
timer.idleCallback = true;
|
1167
|
-
}
|
1168
|
-
if (!clock.timers) {
|
1169
|
-
clock.timers = {};
|
1170
|
-
}
|
1171
|
-
timer.id = uniqueTimerId++;
|
1172
|
-
timer.createdAt = clock.now;
|
1173
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
1174
|
-
clock.timers[timer.id] = timer;
|
1175
|
-
if (addTimerReturnsObject) {
|
1176
|
-
const res = {
|
1177
|
-
refed: true,
|
1178
|
-
ref: function() {
|
1179
|
-
this.refed = true;
|
1180
|
-
return res;
|
1181
|
-
},
|
1182
|
-
unref: function() {
|
1183
|
-
this.refed = false;
|
1184
|
-
return res;
|
1185
|
-
},
|
1186
|
-
hasRef: function() {
|
1187
|
-
return this.refed;
|
1188
|
-
},
|
1189
|
-
refresh: function() {
|
1190
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
1191
|
-
clock.timers[timer.id] = timer;
|
1192
|
-
return res;
|
1193
|
-
},
|
1194
|
-
[Symbol.toPrimitive]: function() {
|
1195
|
-
return timer.id;
|
1339
|
+
if (isNearInfiniteLimit) {
|
1340
|
+
timer.error = new Error();
|
1341
|
+
}
|
1342
|
+
timer.type = timer.immediate ? "Immediate" : "Timeout";
|
1343
|
+
if (timer.hasOwnProperty("delay")) {
|
1344
|
+
if (typeof timer.delay !== "number") {
|
1345
|
+
timer.delay = parseInt(timer.delay, 10);
|
1196
1346
|
}
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1347
|
+
if (!isNumberFinite(timer.delay)) {
|
1348
|
+
timer.delay = 0;
|
1349
|
+
}
|
1350
|
+
timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
|
1351
|
+
timer.delay = Math.max(0, timer.delay);
|
1352
|
+
}
|
1353
|
+
if (timer.hasOwnProperty("interval")) {
|
1354
|
+
timer.type = "Interval";
|
1355
|
+
timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
|
1356
|
+
}
|
1357
|
+
if (timer.hasOwnProperty("animation")) {
|
1358
|
+
timer.type = "AnimationFrame";
|
1359
|
+
timer.animation = true;
|
1360
|
+
}
|
1361
|
+
if (timer.hasOwnProperty("idleCallback")) {
|
1362
|
+
timer.type = "IdleCallback";
|
1363
|
+
timer.idleCallback = true;
|
1364
|
+
}
|
1365
|
+
if (!clock.timers) {
|
1366
|
+
clock.timers = {};
|
1367
|
+
}
|
1368
|
+
timer.id = uniqueTimerId++;
|
1369
|
+
timer.createdAt = clock.now;
|
1370
|
+
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
1371
|
+
clock.timers[timer.id] = timer;
|
1372
|
+
if (addTimerReturnsObject) {
|
1373
|
+
const res = {
|
1374
|
+
refed: true,
|
1375
|
+
ref: function() {
|
1376
|
+
this.refed = true;
|
1377
|
+
return res;
|
1378
|
+
},
|
1379
|
+
unref: function() {
|
1380
|
+
this.refed = false;
|
1381
|
+
return res;
|
1382
|
+
},
|
1383
|
+
hasRef: function() {
|
1384
|
+
return this.refed;
|
1385
|
+
},
|
1386
|
+
refresh: function() {
|
1387
|
+
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
1388
|
+
clock.timers[timer.id] = timer;
|
1389
|
+
return res;
|
1390
|
+
},
|
1391
|
+
[Symbol.toPrimitive]: function() {
|
1392
|
+
return timer.id;
|
1393
|
+
}
|
1394
|
+
};
|
1395
|
+
return res;
|
1396
|
+
}
|
1397
|
+
return timer.id;
|
1223
1398
|
}
|
1224
|
-
|
1225
|
-
|
1399
|
+
function compareTimers(a, b) {
|
1400
|
+
if (a.callAt < b.callAt) {
|
1401
|
+
return -1;
|
1402
|
+
}
|
1403
|
+
if (a.callAt > b.callAt) {
|
1404
|
+
return 1;
|
1405
|
+
}
|
1406
|
+
if (a.immediate && !b.immediate) {
|
1407
|
+
return -1;
|
1408
|
+
}
|
1409
|
+
if (!a.immediate && b.immediate) {
|
1410
|
+
return 1;
|
1411
|
+
}
|
1412
|
+
if (a.createdAt < b.createdAt) {
|
1413
|
+
return -1;
|
1414
|
+
}
|
1415
|
+
if (a.createdAt > b.createdAt) {
|
1416
|
+
return 1;
|
1417
|
+
}
|
1418
|
+
if (a.id < b.id) {
|
1419
|
+
return -1;
|
1420
|
+
}
|
1421
|
+
if (a.id > b.id) {
|
1422
|
+
return 1;
|
1423
|
+
}
|
1226
1424
|
}
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1425
|
+
function firstTimerInRange(clock, from, to) {
|
1426
|
+
const timers2 = clock.timers;
|
1427
|
+
let timer = null;
|
1428
|
+
let id, isInRange;
|
1429
|
+
for (id in timers2) {
|
1430
|
+
if (timers2.hasOwnProperty(id)) {
|
1431
|
+
isInRange = inRange(from, to, timers2[id]);
|
1432
|
+
if (isInRange && (!timer || compareTimers(timer, timers2[id]) === 1)) {
|
1433
|
+
timer = timers2[id];
|
1434
|
+
}
|
1237
1435
|
}
|
1238
1436
|
}
|
1437
|
+
return timer;
|
1239
1438
|
}
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
timer = timers2[id];
|
1439
|
+
function firstTimer(clock) {
|
1440
|
+
const timers2 = clock.timers;
|
1441
|
+
let timer = null;
|
1442
|
+
let id;
|
1443
|
+
for (id in timers2) {
|
1444
|
+
if (timers2.hasOwnProperty(id)) {
|
1445
|
+
if (!timer || compareTimers(timer, timers2[id]) === 1) {
|
1446
|
+
timer = timers2[id];
|
1447
|
+
}
|
1250
1448
|
}
|
1251
1449
|
}
|
1450
|
+
return timer;
|
1252
1451
|
}
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
timer = timers2[id];
|
1452
|
+
function lastTimer(clock) {
|
1453
|
+
const timers2 = clock.timers;
|
1454
|
+
let timer = null;
|
1455
|
+
let id;
|
1456
|
+
for (id in timers2) {
|
1457
|
+
if (timers2.hasOwnProperty(id)) {
|
1458
|
+
if (!timer || compareTimers(timer, timers2[id]) === -1) {
|
1459
|
+
timer = timers2[id];
|
1460
|
+
}
|
1263
1461
|
}
|
1264
1462
|
}
|
1463
|
+
return timer;
|
1265
1464
|
}
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
})();
|
1281
|
-
}
|
1282
|
-
}
|
1283
|
-
function getClearHandler(ttype) {
|
1284
|
-
if (ttype === "IdleCallback" || ttype === "AnimationFrame") {
|
1285
|
-
return `cancel${ttype}`;
|
1465
|
+
function callTimer(clock, timer) {
|
1466
|
+
if (typeof timer.interval === "number") {
|
1467
|
+
clock.timers[timer.id].callAt += timer.interval;
|
1468
|
+
} else {
|
1469
|
+
delete clock.timers[timer.id];
|
1470
|
+
}
|
1471
|
+
if (typeof timer.func === "function") {
|
1472
|
+
timer.func.apply(null, timer.args);
|
1473
|
+
} else {
|
1474
|
+
const eval2 = eval;
|
1475
|
+
(function() {
|
1476
|
+
eval2(timer.func);
|
1477
|
+
})();
|
1478
|
+
}
|
1286
1479
|
}
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
return `
|
1480
|
+
function getClearHandler(ttype) {
|
1481
|
+
if (ttype === "IdleCallback" || ttype === "AnimationFrame") {
|
1482
|
+
return `cancel${ttype}`;
|
1483
|
+
}
|
1484
|
+
return `clear${ttype}`;
|
1292
1485
|
}
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
!calls++ && console.warn(msg);
|
1299
|
-
};
|
1300
|
-
}
|
1301
|
-
const warnOnce = createWarnOnce();
|
1302
|
-
function clearTimer(clock, timerId, ttype) {
|
1303
|
-
if (!timerId) {
|
1304
|
-
return;
|
1486
|
+
function getScheduleHandler(ttype) {
|
1487
|
+
if (ttype === "IdleCallback" || ttype === "AnimationFrame") {
|
1488
|
+
return `request${ttype}`;
|
1489
|
+
}
|
1490
|
+
return `set${ttype}`;
|
1305
1491
|
}
|
1306
|
-
|
1307
|
-
|
1492
|
+
function createWarnOnce() {
|
1493
|
+
let calls = 0;
|
1494
|
+
return function(msg) {
|
1495
|
+
!calls++ && console.warn(msg);
|
1496
|
+
};
|
1308
1497
|
}
|
1309
|
-
const
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1498
|
+
const warnOnce = createWarnOnce();
|
1499
|
+
function clearTimer(clock, timerId, ttype) {
|
1500
|
+
if (!timerId) {
|
1501
|
+
return;
|
1502
|
+
}
|
1503
|
+
if (!clock.timers) {
|
1504
|
+
clock.timers = {};
|
1315
1505
|
}
|
1316
|
-
|
1317
|
-
|
1506
|
+
const id = Number(timerId);
|
1507
|
+
if (Number.isNaN(id) || id < idCounterStart) {
|
1508
|
+
const handlerName = getClearHandler(ttype);
|
1509
|
+
if (clock.shouldClearNativeTimers === true) {
|
1510
|
+
const nativeHandler = clock[`_${handlerName}`];
|
1511
|
+
return typeof nativeHandler === "function" ? nativeHandler(timerId) : void 0;
|
1512
|
+
}
|
1513
|
+
warnOnce(
|
1514
|
+
`FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.
|
1318
1515
|
To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
|
1319
|
-
);
|
1320
|
-
}
|
1321
|
-
if (clock.timers.hasOwnProperty(id)) {
|
1322
|
-
const timer = clock.timers[id];
|
1323
|
-
if (timer.type === ttype || timer.type === "Timeout" && ttype === "Interval" || timer.type === "Interval" && ttype === "Timeout") {
|
1324
|
-
delete clock.timers[id];
|
1325
|
-
} else {
|
1326
|
-
const clear = getClearHandler(ttype);
|
1327
|
-
const schedule = getScheduleHandler(timer.type);
|
1328
|
-
throw new Error(
|
1329
|
-
`Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`
|
1330
1516
|
);
|
1331
1517
|
}
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
_global.process.hrtime = clock[installedHrTime];
|
1342
|
-
} else if (method === "nextTick" && _global.process) {
|
1343
|
-
_global.process.nextTick = clock[installedNextTick];
|
1344
|
-
} else if (method === "performance") {
|
1345
|
-
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(
|
1346
|
-
clock,
|
1347
|
-
`_${method}`
|
1348
|
-
);
|
1349
|
-
if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
|
1350
|
-
Object.defineProperty(
|
1351
|
-
_global,
|
1352
|
-
method,
|
1353
|
-
originalPerfDescriptor
|
1518
|
+
if (clock.timers.hasOwnProperty(id)) {
|
1519
|
+
const timer = clock.timers[id];
|
1520
|
+
if (timer.type === ttype || timer.type === "Timeout" && ttype === "Interval" || timer.type === "Interval" && ttype === "Timeout") {
|
1521
|
+
delete clock.timers[id];
|
1522
|
+
} else {
|
1523
|
+
const clear = getClearHandler(ttype);
|
1524
|
+
const schedule = getScheduleHandler(timer.type);
|
1525
|
+
throw new Error(
|
1526
|
+
`Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`
|
1354
1527
|
);
|
1355
|
-
} else if (originalPerfDescriptor.configurable) {
|
1356
|
-
_global[method] = clock[`_${method}`];
|
1357
1528
|
}
|
1358
|
-
}
|
1359
|
-
|
1360
|
-
|
1529
|
+
}
|
1530
|
+
}
|
1531
|
+
function uninstall(clock, config) {
|
1532
|
+
let method, i, l;
|
1533
|
+
const installedHrTime = "_hrtime";
|
1534
|
+
const installedNextTick = "_nextTick";
|
1535
|
+
for (i = 0, l = clock.methods.length; i < l; i++) {
|
1536
|
+
method = clock.methods[i];
|
1537
|
+
if (method === "hrtime" && _global.process) {
|
1538
|
+
_global.process.hrtime = clock[installedHrTime];
|
1539
|
+
} else if (method === "nextTick" && _global.process) {
|
1540
|
+
_global.process.nextTick = clock[installedNextTick];
|
1541
|
+
} else if (method === "performance") {
|
1542
|
+
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(
|
1543
|
+
clock,
|
1544
|
+
`_${method}`
|
1545
|
+
);
|
1546
|
+
if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
|
1547
|
+
Object.defineProperty(
|
1548
|
+
_global,
|
1549
|
+
method,
|
1550
|
+
originalPerfDescriptor
|
1551
|
+
);
|
1552
|
+
} else if (originalPerfDescriptor.configurable) {
|
1553
|
+
_global[method] = clock[`_${method}`];
|
1554
|
+
}
|
1361
1555
|
} else {
|
1362
|
-
|
1363
|
-
|
1364
|
-
}
|
1556
|
+
if (_global[method] && _global[method].hadOwnProperty) {
|
1557
|
+
_global[method] = clock[`_${method}`];
|
1558
|
+
} else {
|
1559
|
+
try {
|
1560
|
+
delete _global[method];
|
1561
|
+
} catch (ignore) {
|
1562
|
+
}
|
1365
1563
|
}
|
1366
1564
|
}
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1565
|
+
if (clock.timersModuleMethods !== void 0) {
|
1566
|
+
for (let j = 0; j < clock.timersModuleMethods.length; j++) {
|
1567
|
+
const entry = clock.timersModuleMethods[j];
|
1568
|
+
timersModule[entry.methodName] = entry.original;
|
1569
|
+
}
|
1570
|
+
}
|
1571
|
+
if (clock.timersPromisesModuleMethods !== void 0) {
|
1572
|
+
for (let j = 0; j < clock.timersPromisesModuleMethods.length; j++) {
|
1573
|
+
const entry = clock.timersPromisesModuleMethods[j];
|
1574
|
+
timersPromisesModule[entry.methodName] = entry.original;
|
1575
|
+
}
|
1372
1576
|
}
|
1373
1577
|
}
|
1578
|
+
if (config.shouldAdvanceTime === true) {
|
1579
|
+
_global.clearInterval(clock.attachedInterval);
|
1580
|
+
}
|
1581
|
+
clock.methods = [];
|
1582
|
+
for (const [listener, signal] of clock.abortListenerMap.entries()) {
|
1583
|
+
signal.removeEventListener("abort", listener);
|
1584
|
+
clock.abortListenerMap.delete(listener);
|
1585
|
+
}
|
1586
|
+
if (!clock.timers) {
|
1587
|
+
return [];
|
1588
|
+
}
|
1589
|
+
return Object.keys(clock.timers).map(function mapper(key) {
|
1590
|
+
return clock.timers[key];
|
1591
|
+
});
|
1374
1592
|
}
|
1375
|
-
|
1376
|
-
|
1377
|
-
}
|
1378
|
-
clock.methods = [];
|
1379
|
-
if (!clock.timers) {
|
1380
|
-
return [];
|
1381
|
-
}
|
1382
|
-
return Object.keys(clock.timers).map(function mapper(key) {
|
1383
|
-
return clock.timers[key];
|
1384
|
-
});
|
1385
|
-
}
|
1386
|
-
function hijackMethod(target, method, clock) {
|
1387
|
-
clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(
|
1388
|
-
target,
|
1389
|
-
method
|
1390
|
-
);
|
1391
|
-
clock[`_${method}`] = target[method];
|
1392
|
-
if (method === "Date") {
|
1393
|
-
const date = mirrorDateProperties(clock[method], target[method]);
|
1394
|
-
target[method] = date;
|
1395
|
-
} else if (method === "Intl") {
|
1396
|
-
target[method] = clock[method];
|
1397
|
-
} else if (method === "performance") {
|
1398
|
-
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(
|
1593
|
+
function hijackMethod(target, method, clock) {
|
1594
|
+
clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(
|
1399
1595
|
target,
|
1400
1596
|
method
|
1401
1597
|
);
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
const
|
1409
|
-
|
1598
|
+
clock[`_${method}`] = target[method];
|
1599
|
+
if (method === "Date") {
|
1600
|
+
target[method] = clock[method];
|
1601
|
+
} else if (method === "Intl") {
|
1602
|
+
target[method] = clock[method];
|
1603
|
+
} else if (method === "performance") {
|
1604
|
+
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(
|
1605
|
+
target,
|
1410
1606
|
method
|
1411
1607
|
);
|
1412
|
-
|
1608
|
+
if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
|
1609
|
+
Object.defineProperty(
|
1610
|
+
clock,
|
1611
|
+
`_${method}`,
|
1612
|
+
originalPerfDescriptor
|
1613
|
+
);
|
1614
|
+
const perfDescriptor = Object.getOwnPropertyDescriptor(
|
1615
|
+
clock,
|
1616
|
+
method
|
1617
|
+
);
|
1618
|
+
Object.defineProperty(target, method, perfDescriptor);
|
1619
|
+
} else {
|
1620
|
+
target[method] = clock[method];
|
1621
|
+
}
|
1413
1622
|
} else {
|
1414
|
-
target[method] =
|
1623
|
+
target[method] = function() {
|
1624
|
+
return clock[method].apply(clock, arguments);
|
1625
|
+
};
|
1626
|
+
Object.defineProperties(
|
1627
|
+
target[method],
|
1628
|
+
Object.getOwnPropertyDescriptors(clock[method])
|
1629
|
+
);
|
1415
1630
|
}
|
1416
|
-
|
1417
|
-
target[method] = function() {
|
1418
|
-
return clock[method].apply(clock, arguments);
|
1419
|
-
};
|
1420
|
-
Object.defineProperties(
|
1421
|
-
target[method],
|
1422
|
-
Object.getOwnPropertyDescriptors(clock[method])
|
1423
|
-
);
|
1631
|
+
target[method].clock = clock;
|
1424
1632
|
}
|
1425
|
-
|
1426
|
-
|
1427
|
-
function doIntervalTick(clock, advanceTimeDelta) {
|
1428
|
-
clock.tick(advanceTimeDelta);
|
1429
|
-
}
|
1430
|
-
const timers = {
|
1431
|
-
setTimeout: _global.setTimeout,
|
1432
|
-
clearTimeout: _global.clearTimeout,
|
1433
|
-
setInterval: _global.setInterval,
|
1434
|
-
clearInterval: _global.clearInterval,
|
1435
|
-
Date: _global.Date
|
1436
|
-
};
|
1437
|
-
if (setImmediatePresent) {
|
1438
|
-
timers.setImmediate = _global.setImmediate;
|
1439
|
-
timers.clearImmediate = _global.clearImmediate;
|
1440
|
-
}
|
1441
|
-
if (hrtimePresent) {
|
1442
|
-
timers.hrtime = _global.process.hrtime;
|
1443
|
-
}
|
1444
|
-
if (nextTickPresent) {
|
1445
|
-
timers.nextTick = _global.process.nextTick;
|
1446
|
-
}
|
1447
|
-
if (performancePresent) {
|
1448
|
-
timers.performance = _global.performance;
|
1449
|
-
}
|
1450
|
-
if (requestAnimationFramePresent) {
|
1451
|
-
timers.requestAnimationFrame = _global.requestAnimationFrame;
|
1452
|
-
}
|
1453
|
-
if (queueMicrotaskPresent) {
|
1454
|
-
timers.queueMicrotask = true;
|
1455
|
-
}
|
1456
|
-
if (cancelAnimationFramePresent) {
|
1457
|
-
timers.cancelAnimationFrame = _global.cancelAnimationFrame;
|
1458
|
-
}
|
1459
|
-
if (requestIdleCallbackPresent) {
|
1460
|
-
timers.requestIdleCallback = _global.requestIdleCallback;
|
1461
|
-
}
|
1462
|
-
if (cancelIdleCallbackPresent) {
|
1463
|
-
timers.cancelIdleCallback = _global.cancelIdleCallback;
|
1464
|
-
}
|
1465
|
-
if (intlPresent) {
|
1466
|
-
timers.Intl = _global.Intl;
|
1467
|
-
}
|
1468
|
-
const originalSetTimeout = _global.setImmediate || _global.setTimeout;
|
1469
|
-
function createClock(start, loopLimit) {
|
1470
|
-
start = Math.floor(getEpoch(start));
|
1471
|
-
loopLimit = loopLimit || 1e3;
|
1472
|
-
let nanos = 0;
|
1473
|
-
const adjustedSystemTime = [0, 0];
|
1474
|
-
if (NativeDate === void 0) {
|
1475
|
-
throw new Error(
|
1476
|
-
"The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)"
|
1477
|
-
);
|
1633
|
+
function doIntervalTick(clock, advanceTimeDelta) {
|
1634
|
+
clock.tick(advanceTimeDelta);
|
1478
1635
|
}
|
1479
|
-
const
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1636
|
+
const timers = {
|
1637
|
+
setTimeout: _global.setTimeout,
|
1638
|
+
clearTimeout: _global.clearTimeout,
|
1639
|
+
setInterval: _global.setInterval,
|
1640
|
+
clearInterval: _global.clearInterval,
|
1641
|
+
Date: _global.Date
|
1483
1642
|
};
|
1484
|
-
|
1485
|
-
|
1486
|
-
return 16 - (clock.now - start) % 16;
|
1487
|
-
}
|
1488
|
-
function hrtime(prev) {
|
1489
|
-
const millisSinceStart = clock.now - adjustedSystemTime[0] - start;
|
1490
|
-
const secsSinceStart = Math.floor(millisSinceStart / 1e3);
|
1491
|
-
const remainderInNanos = (millisSinceStart - secsSinceStart * 1e3) * 1e6 + nanos - adjustedSystemTime[1];
|
1492
|
-
if (Array.isArray(prev)) {
|
1493
|
-
if (prev[1] > 1e9) {
|
1494
|
-
throw new TypeError(
|
1495
|
-
"Number of nanoseconds can't exceed a billion"
|
1496
|
-
);
|
1497
|
-
}
|
1498
|
-
const oldSecs = prev[0];
|
1499
|
-
let nanoDiff = remainderInNanos - prev[1];
|
1500
|
-
let secDiff = secsSinceStart - oldSecs;
|
1501
|
-
if (nanoDiff < 0) {
|
1502
|
-
nanoDiff += 1e9;
|
1503
|
-
secDiff -= 1;
|
1504
|
-
}
|
1505
|
-
return [secDiff, nanoDiff];
|
1506
|
-
}
|
1507
|
-
return [secsSinceStart, remainderInNanos];
|
1643
|
+
if (isPresent.setImmediate) {
|
1644
|
+
timers.setImmediate = _global.setImmediate;
|
1508
1645
|
}
|
1509
|
-
|
1510
|
-
|
1511
|
-
const millis = hrt[0] * 1e3 + hrt[1] / 1e6;
|
1512
|
-
return millis;
|
1646
|
+
if (isPresent.clearImmediate) {
|
1647
|
+
timers.clearImmediate = _global.clearImmediate;
|
1513
1648
|
}
|
1514
|
-
if (
|
1515
|
-
hrtime
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1649
|
+
if (isPresent.hrtime) {
|
1650
|
+
timers.hrtime = _global.process.hrtime;
|
1651
|
+
}
|
1652
|
+
if (isPresent.nextTick) {
|
1653
|
+
timers.nextTick = _global.process.nextTick;
|
1654
|
+
}
|
1655
|
+
if (isPresent.performance) {
|
1656
|
+
timers.performance = _global.performance;
|
1519
1657
|
}
|
1520
|
-
if (
|
1521
|
-
|
1522
|
-
clock.Intl.clock = clock;
|
1658
|
+
if (isPresent.requestAnimationFrame) {
|
1659
|
+
timers.requestAnimationFrame = _global.requestAnimationFrame;
|
1523
1660
|
}
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1661
|
+
if (isPresent.queueMicrotask) {
|
1662
|
+
timers.queueMicrotask = _global.queueMicrotask;
|
1663
|
+
}
|
1664
|
+
if (isPresent.cancelAnimationFrame) {
|
1665
|
+
timers.cancelAnimationFrame = _global.cancelAnimationFrame;
|
1666
|
+
}
|
1667
|
+
if (isPresent.requestIdleCallback) {
|
1668
|
+
timers.requestIdleCallback = _global.requestIdleCallback;
|
1669
|
+
}
|
1670
|
+
if (isPresent.cancelIdleCallback) {
|
1671
|
+
timers.cancelIdleCallback = _global.cancelIdleCallback;
|
1672
|
+
}
|
1673
|
+
if (isPresent.Intl) {
|
1674
|
+
timers.Intl = NativeIntl;
|
1675
|
+
}
|
1676
|
+
const originalSetTimeout = _global.setImmediate || _global.setTimeout;
|
1677
|
+
function createClock(start, loopLimit) {
|
1678
|
+
start = Math.floor(getEpoch(start));
|
1679
|
+
loopLimit = loopLimit || 1e3;
|
1680
|
+
let nanos = 0;
|
1681
|
+
const adjustedSystemTime = [0, 0];
|
1682
|
+
const clock = {
|
1683
|
+
now: start,
|
1684
|
+
Date: createDate(),
|
1685
|
+
loopLimit
|
1686
|
+
};
|
1687
|
+
clock.Date.clock = clock;
|
1688
|
+
function getTimeToNextFrame() {
|
1689
|
+
return 16 - (clock.now - start) % 16;
|
1690
|
+
}
|
1691
|
+
function hrtime(prev) {
|
1692
|
+
const millisSinceStart = clock.now - adjustedSystemTime[0] - start;
|
1693
|
+
const secsSinceStart = Math.floor(millisSinceStart / 1e3);
|
1694
|
+
const remainderInNanos = (millisSinceStart - secsSinceStart * 1e3) * 1e6 + nanos - adjustedSystemTime[1];
|
1695
|
+
if (Array.isArray(prev)) {
|
1696
|
+
if (prev[1] > 1e9) {
|
1697
|
+
throw new TypeError(
|
1698
|
+
"Number of nanoseconds can't exceed a billion"
|
1699
|
+
);
|
1700
|
+
}
|
1701
|
+
const oldSecs = prev[0];
|
1702
|
+
let nanoDiff = remainderInNanos - prev[1];
|
1703
|
+
let secDiff = secsSinceStart - oldSecs;
|
1704
|
+
if (nanoDiff < 0) {
|
1705
|
+
nanoDiff += 1e9;
|
1706
|
+
secDiff -= 1;
|
1707
|
+
}
|
1708
|
+
return [secDiff, nanoDiff];
|
1709
|
+
}
|
1710
|
+
return [secsSinceStart, remainderInNanos];
|
1528
1711
|
}
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
});
|
1712
|
+
function fakePerformanceNow() {
|
1713
|
+
const hrt = hrtime();
|
1714
|
+
const millis = hrt[0] * 1e3 + hrt[1] / 1e6;
|
1715
|
+
return millis;
|
1716
|
+
}
|
1717
|
+
if (isPresent.hrtimeBigint) {
|
1718
|
+
hrtime.bigint = function() {
|
1719
|
+
const parts = hrtime();
|
1720
|
+
return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]);
|
1721
|
+
};
|
1722
|
+
}
|
1723
|
+
if (isPresent.Intl) {
|
1724
|
+
clock.Intl = createIntl();
|
1725
|
+
clock.Intl.clock = clock;
|
1726
|
+
}
|
1727
|
+
clock.requestIdleCallback = function requestIdleCallback(func, timeout) {
|
1728
|
+
let timeToNextIdlePeriod = 0;
|
1729
|
+
if (clock.countTimers() > 0) {
|
1730
|
+
timeToNextIdlePeriod = 50;
|
1731
|
+
}
|
1732
|
+
const result = addTimer(clock, {
|
1733
|
+
func,
|
1734
|
+
args: Array.prototype.slice.call(arguments, 2),
|
1735
|
+
delay: typeof timeout === "undefined" ? timeToNextIdlePeriod : Math.min(timeout, timeToNextIdlePeriod),
|
1736
|
+
idleCallback: true
|
1555
1737
|
});
|
1738
|
+
return Number(result);
|
1556
1739
|
};
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
1561
|
-
clock.nextTick = function nextTick(func) {
|
1562
|
-
return enqueueJob(clock, {
|
1563
|
-
func,
|
1564
|
-
args: Array.prototype.slice.call(arguments, 1),
|
1565
|
-
error: isNearInfiniteLimit ? new Error() : null
|
1566
|
-
});
|
1567
|
-
};
|
1568
|
-
clock.queueMicrotask = function queueMicrotask(func) {
|
1569
|
-
return clock.nextTick(func);
|
1570
|
-
};
|
1571
|
-
clock.setInterval = function setInterval(func, timeout) {
|
1572
|
-
timeout = parseInt(timeout, 10);
|
1573
|
-
return addTimer(clock, {
|
1574
|
-
func,
|
1575
|
-
args: Array.prototype.slice.call(arguments, 2),
|
1576
|
-
delay: timeout,
|
1577
|
-
interval: timeout
|
1578
|
-
});
|
1579
|
-
};
|
1580
|
-
clock.clearInterval = function clearInterval(timerId) {
|
1581
|
-
return clearTimer(clock, timerId, "Interval");
|
1582
|
-
};
|
1583
|
-
if (setImmediatePresent) {
|
1584
|
-
clock.setImmediate = function setImmediate(func) {
|
1740
|
+
clock.cancelIdleCallback = function cancelIdleCallback(timerId) {
|
1741
|
+
return clearTimer(clock, timerId, "IdleCallback");
|
1742
|
+
};
|
1743
|
+
clock.setTimeout = function setTimeout(func, timeout) {
|
1585
1744
|
return addTimer(clock, {
|
1586
1745
|
func,
|
1587
|
-
args: Array.prototype.slice.call(arguments,
|
1588
|
-
|
1746
|
+
args: Array.prototype.slice.call(arguments, 2),
|
1747
|
+
delay: timeout
|
1589
1748
|
});
|
1590
1749
|
};
|
1591
1750
|
if (typeof _global.Promise !== "undefined" && utilPromisify) {
|
1592
|
-
clock.
|
1593
|
-
return new _global.Promise(
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
}
|
1601
|
-
);
|
1751
|
+
clock.setTimeout[utilPromisify.custom] = function promisifiedSetTimeout(timeout, arg) {
|
1752
|
+
return new _global.Promise(function setTimeoutExecutor(resolve) {
|
1753
|
+
addTimer(clock, {
|
1754
|
+
func: resolve,
|
1755
|
+
args: [arg],
|
1756
|
+
delay: timeout
|
1757
|
+
});
|
1758
|
+
});
|
1602
1759
|
};
|
1603
1760
|
}
|
1604
|
-
clock.
|
1605
|
-
return clearTimer(clock, timerId, "
|
1761
|
+
clock.clearTimeout = function clearTimeout(timerId) {
|
1762
|
+
return clearTimer(clock, timerId, "Timeout");
|
1606
1763
|
};
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
tickFrom += clock.now - oldNow;
|
1650
|
-
tickTo += clock.now - oldNow;
|
1651
|
-
}
|
1652
|
-
function doTickInner() {
|
1653
|
-
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
1654
|
-
while (timer && tickFrom <= tickTo) {
|
1655
|
-
if (clock.timers[timer.id]) {
|
1656
|
-
tickFrom = timer.callAt;
|
1657
|
-
clock.now = timer.callAt;
|
1658
|
-
oldNow = clock.now;
|
1659
|
-
try {
|
1660
|
-
runJobs(clock);
|
1661
|
-
callTimer(clock, timer);
|
1662
|
-
} catch (e) {
|
1663
|
-
firstException = firstException || e;
|
1664
|
-
}
|
1665
|
-
if (isAsync) {
|
1666
|
-
originalSetTimeout(nextPromiseTick);
|
1667
|
-
return;
|
1668
|
-
}
|
1669
|
-
compensationCheck();
|
1670
|
-
}
|
1671
|
-
postTimerCall();
|
1764
|
+
clock.nextTick = function nextTick(func) {
|
1765
|
+
return enqueueJob(clock, {
|
1766
|
+
func,
|
1767
|
+
args: Array.prototype.slice.call(arguments, 1),
|
1768
|
+
error: isNearInfiniteLimit ? new Error() : null
|
1769
|
+
});
|
1770
|
+
};
|
1771
|
+
clock.queueMicrotask = function queueMicrotask(func) {
|
1772
|
+
return clock.nextTick(func);
|
1773
|
+
};
|
1774
|
+
clock.setInterval = function setInterval(func, timeout) {
|
1775
|
+
timeout = parseInt(timeout, 10);
|
1776
|
+
return addTimer(clock, {
|
1777
|
+
func,
|
1778
|
+
args: Array.prototype.slice.call(arguments, 2),
|
1779
|
+
delay: timeout,
|
1780
|
+
interval: timeout
|
1781
|
+
});
|
1782
|
+
};
|
1783
|
+
clock.clearInterval = function clearInterval(timerId) {
|
1784
|
+
return clearTimer(clock, timerId, "Interval");
|
1785
|
+
};
|
1786
|
+
if (isPresent.setImmediate) {
|
1787
|
+
clock.setImmediate = function setImmediate(func) {
|
1788
|
+
return addTimer(clock, {
|
1789
|
+
func,
|
1790
|
+
args: Array.prototype.slice.call(arguments, 1),
|
1791
|
+
immediate: true
|
1792
|
+
});
|
1793
|
+
};
|
1794
|
+
if (typeof _global.Promise !== "undefined" && utilPromisify) {
|
1795
|
+
clock.setImmediate[utilPromisify.custom] = function promisifiedSetImmediate(arg) {
|
1796
|
+
return new _global.Promise(
|
1797
|
+
function setImmediateExecutor(resolve) {
|
1798
|
+
addTimer(clock, {
|
1799
|
+
func: resolve,
|
1800
|
+
args: [arg],
|
1801
|
+
immediate: true
|
1802
|
+
});
|
1803
|
+
}
|
1804
|
+
);
|
1805
|
+
};
|
1672
1806
|
}
|
1673
|
-
|
1807
|
+
clock.clearImmediate = function clearImmediate(timerId) {
|
1808
|
+
return clearTimer(clock, timerId, "Immediate");
|
1809
|
+
};
|
1810
|
+
}
|
1811
|
+
clock.countTimers = function countTimers() {
|
1812
|
+
return Object.keys(clock.timers || {}).length + (clock.jobs || []).length;
|
1813
|
+
};
|
1814
|
+
clock.requestAnimationFrame = function requestAnimationFrame(func) {
|
1815
|
+
const result = addTimer(clock, {
|
1816
|
+
func,
|
1817
|
+
delay: getTimeToNextFrame(),
|
1818
|
+
get args() {
|
1819
|
+
return [fakePerformanceNow()];
|
1820
|
+
},
|
1821
|
+
animation: true
|
1822
|
+
});
|
1823
|
+
return Number(result);
|
1824
|
+
};
|
1825
|
+
clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) {
|
1826
|
+
return clearTimer(clock, timerId, "AnimationFrame");
|
1827
|
+
};
|
1828
|
+
clock.runMicrotasks = function runMicrotasks() {
|
1674
1829
|
runJobs(clock);
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
} catch (e) {
|
1685
|
-
firstException = firstException || e;
|
1686
|
-
}
|
1687
|
-
} else {
|
1688
|
-
clock.now = tickTo;
|
1689
|
-
nanos = nanosTotal;
|
1690
|
-
}
|
1691
|
-
if (firstException) {
|
1692
|
-
throw firstException;
|
1830
|
+
};
|
1831
|
+
function doTick(tickValue, isAsync, resolve, reject) {
|
1832
|
+
const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
|
1833
|
+
const ms = Math.floor(msFloat);
|
1834
|
+
const remainder = nanoRemainder(msFloat);
|
1835
|
+
let nanosTotal = nanos + remainder;
|
1836
|
+
let tickTo = clock.now + ms;
|
1837
|
+
if (msFloat < 0) {
|
1838
|
+
throw new TypeError("Negative ticks are not supported");
|
1693
1839
|
}
|
1694
|
-
if (
|
1695
|
-
|
1696
|
-
|
1697
|
-
return clock.now;
|
1840
|
+
if (nanosTotal >= 1e6) {
|
1841
|
+
tickTo += 1;
|
1842
|
+
nanosTotal -= 1e6;
|
1698
1843
|
}
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
reject(e);
|
1707
|
-
}
|
1708
|
-
};
|
1709
|
-
compensationCheck = function() {
|
1844
|
+
nanos = nanosTotal;
|
1845
|
+
let tickFrom = clock.now;
|
1846
|
+
let previous = clock.now;
|
1847
|
+
let timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;
|
1848
|
+
clock.duringTick = true;
|
1849
|
+
oldNow = clock.now;
|
1850
|
+
runJobs(clock);
|
1710
1851
|
if (oldNow !== clock.now) {
|
1711
1852
|
tickFrom += clock.now - oldNow;
|
1712
1853
|
tickTo += clock.now - oldNow;
|
1713
|
-
previous += clock.now - oldNow;
|
1714
1854
|
}
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1855
|
+
function doTickInner() {
|
1856
|
+
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
1857
|
+
while (timer && tickFrom <= tickTo) {
|
1858
|
+
if (clock.timers[timer.id]) {
|
1859
|
+
tickFrom = timer.callAt;
|
1860
|
+
clock.now = timer.callAt;
|
1861
|
+
oldNow = clock.now;
|
1862
|
+
try {
|
1863
|
+
runJobs(clock);
|
1864
|
+
callTimer(clock, timer);
|
1865
|
+
} catch (e) {
|
1866
|
+
firstException = firstException || e;
|
1867
|
+
}
|
1868
|
+
if (isAsync) {
|
1869
|
+
originalSetTimeout(nextPromiseTick);
|
1870
|
+
return;
|
1871
|
+
}
|
1872
|
+
compensationCheck();
|
1873
|
+
}
|
1874
|
+
postTimerCall();
|
1875
|
+
}
|
1876
|
+
oldNow = clock.now;
|
1877
|
+
runJobs(clock);
|
1878
|
+
if (oldNow !== clock.now) {
|
1879
|
+
tickFrom += clock.now - oldNow;
|
1880
|
+
tickTo += clock.now - oldNow;
|
1881
|
+
}
|
1882
|
+
clock.duringTick = false;
|
1883
|
+
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
1884
|
+
if (timer) {
|
1729
1885
|
try {
|
1730
|
-
|
1886
|
+
clock.tick(tickTo - clock.now);
|
1731
1887
|
} catch (e) {
|
1732
|
-
|
1888
|
+
firstException = firstException || e;
|
1733
1889
|
}
|
1734
|
-
}
|
1735
|
-
|
1736
|
-
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
1749
|
-
|
1750
|
-
|
1751
|
-
|
1890
|
+
} else {
|
1891
|
+
clock.now = tickTo;
|
1892
|
+
nanos = nanosTotal;
|
1893
|
+
}
|
1894
|
+
if (firstException) {
|
1895
|
+
throw firstException;
|
1896
|
+
}
|
1897
|
+
if (isAsync) {
|
1898
|
+
resolve(clock.now);
|
1899
|
+
} else {
|
1900
|
+
return clock.now;
|
1901
|
+
}
|
1902
|
+
}
|
1903
|
+
nextPromiseTick = isAsync && function() {
|
1904
|
+
try {
|
1905
|
+
compensationCheck();
|
1906
|
+
postTimerCall();
|
1907
|
+
doTickInner();
|
1908
|
+
} catch (e) {
|
1909
|
+
reject(e);
|
1910
|
+
}
|
1911
|
+
};
|
1912
|
+
compensationCheck = function() {
|
1913
|
+
if (oldNow !== clock.now) {
|
1914
|
+
tickFrom += clock.now - oldNow;
|
1915
|
+
tickTo += clock.now - oldNow;
|
1916
|
+
previous += clock.now - oldNow;
|
1917
|
+
}
|
1918
|
+
};
|
1919
|
+
postTimerCall = function() {
|
1920
|
+
timer = firstTimerInRange(clock, previous, tickTo);
|
1921
|
+
previous = tickFrom;
|
1922
|
+
};
|
1923
|
+
return doTickInner();
|
1752
1924
|
}
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
if (!timer) {
|
1761
|
-
resolve(clock.now);
|
1762
|
-
return;
|
1763
|
-
}
|
1764
|
-
let err;
|
1765
|
-
clock.duringTick = true;
|
1766
|
-
clock.now = timer.callAt;
|
1925
|
+
clock.tick = function tick(tickValue) {
|
1926
|
+
return doTick(tickValue, false);
|
1927
|
+
};
|
1928
|
+
if (typeof _global.Promise !== "undefined") {
|
1929
|
+
clock.tickAsync = function tickAsync(tickValue) {
|
1930
|
+
return new _global.Promise(function(resolve, reject) {
|
1931
|
+
originalSetTimeout(function() {
|
1767
1932
|
try {
|
1768
|
-
|
1933
|
+
doTick(tickValue, true, resolve, reject);
|
1769
1934
|
} catch (e) {
|
1770
|
-
|
1935
|
+
reject(e);
|
1771
1936
|
}
|
1772
|
-
|
1773
|
-
originalSetTimeout(function() {
|
1774
|
-
if (err) {
|
1775
|
-
reject(err);
|
1776
|
-
} else {
|
1777
|
-
resolve(clock.now);
|
1778
|
-
}
|
1779
|
-
});
|
1780
|
-
} catch (e) {
|
1781
|
-
reject(e);
|
1782
|
-
}
|
1937
|
+
});
|
1783
1938
|
});
|
1784
|
-
}
|
1785
|
-
}
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
for (i = 0; i < clock.loopLimit; i++) {
|
1791
|
-
if (!clock.timers) {
|
1792
|
-
resetIsNearInfiniteLimit();
|
1939
|
+
};
|
1940
|
+
}
|
1941
|
+
clock.next = function next() {
|
1942
|
+
runJobs(clock);
|
1943
|
+
const timer = firstTimer(clock);
|
1944
|
+
if (!timer) {
|
1793
1945
|
return clock.now;
|
1794
1946
|
}
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1947
|
+
clock.duringTick = true;
|
1948
|
+
try {
|
1949
|
+
clock.now = timer.callAt;
|
1950
|
+
callTimer(clock, timer);
|
1951
|
+
runJobs(clock);
|
1798
1952
|
return clock.now;
|
1953
|
+
} finally {
|
1954
|
+
clock.duringTick = false;
|
1799
1955
|
}
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
throw getInfiniteLoopError(clock, excessJob);
|
1805
|
-
};
|
1806
|
-
clock.runToFrame = function runToFrame() {
|
1807
|
-
return clock.tick(getTimeToNextFrame());
|
1808
|
-
};
|
1809
|
-
if (typeof _global.Promise !== "undefined") {
|
1810
|
-
clock.runAllAsync = function runAllAsync() {
|
1811
|
-
return new _global.Promise(function(resolve, reject) {
|
1812
|
-
let i = 0;
|
1813
|
-
function doRun() {
|
1956
|
+
};
|
1957
|
+
if (typeof _global.Promise !== "undefined") {
|
1958
|
+
clock.nextAsync = function nextAsync() {
|
1959
|
+
return new _global.Promise(function(resolve, reject) {
|
1814
1960
|
originalSetTimeout(function() {
|
1815
1961
|
try {
|
1816
|
-
|
1817
|
-
if (
|
1818
|
-
|
1819
|
-
resetIsNearInfiniteLimit();
|
1820
|
-
resolve(clock.now);
|
1821
|
-
return;
|
1822
|
-
}
|
1823
|
-
numTimers = Object.keys(
|
1824
|
-
clock.timers
|
1825
|
-
).length;
|
1826
|
-
if (numTimers === 0) {
|
1827
|
-
resetIsNearInfiniteLimit();
|
1828
|
-
resolve(clock.now);
|
1829
|
-
return;
|
1830
|
-
}
|
1831
|
-
clock.next();
|
1832
|
-
i++;
|
1833
|
-
doRun();
|
1834
|
-
checkIsNearInfiniteLimit(clock, i);
|
1962
|
+
const timer = firstTimer(clock);
|
1963
|
+
if (!timer) {
|
1964
|
+
resolve(clock.now);
|
1835
1965
|
return;
|
1836
1966
|
}
|
1837
|
-
|
1838
|
-
|
1967
|
+
let err;
|
1968
|
+
clock.duringTick = true;
|
1969
|
+
clock.now = timer.callAt;
|
1970
|
+
try {
|
1971
|
+
callTimer(clock, timer);
|
1972
|
+
} catch (e) {
|
1973
|
+
err = e;
|
1974
|
+
}
|
1975
|
+
clock.duringTick = false;
|
1976
|
+
originalSetTimeout(function() {
|
1977
|
+
if (err) {
|
1978
|
+
reject(err);
|
1979
|
+
} else {
|
1980
|
+
resolve(clock.now);
|
1981
|
+
}
|
1982
|
+
});
|
1839
1983
|
} catch (e) {
|
1840
1984
|
reject(e);
|
1841
1985
|
}
|
1842
1986
|
});
|
1987
|
+
});
|
1988
|
+
};
|
1989
|
+
}
|
1990
|
+
clock.runAll = function runAll() {
|
1991
|
+
let numTimers, i;
|
1992
|
+
runJobs(clock);
|
1993
|
+
for (i = 0; i < clock.loopLimit; i++) {
|
1994
|
+
if (!clock.timers) {
|
1995
|
+
resetIsNearInfiniteLimit();
|
1996
|
+
return clock.now;
|
1843
1997
|
}
|
1844
|
-
|
1845
|
-
|
1998
|
+
numTimers = Object.keys(clock.timers).length;
|
1999
|
+
if (numTimers === 0) {
|
2000
|
+
resetIsNearInfiniteLimit();
|
2001
|
+
return clock.now;
|
2002
|
+
}
|
2003
|
+
clock.next();
|
2004
|
+
checkIsNearInfiniteLimit(clock, i);
|
2005
|
+
}
|
2006
|
+
const excessJob = firstTimer(clock);
|
2007
|
+
throw getInfiniteLoopError(clock, excessJob);
|
1846
2008
|
};
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
if (
|
1851
|
-
|
1852
|
-
|
2009
|
+
clock.runToFrame = function runToFrame() {
|
2010
|
+
return clock.tick(getTimeToNextFrame());
|
2011
|
+
};
|
2012
|
+
if (typeof _global.Promise !== "undefined") {
|
2013
|
+
clock.runAllAsync = function runAllAsync() {
|
2014
|
+
return new _global.Promise(function(resolve, reject) {
|
2015
|
+
let i = 0;
|
2016
|
+
function doRun() {
|
2017
|
+
originalSetTimeout(function() {
|
2018
|
+
try {
|
2019
|
+
runJobs(clock);
|
2020
|
+
let numTimers;
|
2021
|
+
if (i < clock.loopLimit) {
|
2022
|
+
if (!clock.timers) {
|
2023
|
+
resetIsNearInfiniteLimit();
|
2024
|
+
resolve(clock.now);
|
2025
|
+
return;
|
2026
|
+
}
|
2027
|
+
numTimers = Object.keys(
|
2028
|
+
clock.timers
|
2029
|
+
).length;
|
2030
|
+
if (numTimers === 0) {
|
2031
|
+
resetIsNearInfiniteLimit();
|
2032
|
+
resolve(clock.now);
|
2033
|
+
return;
|
2034
|
+
}
|
2035
|
+
clock.next();
|
2036
|
+
i++;
|
2037
|
+
doRun();
|
2038
|
+
checkIsNearInfiniteLimit(clock, i);
|
2039
|
+
return;
|
2040
|
+
}
|
2041
|
+
const excessJob = firstTimer(clock);
|
2042
|
+
reject(getInfiniteLoopError(clock, excessJob));
|
2043
|
+
} catch (e) {
|
2044
|
+
reject(e);
|
2045
|
+
}
|
2046
|
+
});
|
2047
|
+
}
|
2048
|
+
doRun();
|
2049
|
+
});
|
2050
|
+
};
|
1853
2051
|
}
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
2052
|
+
clock.runToLast = function runToLast() {
|
2053
|
+
const timer = lastTimer(clock);
|
2054
|
+
if (!timer) {
|
2055
|
+
runJobs(clock);
|
2056
|
+
return clock.now;
|
2057
|
+
}
|
2058
|
+
return clock.tick(timer.callAt - clock.now);
|
2059
|
+
};
|
2060
|
+
if (typeof _global.Promise !== "undefined") {
|
2061
|
+
clock.runToLastAsync = function runToLastAsync() {
|
2062
|
+
return new _global.Promise(function(resolve, reject) {
|
2063
|
+
originalSetTimeout(function() {
|
2064
|
+
try {
|
2065
|
+
const timer = lastTimer(clock);
|
2066
|
+
if (!timer) {
|
2067
|
+
runJobs(clock);
|
2068
|
+
resolve(clock.now);
|
2069
|
+
}
|
2070
|
+
resolve(clock.tickAsync(timer.callAt - clock.now));
|
2071
|
+
} catch (e) {
|
2072
|
+
reject(e);
|
1864
2073
|
}
|
1865
|
-
|
1866
|
-
} catch (e) {
|
1867
|
-
reject(e);
|
1868
|
-
}
|
2074
|
+
});
|
1869
2075
|
});
|
1870
|
-
}
|
2076
|
+
};
|
2077
|
+
}
|
2078
|
+
clock.reset = function reset() {
|
2079
|
+
nanos = 0;
|
2080
|
+
clock.timers = {};
|
2081
|
+
clock.jobs = [];
|
2082
|
+
clock.now = start;
|
1871
2083
|
};
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
|
1884
|
-
|
1885
|
-
|
1886
|
-
nanos = 0;
|
1887
|
-
for (id in clock.timers) {
|
1888
|
-
if (clock.timers.hasOwnProperty(id)) {
|
1889
|
-
timer = clock.timers[id];
|
1890
|
-
timer.createdAt += difference;
|
1891
|
-
timer.callAt += difference;
|
2084
|
+
clock.setSystemTime = function setSystemTime(systemTime) {
|
2085
|
+
const newNow = getEpoch(systemTime);
|
2086
|
+
const difference = newNow - clock.now;
|
2087
|
+
let id, timer;
|
2088
|
+
adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
|
2089
|
+
adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
|
2090
|
+
clock.now = newNow;
|
2091
|
+
nanos = 0;
|
2092
|
+
for (id in clock.timers) {
|
2093
|
+
if (clock.timers.hasOwnProperty(id)) {
|
2094
|
+
timer = clock.timers[id];
|
2095
|
+
timer.createdAt += difference;
|
2096
|
+
timer.callAt += difference;
|
2097
|
+
}
|
1892
2098
|
}
|
1893
|
-
}
|
1894
|
-
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
2099
|
+
};
|
2100
|
+
clock.jump = function jump(tickValue) {
|
2101
|
+
const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
|
2102
|
+
const ms = Math.floor(msFloat);
|
2103
|
+
for (const timer of Object.values(clock.timers)) {
|
2104
|
+
if (clock.now + ms > timer.callAt) {
|
2105
|
+
timer.callAt = clock.now + ms;
|
2106
|
+
}
|
1901
2107
|
}
|
2108
|
+
clock.tick(ms);
|
2109
|
+
};
|
2110
|
+
if (isPresent.performance) {
|
2111
|
+
clock.performance = /* @__PURE__ */ Object.create(null);
|
2112
|
+
clock.performance.now = fakePerformanceNow;
|
1902
2113
|
}
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
clock
|
1907
|
-
clock.performance.now = fakePerformanceNow;
|
1908
|
-
}
|
1909
|
-
if (hrtimePresent) {
|
1910
|
-
clock.hrtime = hrtime;
|
1911
|
-
}
|
1912
|
-
return clock;
|
1913
|
-
}
|
1914
|
-
function install(config) {
|
1915
|
-
if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || typeof config === "number") {
|
1916
|
-
throw new TypeError(
|
1917
|
-
`FakeTimers.install called with ${String(
|
1918
|
-
config
|
1919
|
-
)} install requires an object parameter`
|
1920
|
-
);
|
1921
|
-
}
|
1922
|
-
if (_global.Date.isFake === true) {
|
1923
|
-
throw new TypeError(
|
1924
|
-
"Can't install fake timers twice on the same global object."
|
1925
|
-
);
|
1926
|
-
}
|
1927
|
-
config = typeof config !== "undefined" ? config : {};
|
1928
|
-
config.shouldAdvanceTime = config.shouldAdvanceTime || false;
|
1929
|
-
config.advanceTimeDelta = config.advanceTimeDelta || 20;
|
1930
|
-
config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;
|
1931
|
-
if (config.target) {
|
1932
|
-
throw new TypeError(
|
1933
|
-
"config.target is no longer supported. Use `withGlobal(target)` instead."
|
1934
|
-
);
|
1935
|
-
}
|
1936
|
-
let i, l;
|
1937
|
-
const clock = createClock(config.now, config.loopLimit);
|
1938
|
-
clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
|
1939
|
-
clock.uninstall = function() {
|
1940
|
-
return uninstall(clock, config);
|
1941
|
-
};
|
1942
|
-
clock.methods = config.toFake || [];
|
1943
|
-
if (clock.methods.length === 0) {
|
1944
|
-
clock.methods = Object.keys(timers).filter(function(key) {
|
1945
|
-
return key !== "nextTick" && key !== "queueMicrotask";
|
1946
|
-
});
|
1947
|
-
}
|
1948
|
-
if (config.shouldAdvanceTime === true) {
|
1949
|
-
const intervalTick = doIntervalTick.bind(
|
1950
|
-
null,
|
1951
|
-
clock,
|
1952
|
-
config.advanceTimeDelta
|
1953
|
-
);
|
1954
|
-
const intervalId = _global.setInterval(
|
1955
|
-
intervalTick,
|
1956
|
-
config.advanceTimeDelta
|
1957
|
-
);
|
1958
|
-
clock.attachedInterval = intervalId;
|
2114
|
+
if (isPresent.hrtime) {
|
2115
|
+
clock.hrtime = hrtime;
|
2116
|
+
}
|
2117
|
+
return clock;
|
1959
2118
|
}
|
1960
|
-
|
1961
|
-
|
1962
|
-
|
1963
|
-
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
2119
|
+
function install(config) {
|
2120
|
+
if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || typeof config === "number") {
|
2121
|
+
throw new TypeError(
|
2122
|
+
`FakeTimers.install called with ${String(
|
2123
|
+
config
|
2124
|
+
)} install requires an object parameter`
|
2125
|
+
);
|
2126
|
+
}
|
2127
|
+
if (_global.Date.isFake === true) {
|
2128
|
+
throw new TypeError(
|
2129
|
+
"Can't install fake timers twice on the same global object."
|
2130
|
+
);
|
2131
|
+
}
|
2132
|
+
config = typeof config !== "undefined" ? config : {};
|
2133
|
+
config.shouldAdvanceTime = config.shouldAdvanceTime || false;
|
2134
|
+
config.advanceTimeDelta = config.advanceTimeDelta || 20;
|
2135
|
+
config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;
|
2136
|
+
if (config.target) {
|
2137
|
+
throw new TypeError(
|
2138
|
+
"config.target is no longer supported. Use `withGlobal(target)` instead."
|
2139
|
+
);
|
2140
|
+
}
|
2141
|
+
function handleMissingTimer(timer) {
|
2142
|
+
if (config.ignoreMissingTimers) {
|
2143
|
+
return;
|
1967
2144
|
}
|
1968
|
-
})();
|
1969
|
-
if (proto) {
|
1970
|
-
Object.getOwnPropertyNames(proto).forEach(function(name) {
|
1971
|
-
if (name !== "now") {
|
1972
|
-
clock.performance[name] = name.indexOf("getEntries") === 0 ? NOOP_ARRAY : NOOP;
|
1973
|
-
}
|
1974
|
-
});
|
1975
|
-
} else if ((config.toFake || []).includes("performance")) {
|
1976
2145
|
throw new ReferenceError(
|
1977
|
-
|
2146
|
+
`non-existent timers and/or objects cannot be faked: '${timer}'`
|
1978
2147
|
);
|
1979
2148
|
}
|
1980
|
-
|
1981
|
-
|
1982
|
-
clock.
|
1983
|
-
|
1984
|
-
|
1985
|
-
|
1986
|
-
|
1987
|
-
|
1988
|
-
|
1989
|
-
|
1990
|
-
}
|
1991
|
-
|
1992
|
-
|
2149
|
+
let i, l;
|
2150
|
+
const clock = createClock(config.now, config.loopLimit);
|
2151
|
+
clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
|
2152
|
+
clock.uninstall = function() {
|
2153
|
+
return uninstall(clock, config);
|
2154
|
+
};
|
2155
|
+
clock.abortListenerMap = /* @__PURE__ */ new Map();
|
2156
|
+
clock.methods = config.toFake || [];
|
2157
|
+
if (clock.methods.length === 0) {
|
2158
|
+
clock.methods = Object.keys(timers);
|
2159
|
+
}
|
2160
|
+
if (config.shouldAdvanceTime === true) {
|
2161
|
+
const intervalTick = doIntervalTick.bind(
|
2162
|
+
null,
|
2163
|
+
clock,
|
2164
|
+
config.advanceTimeDelta
|
2165
|
+
);
|
2166
|
+
const intervalId = _global.setInterval(
|
2167
|
+
intervalTick,
|
2168
|
+
config.advanceTimeDelta
|
2169
|
+
);
|
2170
|
+
clock.attachedInterval = intervalId;
|
2171
|
+
}
|
2172
|
+
if (clock.methods.includes("performance")) {
|
2173
|
+
const proto = (() => {
|
2174
|
+
if (hasPerformanceConstructorPrototype) {
|
2175
|
+
return _global.performance.constructor.prototype;
|
2176
|
+
}
|
2177
|
+
if (hasPerformancePrototype) {
|
2178
|
+
return _global.Performance.prototype;
|
2179
|
+
}
|
2180
|
+
})();
|
2181
|
+
if (proto) {
|
2182
|
+
Object.getOwnPropertyNames(proto).forEach(function(name) {
|
2183
|
+
if (name !== "now") {
|
2184
|
+
clock.performance[name] = name.indexOf("getEntries") === 0 ? NOOP_ARRAY : NOOP;
|
2185
|
+
}
|
2186
|
+
});
|
2187
|
+
clock.performance.mark = (name) => new FakePerformanceEntry(name, "mark", 0, 0);
|
2188
|
+
clock.performance.measure = (name) => new FakePerformanceEntry(name, "measure", 0, 100);
|
2189
|
+
clock.performance.timeOrigin = getEpoch(config.now);
|
2190
|
+
} else if ((config.toFake || []).includes("performance")) {
|
2191
|
+
return handleMissingTimer("performance");
|
1993
2192
|
}
|
1994
|
-
} else {
|
1995
|
-
hijackMethod(_global, nameOfMethodToReplace, clock);
|
1996
2193
|
}
|
1997
|
-
if (
|
1998
|
-
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2194
|
+
if (_global === globalObject && timersModule) {
|
2195
|
+
clock.timersModuleMethods = [];
|
2196
|
+
}
|
2197
|
+
if (_global === globalObject && timersPromisesModule) {
|
2198
|
+
clock.timersPromisesModuleMethods = [];
|
2199
|
+
}
|
2200
|
+
for (i = 0, l = clock.methods.length; i < l; i++) {
|
2201
|
+
const nameOfMethodToReplace = clock.methods[i];
|
2202
|
+
if (!isPresent[nameOfMethodToReplace]) {
|
2203
|
+
handleMissingTimer(nameOfMethodToReplace);
|
2204
|
+
continue;
|
2205
|
+
}
|
2206
|
+
if (nameOfMethodToReplace === "hrtime") {
|
2207
|
+
if (_global.process && typeof _global.process.hrtime === "function") {
|
2208
|
+
hijackMethod(_global.process, nameOfMethodToReplace, clock);
|
2209
|
+
}
|
2210
|
+
} else if (nameOfMethodToReplace === "nextTick") {
|
2211
|
+
if (_global.process && typeof _global.process.nextTick === "function") {
|
2212
|
+
hijackMethod(_global.process, nameOfMethodToReplace, clock);
|
2213
|
+
}
|
2214
|
+
} else {
|
2215
|
+
hijackMethod(_global, nameOfMethodToReplace, clock);
|
2216
|
+
}
|
2217
|
+
if (clock.timersModuleMethods !== void 0 && timersModule[nameOfMethodToReplace]) {
|
2218
|
+
const original = timersModule[nameOfMethodToReplace];
|
2219
|
+
clock.timersModuleMethods.push({
|
2220
|
+
methodName: nameOfMethodToReplace,
|
2221
|
+
original
|
2222
|
+
});
|
2223
|
+
timersModule[nameOfMethodToReplace] = _global[nameOfMethodToReplace];
|
2224
|
+
}
|
2225
|
+
if (clock.timersPromisesModuleMethods !== void 0) {
|
2226
|
+
if (nameOfMethodToReplace === "setTimeout") {
|
2227
|
+
clock.timersPromisesModuleMethods.push({
|
2228
|
+
methodName: "setTimeout",
|
2229
|
+
original: timersPromisesModule.setTimeout
|
2230
|
+
});
|
2231
|
+
timersPromisesModule.setTimeout = (delay, value, options = {}) => new Promise((resolve, reject) => {
|
2232
|
+
const abort = () => {
|
2233
|
+
options.signal.removeEventListener(
|
2234
|
+
"abort",
|
2235
|
+
abort
|
2236
|
+
);
|
2237
|
+
clock.abortListenerMap.delete(abort);
|
2238
|
+
clock.clearTimeout(handle);
|
2239
|
+
reject(options.signal.reason);
|
2240
|
+
};
|
2241
|
+
const handle = clock.setTimeout(() => {
|
2242
|
+
if (options.signal) {
|
2243
|
+
options.signal.removeEventListener(
|
2244
|
+
"abort",
|
2245
|
+
abort
|
2246
|
+
);
|
2247
|
+
clock.abortListenerMap.delete(abort);
|
2248
|
+
}
|
2249
|
+
resolve(value);
|
2250
|
+
}, delay);
|
2251
|
+
if (options.signal) {
|
2252
|
+
if (options.signal.aborted) {
|
2253
|
+
abort();
|
2254
|
+
} else {
|
2255
|
+
options.signal.addEventListener(
|
2256
|
+
"abort",
|
2257
|
+
abort
|
2258
|
+
);
|
2259
|
+
clock.abortListenerMap.set(
|
2260
|
+
abort,
|
2261
|
+
options.signal
|
2262
|
+
);
|
2263
|
+
}
|
2264
|
+
}
|
2265
|
+
});
|
2266
|
+
} else if (nameOfMethodToReplace === "setImmediate") {
|
2267
|
+
clock.timersPromisesModuleMethods.push({
|
2268
|
+
methodName: "setImmediate",
|
2269
|
+
original: timersPromisesModule.setImmediate
|
2270
|
+
});
|
2271
|
+
timersPromisesModule.setImmediate = (value, options = {}) => new Promise((resolve, reject) => {
|
2272
|
+
const abort = () => {
|
2273
|
+
options.signal.removeEventListener(
|
2274
|
+
"abort",
|
2275
|
+
abort
|
2276
|
+
);
|
2277
|
+
clock.abortListenerMap.delete(abort);
|
2278
|
+
clock.clearImmediate(handle);
|
2279
|
+
reject(options.signal.reason);
|
2280
|
+
};
|
2281
|
+
const handle = clock.setImmediate(() => {
|
2282
|
+
if (options.signal) {
|
2283
|
+
options.signal.removeEventListener(
|
2284
|
+
"abort",
|
2285
|
+
abort
|
2286
|
+
);
|
2287
|
+
clock.abortListenerMap.delete(abort);
|
2288
|
+
}
|
2289
|
+
resolve(value);
|
2290
|
+
});
|
2291
|
+
if (options.signal) {
|
2292
|
+
if (options.signal.aborted) {
|
2293
|
+
abort();
|
2294
|
+
} else {
|
2295
|
+
options.signal.addEventListener(
|
2296
|
+
"abort",
|
2297
|
+
abort
|
2298
|
+
);
|
2299
|
+
clock.abortListenerMap.set(
|
2300
|
+
abort,
|
2301
|
+
options.signal
|
2302
|
+
);
|
2303
|
+
}
|
2304
|
+
}
|
2305
|
+
});
|
2306
|
+
} else if (nameOfMethodToReplace === "setInterval") {
|
2307
|
+
clock.timersPromisesModuleMethods.push({
|
2308
|
+
methodName: "setInterval",
|
2309
|
+
original: timersPromisesModule.setInterval
|
2310
|
+
});
|
2311
|
+
timersPromisesModule.setInterval = (delay, value, options = {}) => ({
|
2312
|
+
[Symbol.asyncIterator]: () => {
|
2313
|
+
const createResolvable = () => {
|
2314
|
+
let resolve, reject;
|
2315
|
+
const promise = new Promise((res, rej) => {
|
2316
|
+
resolve = res;
|
2317
|
+
reject = rej;
|
2318
|
+
});
|
2319
|
+
promise.resolve = resolve;
|
2320
|
+
promise.reject = reject;
|
2321
|
+
return promise;
|
2322
|
+
};
|
2323
|
+
let done = false;
|
2324
|
+
let hasThrown = false;
|
2325
|
+
let returnCall;
|
2326
|
+
let nextAvailable = 0;
|
2327
|
+
const nextQueue = [];
|
2328
|
+
const handle = clock.setInterval(() => {
|
2329
|
+
if (nextQueue.length > 0) {
|
2330
|
+
nextQueue.shift().resolve();
|
2331
|
+
} else {
|
2332
|
+
nextAvailable++;
|
2333
|
+
}
|
2334
|
+
}, delay);
|
2335
|
+
const abort = () => {
|
2336
|
+
options.signal.removeEventListener(
|
2337
|
+
"abort",
|
2338
|
+
abort
|
2339
|
+
);
|
2340
|
+
clock.abortListenerMap.delete(abort);
|
2341
|
+
clock.clearInterval(handle);
|
2342
|
+
done = true;
|
2343
|
+
for (const resolvable of nextQueue) {
|
2344
|
+
resolvable.resolve();
|
2345
|
+
}
|
2346
|
+
};
|
2347
|
+
if (options.signal) {
|
2348
|
+
if (options.signal.aborted) {
|
2349
|
+
done = true;
|
2350
|
+
} else {
|
2351
|
+
options.signal.addEventListener(
|
2352
|
+
"abort",
|
2353
|
+
abort
|
2354
|
+
);
|
2355
|
+
clock.abortListenerMap.set(
|
2356
|
+
abort,
|
2357
|
+
options.signal
|
2358
|
+
);
|
2359
|
+
}
|
2360
|
+
}
|
2361
|
+
return {
|
2362
|
+
next: async () => {
|
2363
|
+
if (options.signal?.aborted && !hasThrown) {
|
2364
|
+
hasThrown = true;
|
2365
|
+
throw options.signal.reason;
|
2366
|
+
}
|
2367
|
+
if (done) {
|
2368
|
+
return { done: true, value: void 0 };
|
2369
|
+
}
|
2370
|
+
if (nextAvailable > 0) {
|
2371
|
+
nextAvailable--;
|
2372
|
+
return { done: false, value };
|
2373
|
+
}
|
2374
|
+
const resolvable = createResolvable();
|
2375
|
+
nextQueue.push(resolvable);
|
2376
|
+
await resolvable;
|
2377
|
+
if (returnCall && nextQueue.length === 0) {
|
2378
|
+
returnCall.resolve();
|
2379
|
+
}
|
2380
|
+
if (options.signal?.aborted && !hasThrown) {
|
2381
|
+
hasThrown = true;
|
2382
|
+
throw options.signal.reason;
|
2383
|
+
}
|
2384
|
+
if (done) {
|
2385
|
+
return { done: true, value: void 0 };
|
2386
|
+
}
|
2387
|
+
return { done: false, value };
|
2388
|
+
},
|
2389
|
+
return: async () => {
|
2390
|
+
if (done) {
|
2391
|
+
return { done: true, value: void 0 };
|
2392
|
+
}
|
2393
|
+
if (nextQueue.length > 0) {
|
2394
|
+
returnCall = createResolvable();
|
2395
|
+
await returnCall;
|
2396
|
+
}
|
2397
|
+
clock.clearInterval(handle);
|
2398
|
+
done = true;
|
2399
|
+
if (options.signal) {
|
2400
|
+
options.signal.removeEventListener(
|
2401
|
+
"abort",
|
2402
|
+
abort
|
2403
|
+
);
|
2404
|
+
clock.abortListenerMap.delete(abort);
|
2405
|
+
}
|
2406
|
+
return { done: true, value: void 0 };
|
2407
|
+
}
|
2408
|
+
};
|
2409
|
+
}
|
2410
|
+
});
|
2411
|
+
}
|
2412
|
+
}
|
2004
2413
|
}
|
2414
|
+
return clock;
|
2005
2415
|
}
|
2006
|
-
return
|
2416
|
+
return {
|
2417
|
+
timers,
|
2418
|
+
createClock,
|
2419
|
+
install,
|
2420
|
+
withGlobal
|
2421
|
+
};
|
2007
2422
|
}
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2423
|
+
const defaultImplementation = withGlobal(globalObject);
|
2424
|
+
fakeTimersSrc.timers = defaultImplementation.timers;
|
2425
|
+
fakeTimersSrc.createClock = defaultImplementation.createClock;
|
2426
|
+
fakeTimersSrc.install = defaultImplementation.install;
|
2427
|
+
fakeTimersSrc.withGlobal = withGlobal;
|
2428
|
+
return fakeTimersSrc;
|
2014
2429
|
}
|
2015
|
-
var
|
2016
|
-
defaultImplementation.timers;
|
2017
|
-
defaultImplementation.createClock;
|
2018
|
-
defaultImplementation.install;
|
2019
|
-
var withGlobal_1 = withGlobal;
|
2430
|
+
var fakeTimersSrcExports = requireFakeTimersSrc();
|
2020
2431
|
var FakeTimers = class {
|
2021
2432
|
_global;
|
2022
2433
|
_clock;
|
@@ -2025,46 +2436,49 @@ var FakeTimers = class {
|
|
2025
2436
|
_fakeTimers;
|
2026
2437
|
_userConfig;
|
2027
2438
|
_now = RealDate.now;
|
2028
|
-
constructor({
|
2029
|
-
global: global3,
|
2030
|
-
config
|
2031
|
-
}) {
|
2439
|
+
constructor({ global: global3, config }) {
|
2032
2440
|
this._userConfig = config;
|
2033
|
-
this._fakingDate =
|
2441
|
+
this._fakingDate = null;
|
2034
2442
|
this._fakingTime = false;
|
2035
|
-
this._fakeTimers =
|
2443
|
+
this._fakeTimers = fakeTimersSrcExports.withGlobal(global3);
|
2036
2444
|
this._global = global3;
|
2037
2445
|
}
|
2038
2446
|
clearAllTimers() {
|
2039
|
-
if (this._fakingTime)
|
2447
|
+
if (this._fakingTime) {
|
2040
2448
|
this._clock.reset();
|
2449
|
+
}
|
2041
2450
|
}
|
2042
2451
|
dispose() {
|
2043
2452
|
this.useRealTimers();
|
2044
2453
|
}
|
2045
2454
|
runAllTimers() {
|
2046
|
-
if (this._checkFakeTimers())
|
2455
|
+
if (this._checkFakeTimers()) {
|
2047
2456
|
this._clock.runAll();
|
2457
|
+
}
|
2048
2458
|
}
|
2049
2459
|
async runAllTimersAsync() {
|
2050
|
-
if (this._checkFakeTimers())
|
2460
|
+
if (this._checkFakeTimers()) {
|
2051
2461
|
await this._clock.runAllAsync();
|
2462
|
+
}
|
2052
2463
|
}
|
2053
2464
|
runOnlyPendingTimers() {
|
2054
|
-
if (this._checkFakeTimers())
|
2465
|
+
if (this._checkFakeTimers()) {
|
2055
2466
|
this._clock.runToLast();
|
2467
|
+
}
|
2056
2468
|
}
|
2057
2469
|
async runOnlyPendingTimersAsync() {
|
2058
|
-
if (this._checkFakeTimers())
|
2470
|
+
if (this._checkFakeTimers()) {
|
2059
2471
|
await this._clock.runToLastAsync();
|
2472
|
+
}
|
2060
2473
|
}
|
2061
2474
|
advanceTimersToNextTimer(steps = 1) {
|
2062
2475
|
if (this._checkFakeTimers()) {
|
2063
2476
|
for (let i = steps; i > 0; i--) {
|
2064
2477
|
this._clock.next();
|
2065
2478
|
this._clock.tick(0);
|
2066
|
-
if (this._clock.countTimers() === 0)
|
2479
|
+
if (this._clock.countTimers() === 0) {
|
2067
2480
|
break;
|
2481
|
+
}
|
2068
2482
|
}
|
2069
2483
|
}
|
2070
2484
|
}
|
@@ -2073,18 +2487,26 @@ var FakeTimers = class {
|
|
2073
2487
|
for (let i = steps; i > 0; i--) {
|
2074
2488
|
await this._clock.nextAsync();
|
2075
2489
|
this._clock.tick(0);
|
2076
|
-
if (this._clock.countTimers() === 0)
|
2490
|
+
if (this._clock.countTimers() === 0) {
|
2077
2491
|
break;
|
2492
|
+
}
|
2078
2493
|
}
|
2079
2494
|
}
|
2080
2495
|
}
|
2081
2496
|
advanceTimersByTime(msToRun) {
|
2082
|
-
if (this._checkFakeTimers())
|
2497
|
+
if (this._checkFakeTimers()) {
|
2083
2498
|
this._clock.tick(msToRun);
|
2499
|
+
}
|
2084
2500
|
}
|
2085
2501
|
async advanceTimersByTimeAsync(msToRun) {
|
2086
|
-
if (this._checkFakeTimers())
|
2502
|
+
if (this._checkFakeTimers()) {
|
2087
2503
|
await this._clock.tickAsync(msToRun);
|
2504
|
+
}
|
2505
|
+
}
|
2506
|
+
advanceTimersToNextFrame() {
|
2507
|
+
if (this._checkFakeTimers()) {
|
2508
|
+
this._clock.runToFrame();
|
2509
|
+
}
|
2088
2510
|
}
|
2089
2511
|
runAllTicks() {
|
2090
2512
|
if (this._checkFakeTimers()) {
|
@@ -2094,7 +2516,7 @@ var FakeTimers = class {
|
|
2094
2516
|
useRealTimers() {
|
2095
2517
|
if (this._fakingDate) {
|
2096
2518
|
resetDate();
|
2097
|
-
this._fakingDate =
|
2519
|
+
this._fakingDate = null;
|
2098
2520
|
}
|
2099
2521
|
if (this._fakingTime) {
|
2100
2522
|
this._clock.uninstall();
|
@@ -2102,29 +2524,19 @@ var FakeTimers = class {
|
|
2102
2524
|
}
|
2103
2525
|
}
|
2104
2526
|
useFakeTimers() {
|
2105
|
-
var _a, _b, _c;
|
2106
2527
|
if (this._fakingDate) {
|
2107
|
-
throw new Error(
|
2108
|
-
'"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.'
|
2109
|
-
);
|
2528
|
+
throw new Error('"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.');
|
2110
2529
|
}
|
2111
2530
|
if (!this._fakingTime) {
|
2112
|
-
const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick");
|
2113
|
-
if (
|
2531
|
+
const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick" && timer !== "queueMicrotask");
|
2532
|
+
if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) {
|
2114
2533
|
throw new Error("process.nextTick cannot be mocked inside child_process");
|
2115
|
-
|
2116
|
-
switch (method) {
|
2117
|
-
case "setImmediate":
|
2118
|
-
case "clearImmediate":
|
2119
|
-
return method in this._global && this._global[method];
|
2120
|
-
default:
|
2121
|
-
return true;
|
2122
|
-
}
|
2123
|
-
});
|
2534
|
+
}
|
2124
2535
|
this._clock = this._fakeTimers.install({
|
2125
2536
|
now: Date.now(),
|
2126
2537
|
...this._userConfig,
|
2127
|
-
toFake:
|
2538
|
+
toFake: this._userConfig?.toFake || toFake,
|
2539
|
+
ignoreMissingTimers: true
|
2128
2540
|
});
|
2129
2541
|
this._fakingTime = true;
|
2130
2542
|
}
|
@@ -2137,19 +2549,24 @@ var FakeTimers = class {
|
|
2137
2549
|
}
|
2138
2550
|
}
|
2139
2551
|
setSystemTime(now2) {
|
2552
|
+
const date = typeof now2 === "undefined" || now2 instanceof Date ? now2 : new Date(now2);
|
2140
2553
|
if (this._fakingTime) {
|
2141
|
-
this._clock.setSystemTime(
|
2554
|
+
this._clock.setSystemTime(date);
|
2142
2555
|
} else {
|
2143
|
-
|
2144
|
-
this._fakingDate
|
2556
|
+
this._fakingDate = date ?? new Date(this.getRealSystemTime());
|
2557
|
+
mockDate(this._fakingDate);
|
2145
2558
|
}
|
2146
2559
|
}
|
2560
|
+
getMockedSystemTime() {
|
2561
|
+
return this._fakingTime ? new Date(this._clock.now) : this._fakingDate;
|
2562
|
+
}
|
2147
2563
|
getRealSystemTime() {
|
2148
2564
|
return this._now();
|
2149
2565
|
}
|
2150
2566
|
getTimerCount() {
|
2151
|
-
if (this._checkFakeTimers())
|
2567
|
+
if (this._checkFakeTimers()) {
|
2152
2568
|
return this._clock.countTimers();
|
2569
|
+
}
|
2153
2570
|
return 0;
|
2154
2571
|
}
|
2155
2572
|
configure(config) {
|
@@ -2160,20 +2577,19 @@ var FakeTimers = class {
|
|
2160
2577
|
}
|
2161
2578
|
_checkFakeTimers() {
|
2162
2579
|
if (!this._fakingTime) {
|
2163
|
-
throw new Error(
|
2164
|
-
'Timers are not mocked. Try calling "vi.useFakeTimers()" first.'
|
2165
|
-
);
|
2580
|
+
throw new Error('Timers are not mocked. Try calling "vi.useFakeTimers()" first.');
|
2166
2581
|
}
|
2167
2582
|
return this._fakingTime;
|
2168
2583
|
}
|
2169
2584
|
};
|
2170
2585
|
function copyStackTrace(target, source) {
|
2171
|
-
if (source.stack !== void 0)
|
2586
|
+
if (source.stack !== void 0) {
|
2172
2587
|
target.stack = source.stack.replace(source.message, target.message);
|
2588
|
+
}
|
2173
2589
|
return target;
|
2174
2590
|
}
|
2175
2591
|
function waitFor(callback, options = {}) {
|
2176
|
-
const { setTimeout, setInterval, clearTimeout, clearInterval } =
|
2592
|
+
const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2();
|
2177
2593
|
const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
|
2178
2594
|
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
2179
2595
|
return new Promise((resolve, reject) => {
|
@@ -2182,38 +2598,43 @@ function waitFor(callback, options = {}) {
|
|
2182
2598
|
let timeoutId;
|
2183
2599
|
let intervalId;
|
2184
2600
|
const onResolve = (result) => {
|
2185
|
-
if (timeoutId)
|
2601
|
+
if (timeoutId) {
|
2186
2602
|
clearTimeout(timeoutId);
|
2187
|
-
|
2603
|
+
}
|
2604
|
+
if (intervalId) {
|
2188
2605
|
clearInterval(intervalId);
|
2606
|
+
}
|
2189
2607
|
resolve(result);
|
2190
2608
|
};
|
2191
2609
|
const handleTimeout = () => {
|
2610
|
+
if (intervalId) {
|
2611
|
+
clearInterval(intervalId);
|
2612
|
+
}
|
2192
2613
|
let error = lastError;
|
2193
|
-
if (!error)
|
2614
|
+
if (!error) {
|
2194
2615
|
error = copyStackTrace(new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
|
2616
|
+
}
|
2195
2617
|
reject(error);
|
2196
2618
|
};
|
2197
2619
|
const checkCallback = () => {
|
2198
|
-
if (vi.isFakeTimers())
|
2620
|
+
if (vi.isFakeTimers()) {
|
2199
2621
|
vi.advanceTimersByTime(interval);
|
2200
|
-
|
2622
|
+
}
|
2623
|
+
if (promiseStatus === "pending") {
|
2201
2624
|
return;
|
2625
|
+
}
|
2202
2626
|
try {
|
2203
2627
|
const result = callback();
|
2204
2628
|
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
2205
2629
|
const thenable = result;
|
2206
2630
|
promiseStatus = "pending";
|
2207
|
-
thenable.then(
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
2212
|
-
|
2213
|
-
|
2214
|
-
lastError = rejectedValue;
|
2215
|
-
}
|
2216
|
-
);
|
2631
|
+
thenable.then((resolvedValue) => {
|
2632
|
+
promiseStatus = "resolved";
|
2633
|
+
onResolve(resolvedValue);
|
2634
|
+
}, (rejectedValue) => {
|
2635
|
+
promiseStatus = "rejected";
|
2636
|
+
lastError = rejectedValue;
|
2637
|
+
});
|
2217
2638
|
} else {
|
2218
2639
|
onResolve(result);
|
2219
2640
|
return true;
|
@@ -2222,14 +2643,15 @@ function waitFor(callback, options = {}) {
|
|
2222
2643
|
lastError = error;
|
2223
2644
|
}
|
2224
2645
|
};
|
2225
|
-
if (checkCallback() === true)
|
2646
|
+
if (checkCallback() === true) {
|
2226
2647
|
return;
|
2648
|
+
}
|
2227
2649
|
timeoutId = setTimeout(handleTimeout, timeout);
|
2228
2650
|
intervalId = setInterval(checkCallback, interval);
|
2229
2651
|
});
|
2230
2652
|
}
|
2231
2653
|
function waitUntil(callback, options = {}) {
|
2232
|
-
const { setTimeout, setInterval, clearTimeout, clearInterval } =
|
2654
|
+
const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2();
|
2233
2655
|
const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
|
2234
2656
|
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
2235
2657
|
return new Promise((resolve, reject) => {
|
@@ -2237,40 +2659,46 @@ function waitUntil(callback, options = {}) {
|
|
2237
2659
|
let timeoutId;
|
2238
2660
|
let intervalId;
|
2239
2661
|
const onReject = (error) => {
|
2240
|
-
if (
|
2662
|
+
if (intervalId) {
|
2663
|
+
clearInterval(intervalId);
|
2664
|
+
}
|
2665
|
+
if (!error) {
|
2241
2666
|
error = copyStackTrace(new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
|
2667
|
+
}
|
2242
2668
|
reject(error);
|
2243
2669
|
};
|
2244
2670
|
const onResolve = (result) => {
|
2245
|
-
if (!result)
|
2671
|
+
if (!result) {
|
2246
2672
|
return;
|
2247
|
-
|
2673
|
+
}
|
2674
|
+
if (timeoutId) {
|
2248
2675
|
clearTimeout(timeoutId);
|
2249
|
-
|
2676
|
+
}
|
2677
|
+
if (intervalId) {
|
2250
2678
|
clearInterval(intervalId);
|
2679
|
+
}
|
2251
2680
|
resolve(result);
|
2252
2681
|
return true;
|
2253
2682
|
};
|
2254
2683
|
const checkCallback = () => {
|
2255
|
-
if (vi.isFakeTimers())
|
2684
|
+
if (vi.isFakeTimers()) {
|
2256
2685
|
vi.advanceTimersByTime(interval);
|
2257
|
-
|
2686
|
+
}
|
2687
|
+
if (promiseStatus === "pending") {
|
2258
2688
|
return;
|
2689
|
+
}
|
2259
2690
|
try {
|
2260
2691
|
const result = callback();
|
2261
2692
|
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
2262
2693
|
const thenable = result;
|
2263
2694
|
promiseStatus = "pending";
|
2264
|
-
thenable.then(
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
2268
|
-
|
2269
|
-
(rejectedValue)
|
2270
|
-
|
2271
|
-
onReject(rejectedValue);
|
2272
|
-
}
|
2273
|
-
);
|
2695
|
+
thenable.then((resolvedValue) => {
|
2696
|
+
promiseStatus = "resolved";
|
2697
|
+
onResolve(resolvedValue);
|
2698
|
+
}, (rejectedValue) => {
|
2699
|
+
promiseStatus = "rejected";
|
2700
|
+
onReject(rejectedValue);
|
2701
|
+
});
|
2274
2702
|
} else {
|
2275
2703
|
return onResolve(result);
|
2276
2704
|
}
|
@@ -2278,51 +2706,43 @@ function waitUntil(callback, options = {}) {
|
|
2278
2706
|
onReject(error);
|
2279
2707
|
}
|
2280
2708
|
};
|
2281
|
-
if (checkCallback() === true)
|
2709
|
+
if (checkCallback() === true) {
|
2282
2710
|
return;
|
2711
|
+
}
|
2283
2712
|
timeoutId = setTimeout(onReject, timeout);
|
2284
2713
|
intervalId = setInterval(checkCallback, interval);
|
2285
2714
|
});
|
2286
2715
|
}
|
2287
2716
|
function createVitest() {
|
2288
|
-
const _mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : new Proxy({}, {
|
2289
|
-
get(_, name) {
|
2290
|
-
throw new Error(
|
2291
|
-
`Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`
|
2292
|
-
);
|
2293
|
-
}
|
2294
|
-
});
|
2295
|
-
let _mockedDate = null;
|
2296
2717
|
let _config = null;
|
2297
2718
|
const workerState = getWorkerState();
|
2298
2719
|
let _timers;
|
2299
|
-
const timers = () => _timers
|
2720
|
+
const timers = () => _timers ||= new FakeTimers({
|
2300
2721
|
global: globalThis,
|
2301
2722
|
config: workerState.config.fakeTimers
|
2302
|
-
})
|
2723
|
+
});
|
2303
2724
|
const _stubsGlobal = /* @__PURE__ */ new Map();
|
2304
2725
|
const _stubsEnv = /* @__PURE__ */ new Map();
|
2305
|
-
const _envBooleans = [
|
2306
|
-
|
2307
|
-
|
2308
|
-
|
2309
|
-
|
2310
|
-
return (stack == null ? void 0 : stack.file) || "";
|
2311
|
-
};
|
2726
|
+
const _envBooleans = [
|
2727
|
+
"PROD",
|
2728
|
+
"DEV",
|
2729
|
+
"SSR"
|
2730
|
+
];
|
2312
2731
|
const utils = {
|
2313
2732
|
useFakeTimers(config) {
|
2314
|
-
var _a, _b, _c, _d;
|
2315
2733
|
if (isChildProcess()) {
|
2316
|
-
if (
|
2317
|
-
throw new Error(
|
2318
|
-
'vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.'
|
2319
|
-
);
|
2734
|
+
if (config?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) {
|
2735
|
+
throw new Error('vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.');
|
2320
2736
|
}
|
2321
2737
|
}
|
2322
|
-
if (config)
|
2323
|
-
timers().configure({
|
2324
|
-
|
2738
|
+
if (config) {
|
2739
|
+
timers().configure({
|
2740
|
+
...workerState.config.fakeTimers,
|
2741
|
+
...config
|
2742
|
+
});
|
2743
|
+
} else {
|
2325
2744
|
timers().configure(workerState.config.fakeTimers);
|
2745
|
+
}
|
2326
2746
|
timers().useFakeTimers();
|
2327
2747
|
return utils;
|
2328
2748
|
},
|
@@ -2331,7 +2751,6 @@ function createVitest() {
|
|
2331
2751
|
},
|
2332
2752
|
useRealTimers() {
|
2333
2753
|
timers().useRealTimers();
|
2334
|
-
_mockedDate = null;
|
2335
2754
|
return utils;
|
2336
2755
|
},
|
2337
2756
|
runOnlyPendingTimers() {
|
@@ -2370,17 +2789,19 @@ function createVitest() {
|
|
2370
2789
|
await timers().advanceTimersToNextTimerAsync();
|
2371
2790
|
return utils;
|
2372
2791
|
},
|
2792
|
+
advanceTimersToNextFrame() {
|
2793
|
+
timers().advanceTimersToNextFrame();
|
2794
|
+
return utils;
|
2795
|
+
},
|
2373
2796
|
getTimerCount() {
|
2374
2797
|
return timers().getTimerCount();
|
2375
2798
|
},
|
2376
2799
|
setSystemTime(time) {
|
2377
|
-
|
2378
|
-
_mockedDate = date;
|
2379
|
-
timers().setSystemTime(date);
|
2800
|
+
timers().setSystemTime(time);
|
2380
2801
|
return utils;
|
2381
2802
|
},
|
2382
2803
|
getMockedSystemTime() {
|
2383
|
-
return
|
2804
|
+
return timers().getMockedSystemTime();
|
2384
2805
|
},
|
2385
2806
|
getRealSystemTime() {
|
2386
2807
|
return timers().getRealSystemTime();
|
@@ -2389,7 +2810,6 @@ function createVitest() {
|
|
2389
2810
|
timers().clearAllTimers();
|
2390
2811
|
return utils;
|
2391
2812
|
},
|
2392
|
-
// mocks
|
2393
2813
|
spyOn,
|
2394
2814
|
fn,
|
2395
2815
|
waitFor,
|
@@ -2399,40 +2819,37 @@ function createVitest() {
|
|
2399
2819
|
return factory();
|
2400
2820
|
},
|
2401
2821
|
mock(path, factory) {
|
2402
|
-
|
2403
|
-
|
2404
|
-
|
2405
|
-
|
2406
|
-
|
2407
|
-
true
|
2408
|
-
);
|
2822
|
+
if (typeof path !== "string") {
|
2823
|
+
throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
|
2824
|
+
}
|
2825
|
+
const importer = getImporter("mock");
|
2826
|
+
_mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
|
2409
2827
|
},
|
2410
2828
|
unmock(path) {
|
2411
|
-
|
2829
|
+
if (typeof path !== "string") {
|
2830
|
+
throw new TypeError(`vi.unmock() expects a string path, but received a ${typeof path}`);
|
2831
|
+
}
|
2832
|
+
_mocker().queueUnmock(path, getImporter("unmock"));
|
2412
2833
|
},
|
2413
2834
|
doMock(path, factory) {
|
2414
|
-
|
2415
|
-
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
false
|
2420
|
-
);
|
2835
|
+
if (typeof path !== "string") {
|
2836
|
+
throw new TypeError(`vi.doMock() expects a string path, but received a ${typeof path}`);
|
2837
|
+
}
|
2838
|
+
const importer = getImporter("doMock");
|
2839
|
+
_mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
|
2421
2840
|
},
|
2422
2841
|
doUnmock(path) {
|
2423
|
-
|
2842
|
+
if (typeof path !== "string") {
|
2843
|
+
throw new TypeError(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
|
2844
|
+
}
|
2845
|
+
_mocker().queueUnmock(path, getImporter("doUnmock"));
|
2424
2846
|
},
|
2425
2847
|
async importActual(path) {
|
2426
|
-
return _mocker.importActual(
|
2427
|
-
path,
|
2428
|
-
getImporter(),
|
2429
|
-
_mocker.getMockContext().callstack
|
2430
|
-
);
|
2848
|
+
return _mocker().importActual(path, getImporter("importActual"), _mocker().getMockContext().callstack);
|
2431
2849
|
},
|
2432
2850
|
async importMock(path) {
|
2433
|
-
return _mocker.importMock(path, getImporter());
|
2851
|
+
return _mocker().importMock(path, getImporter("importMock"));
|
2434
2852
|
},
|
2435
|
-
// this is typed in the interface so it's not necessary to type it here
|
2436
2853
|
mocked(item, _options = {}) {
|
2437
2854
|
return item;
|
2438
2855
|
},
|
@@ -2440,20 +2857,21 @@ function createVitest() {
|
|
2440
2857
|
return isMockFunction(fn2);
|
2441
2858
|
},
|
2442
2859
|
clearAllMocks() {
|
2443
|
-
mocks.forEach((spy) => spy.mockClear());
|
2860
|
+
[...mocks].reverse().forEach((spy) => spy.mockClear());
|
2444
2861
|
return utils;
|
2445
2862
|
},
|
2446
2863
|
resetAllMocks() {
|
2447
|
-
mocks.forEach((spy) => spy.mockReset());
|
2864
|
+
[...mocks].reverse().forEach((spy) => spy.mockReset());
|
2448
2865
|
return utils;
|
2449
2866
|
},
|
2450
2867
|
restoreAllMocks() {
|
2451
|
-
mocks.forEach((spy) => spy.mockRestore());
|
2868
|
+
[...mocks].reverse().forEach((spy) => spy.mockRestore());
|
2452
2869
|
return utils;
|
2453
2870
|
},
|
2454
2871
|
stubGlobal(name, value) {
|
2455
|
-
if (!_stubsGlobal.has(name))
|
2872
|
+
if (!_stubsGlobal.has(name)) {
|
2456
2873
|
_stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
|
2874
|
+
}
|
2457
2875
|
Object.defineProperty(globalThis, name, {
|
2458
2876
|
value,
|
2459
2877
|
writable: true,
|
@@ -2463,30 +2881,36 @@ function createVitest() {
|
|
2463
2881
|
return utils;
|
2464
2882
|
},
|
2465
2883
|
stubEnv(name, value) {
|
2466
|
-
if (!_stubsEnv.has(name))
|
2884
|
+
if (!_stubsEnv.has(name)) {
|
2467
2885
|
_stubsEnv.set(name, process.env[name]);
|
2468
|
-
|
2886
|
+
}
|
2887
|
+
if (_envBooleans.includes(name)) {
|
2469
2888
|
process.env[name] = value ? "1" : "";
|
2470
|
-
else
|
2889
|
+
} else if (value === void 0) {
|
2890
|
+
delete process.env[name];
|
2891
|
+
} else {
|
2471
2892
|
process.env[name] = String(value);
|
2893
|
+
}
|
2472
2894
|
return utils;
|
2473
2895
|
},
|
2474
2896
|
unstubAllGlobals() {
|
2475
2897
|
_stubsGlobal.forEach((original, name) => {
|
2476
|
-
if (!original)
|
2898
|
+
if (!original) {
|
2477
2899
|
Reflect.deleteProperty(globalThis, name);
|
2478
|
-
else
|
2900
|
+
} else {
|
2479
2901
|
Object.defineProperty(globalThis, name, original);
|
2902
|
+
}
|
2480
2903
|
});
|
2481
2904
|
_stubsGlobal.clear();
|
2482
2905
|
return utils;
|
2483
2906
|
},
|
2484
2907
|
unstubAllEnvs() {
|
2485
2908
|
_stubsEnv.forEach((original, name) => {
|
2486
|
-
if (original === void 0)
|
2909
|
+
if (original === void 0) {
|
2487
2910
|
delete process.env[name];
|
2488
|
-
else
|
2911
|
+
} else {
|
2489
2912
|
process.env[name] = original;
|
2913
|
+
}
|
2490
2914
|
});
|
2491
2915
|
_stubsEnv.clear();
|
2492
2916
|
return utils;
|
@@ -2499,130 +2923,48 @@ function createVitest() {
|
|
2499
2923
|
return waitForImportsToResolve();
|
2500
2924
|
},
|
2501
2925
|
setConfig(config) {
|
2502
|
-
if (!_config)
|
2926
|
+
if (!_config) {
|
2503
2927
|
_config = { ...workerState.config };
|
2928
|
+
}
|
2504
2929
|
Object.assign(workerState.config, config);
|
2505
2930
|
},
|
2506
2931
|
resetConfig() {
|
2507
|
-
if (_config)
|
2932
|
+
if (_config) {
|
2508
2933
|
Object.assign(workerState.config, _config);
|
2934
|
+
}
|
2509
2935
|
}
|
2510
2936
|
};
|
2511
2937
|
return utils;
|
2512
2938
|
}
|
2513
2939
|
var vitest = createVitest();
|
2514
2940
|
var vi = vitest;
|
2941
|
+
function _mocker() {
|
2942
|
+
return typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : new Proxy({}, { get(_, name) {
|
2943
|
+
throw new Error(`Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`);
|
2944
|
+
} });
|
2945
|
+
}
|
2946
|
+
function getImporter(name) {
|
2947
|
+
const stackTrace = createSimpleStackTrace({ stackTraceLimit: 5 });
|
2948
|
+
const stackArray = stackTrace.split("\n");
|
2949
|
+
const importerStackIndex = stackArray.findIndex((stack2) => {
|
2950
|
+
return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
|
2951
|
+
});
|
2952
|
+
const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
|
2953
|
+
return stack?.file || "";
|
2954
|
+
}
|
2515
2955
|
|
2516
|
-
// ../../node_modules/.pnpm/vitest@1.
|
2956
|
+
// ../../node_modules/.pnpm/vitest@3.1.1_@types+debug@4.1.12_@types+node@22.14.0_jiti@2.4.2_lightningcss@1.29.2_terser@5.39.0_tsx@4.19.3_yaml@2.7.1/node_modules/vitest/dist/index.js
|
2957
|
+
import { expectTypeOf } from "expect-type.mjs";
|
2517
2958
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from "@vitest/runner.mjs";
|
2518
2959
|
import * as chai2 from "chai.mjs";
|
2519
2960
|
import { assert as assert2, should } from "chai.mjs";
|
2520
|
-
|
2521
|
-
return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
|
2522
|
-
}
|
2523
|
-
function isWatchMode() {
|
2524
|
-
return getRunningMode() === "watch";
|
2525
|
-
}
|
2526
|
-
function inject(key) {
|
2527
|
-
const workerState = getWorkerState();
|
2528
|
-
return workerState.providedContext[key];
|
2529
|
-
}
|
2530
|
-
var dist = {};
|
2531
|
-
(function(exports) {
|
2532
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
2533
|
-
exports.expectTypeOf = void 0;
|
2534
|
-
const fn2 = () => true;
|
2535
|
-
const expectTypeOf2 = (_actual) => {
|
2536
|
-
const nonFunctionProperties = [
|
2537
|
-
"parameters",
|
2538
|
-
"returns",
|
2539
|
-
"resolves",
|
2540
|
-
"not",
|
2541
|
-
"items",
|
2542
|
-
"constructorParameters",
|
2543
|
-
"thisParameter",
|
2544
|
-
"instance",
|
2545
|
-
"guards",
|
2546
|
-
"asserts",
|
2547
|
-
"branded"
|
2548
|
-
];
|
2549
|
-
const obj = {
|
2550
|
-
/* eslint-disable mmkal/@typescript-eslint/no-unsafe-assignment */
|
2551
|
-
toBeAny: fn2,
|
2552
|
-
toBeUnknown: fn2,
|
2553
|
-
toBeNever: fn2,
|
2554
|
-
toBeFunction: fn2,
|
2555
|
-
toBeObject: fn2,
|
2556
|
-
toBeArray: fn2,
|
2557
|
-
toBeString: fn2,
|
2558
|
-
toBeNumber: fn2,
|
2559
|
-
toBeBoolean: fn2,
|
2560
|
-
toBeVoid: fn2,
|
2561
|
-
toBeSymbol: fn2,
|
2562
|
-
toBeNull: fn2,
|
2563
|
-
toBeUndefined: fn2,
|
2564
|
-
toBeNullable: fn2,
|
2565
|
-
toMatchTypeOf: fn2,
|
2566
|
-
toEqualTypeOf: fn2,
|
2567
|
-
toBeCallableWith: fn2,
|
2568
|
-
toBeConstructibleWith: fn2,
|
2569
|
-
/* eslint-enable mmkal/@typescript-eslint/no-unsafe-assignment */
|
2570
|
-
extract: exports.expectTypeOf,
|
2571
|
-
exclude: exports.expectTypeOf,
|
2572
|
-
toHaveProperty: exports.expectTypeOf,
|
2573
|
-
parameter: exports.expectTypeOf
|
2574
|
-
};
|
2575
|
-
const getterProperties = nonFunctionProperties;
|
2576
|
-
getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
|
2577
|
-
return obj;
|
2578
|
-
};
|
2579
|
-
exports.expectTypeOf = expectTypeOf2;
|
2580
|
-
})(dist);
|
2581
|
-
function noop2() {
|
2582
|
-
}
|
2583
|
-
var assertType = noop2;
|
2584
|
-
var VitestIndex = /* @__PURE__ */ Object.freeze({
|
2585
|
-
__proto__: null,
|
2586
|
-
afterAll,
|
2587
|
-
afterEach,
|
2588
|
-
assert: assert2,
|
2589
|
-
assertType,
|
2590
|
-
beforeAll,
|
2591
|
-
beforeEach,
|
2592
|
-
bench,
|
2593
|
-
chai: chai2,
|
2594
|
-
createExpect,
|
2595
|
-
describe,
|
2596
|
-
expect: globalExpect,
|
2597
|
-
expectTypeOf: dist.expectTypeOf,
|
2598
|
-
getRunningMode,
|
2599
|
-
inject,
|
2600
|
-
isFirstRun,
|
2601
|
-
isWatchMode,
|
2602
|
-
it,
|
2603
|
-
onTestFailed,
|
2604
|
-
onTestFinished,
|
2605
|
-
runOnce,
|
2606
|
-
should,
|
2607
|
-
suite,
|
2608
|
-
test,
|
2609
|
-
vi,
|
2610
|
-
vitest
|
2611
|
-
});
|
2612
|
-
|
2613
|
-
// ../../node_modules/.pnpm/vitest@1.6.1_@types+node@22.13.1_lightningcss@1.29.1_terser@5.38.1/node_modules/vitest/dist/index.js
|
2614
|
-
import * as chai3 from "chai.mjs";
|
2615
|
-
import { assert as assert3, should as should2 } from "chai.mjs";
|
2961
|
+
import "@vitest/expect.mjs";
|
2616
2962
|
import "@vitest/runner/utils.mjs";
|
2617
2963
|
import "@vitest/utils.mjs";
|
2618
|
-
import "pathe.mjs";
|
2619
|
-
import "std-env.mjs";
|
2620
|
-
import "@vitest/expect.mjs";
|
2621
2964
|
import "@vitest/snapshot.mjs";
|
2622
2965
|
import "@vitest/utils/error.mjs";
|
2623
|
-
import "@vitest/utils/source-map.mjs";
|
2624
2966
|
import "@vitest/spy.mjs";
|
2625
|
-
|
2967
|
+
import "@vitest/utils/source-map.mjs";
|
2626
2968
|
|
2627
2969
|
// src/tests/setup.ts
|
2628
2970
|
var OriginalDate = global.Date;
|