@accelint/design-system 0.4.0 → 0.5.0
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/README.md +12 -12
- package/dist/components/aria/aria.js.map +1 -1
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +1 -1
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/types.d.ts +1 -1
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/chip/chip.d.ts +1 -1
- package/dist/components/chip/chip.js.map +1 -1
- package/dist/components/chip/types.d.ts +1 -1
- package/dist/components/collection/collection.js.map +1 -1
- package/dist/components/combo-box/combo-box.d.ts +1 -1
- package/dist/components/combo-box/combo-box.js.map +1 -1
- package/dist/components/combo-box/types.d.ts +1 -1
- package/dist/components/dialog/dialog.d.ts +1 -1
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/types.d.ts +1 -1
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/drawer.js +4 -3
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/drawer/types.d.ts +2 -2
- package/dist/components/element/element.js.map +1 -1
- package/dist/components/group/group.d.ts +1 -1
- package/dist/components/group/group.js.map +1 -1
- package/dist/components/group/types.d.ts +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/types.d.ts +1 -1
- package/dist/components/input/input.css.d.ts +1 -1
- package/dist/components/input/input.d.ts +4 -4
- package/dist/components/input/input.js +3 -3
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/input/types.d.ts +1 -1
- package/dist/components/menu/index.d.ts +1 -1
- package/dist/components/menu/menu.css.d.ts +1 -1
- package/dist/components/menu/menu.d.ts +2 -2
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/menu/types.d.ts +2 -2
- package/dist/components/merge-provider/merge-provider.js +2 -2
- package/dist/components/merge-provider/merge-provider.js.map +1 -1
- package/dist/components/number-field/number-field.d.ts +1 -1
- package/dist/components/number-field/types.d.ts +1 -1
- package/dist/components/options/index.d.ts +1 -1
- package/dist/components/options/options.css.d.ts +1 -1
- package/dist/components/options/options.d.ts +2 -2
- package/dist/components/options/options.js.map +1 -1
- package/dist/components/options/types.d.ts +2 -2
- package/dist/components/picker/picker.d.ts +1 -1
- package/dist/components/picker/picker.js +2 -2
- package/dist/components/picker/picker.js.map +1 -1
- package/dist/components/picker/types.d.ts +1 -1
- package/dist/components/popover/popover.d.ts +1 -1
- package/dist/components/popover/popover.js +2 -2
- package/dist/components/popover/popover.js.map +1 -1
- package/dist/components/query-builder/dataset-sample.js +8 -24
- package/dist/components/query-builder/dataset-sample.js.map +1 -1
- package/dist/components/query-builder/group.js +1 -1
- package/dist/components/query-builder/group.js.map +1 -1
- package/dist/components/query-builder/query-builder.js +2 -2
- package/dist/components/query-builder/query-builder.js.map +1 -1
- package/dist/components/query-builder/rule.js.map +1 -1
- package/dist/components/query-builder/types.d.ts +3 -3
- package/dist/components/query-builder/utils.d.ts +1 -1
- package/dist/components/query-builder/utils.js.map +1 -1
- package/dist/components/query-builder/value-editor.js +1 -1
- package/dist/components/query-builder/value-editor.js.map +1 -1
- package/dist/components/query-builder/value-selector.js.map +1 -1
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radio/types.d.ts +1 -1
- package/dist/components/search-field/index.d.ts +1 -1
- package/dist/components/search-field/search-field.d.ts +1 -1
- package/dist/components/search-field/types.d.ts +1 -1
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/tabs/tabs.css.d.ts +2 -2
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +2 -2
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tabs/types.d.ts +3 -3
- package/dist/components/text-field/text-field.d.ts +5 -4
- package/dist/components/text-field/types.d.ts +1 -1
- package/dist/components/textarea/textarea.css.d.ts +1 -1
- package/dist/components/textarea/textarea.d.ts +4 -4
- package/dist/components/textarea/textarea.js +5 -5
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/textarea/types.d.ts +2 -2
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +3 -3
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/tree/tree.css.d.ts +1 -0
- package/dist/components/tree/tree.css.js +2 -2
- package/dist/components/tree/tree.css.js.map +1 -1
- package/dist/components/tree/tree.d.ts +1 -1
- package/dist/components/tree/tree.js +5 -2
- package/dist/components/tree/tree.js.map +1 -1
- package/dist/components/tree/types.d.ts +4 -4
- package/dist/components/tree/utils.js.map +1 -1
- package/dist/hooks/use-collection-render/use-collection-render.js +1 -0
- package/dist/hooks/use-collection-render/use-collection-render.js.map +1 -1
- package/dist/hooks/use-defaults/use-defaults.d.ts +1 -1
- package/dist/hooks/use-slot/use-slot.js +3 -3
- package/dist/hooks/use-slot/use-slot.js.map +1 -1
- package/dist/hooks/use-theme/types.d.ts +1 -1
- package/dist/hooks/use-theme/use-theme.d.ts +18 -1
- package/dist/hooks/use-theme/use-theme.js.map +1 -1
- package/dist/hooks/use-tree/index.d.ts +1 -1
- package/dist/hooks/use-tree/use-tree.d.ts +1 -1
- package/dist/hooks/use-tree/use-tree.js +10 -5
- package/dist/hooks/use-tree/use-tree.js.map +1 -1
- package/dist/hooks/use-tree/utils.d.ts +1 -1
- package/dist/hooks/use-tree/utils.js +3 -4
- package/dist/hooks/use-tree/utils.js.map +1 -1
- package/dist/index.css +34 -31
- package/dist/ladle/actions.js.map +1 -1
- package/dist/test/setup.js +347 -331
- package/dist/test/setup.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react-aria.d.ts +1 -1
- package/dist/types/react.d.d.ts +16 -0
- package/dist/types/use-tree.d.ts +2 -1
- package/dist/utils/css.d.ts +2 -2
- package/dist/utils/css.js +5 -5
- package/dist/utils/css.js.map +1 -1
- package/dist/utils/props.js +5 -6
- package/dist/utils/props.js.map +1 -1
- package/dist/utils/validators.d.ts +2 -2
- package/dist/utils/validators.js.map +1 -1
- package/package.json +60 -57
package/dist/test/setup.js
CHANGED
|
@@ -12,18 +12,20 @@ import 'react-dom';
|
|
|
12
12
|
import 'react-dom/client';
|
|
13
13
|
import * as prettyFormat from 'pretty-format.js';
|
|
14
14
|
import lzString from 'lz-string.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
15
|
+
import { test, suite, onTestFinished, onTestFailed, it, describe, beforeEach, beforeAll as beforeAll$1, afterEach as afterEach$1, afterAll as afterAll$1, getCurrentSuite, getCurrentTest } from '@vitest/runner.js';
|
|
16
|
+
import { createChainable, getNames } from '@vitest/runner/utils.js';
|
|
17
|
+
import { noop, getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils.js';
|
|
18
|
+
import 'pathe.js';
|
|
18
19
|
import * as chai$1 from 'chai.js';
|
|
19
|
-
import {
|
|
20
|
+
import { should, assert } from 'chai.js';
|
|
21
|
+
import { JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, equals, iterableEquality, subsetEquality } from '@vitest/expect.js';
|
|
20
22
|
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot.js';
|
|
21
23
|
import '@vitest/utils/error.js';
|
|
22
24
|
import { parseSingleStack } from '@vitest/utils/source-map.js';
|
|
23
|
-
import { spyOn,
|
|
24
|
-
import '
|
|
25
|
+
import { fn, spyOn, mocks, isMockFunction } from '@vitest/spy.js';
|
|
26
|
+
import 'std-env.js';
|
|
25
27
|
|
|
26
|
-
// ../../node_modules/.pnpm/@testing-library+jest-dom@6.
|
|
28
|
+
// ../../node_modules/.pnpm/@testing-library+jest-dom@6.5.0/node_modules/@testing-library/jest-dom/dist/matchers.mjs
|
|
27
29
|
var matchers_exports = {};
|
|
28
30
|
__export(matchers_exports, {
|
|
29
31
|
toBeChecked: () => toBeChecked,
|
|
@@ -51,7 +53,6 @@ __export(matchers_exports, {
|
|
|
51
53
|
toHaveFocus: () => toHaveFocus,
|
|
52
54
|
toHaveFormValues: () => toHaveFormValues,
|
|
53
55
|
toHaveRole: () => toHaveRole,
|
|
54
|
-
toHaveSelection: () => toHaveSelection,
|
|
55
56
|
toHaveStyle: () => toHaveStyle,
|
|
56
57
|
toHaveTextContent: () => toHaveTextContent,
|
|
57
58
|
toHaveValue: () => toHaveValue
|
|
@@ -1356,75 +1357,6 @@ function toHaveErrorMessage(htmlElement, checkWith) {
|
|
|
1356
1357
|
}
|
|
1357
1358
|
};
|
|
1358
1359
|
}
|
|
1359
|
-
function getSelection(element) {
|
|
1360
|
-
const selection = element.ownerDocument.getSelection();
|
|
1361
|
-
if (["input", "textarea"].includes(element.tagName.toLowerCase())) {
|
|
1362
|
-
if (["radio", "checkbox"].includes(element.type)) return "";
|
|
1363
|
-
return element.value.toString().substring(element.selectionStart, element.selectionEnd);
|
|
1364
|
-
}
|
|
1365
|
-
if (selection.anchorNode === null || selection.focusNode === null) {
|
|
1366
|
-
return "";
|
|
1367
|
-
}
|
|
1368
|
-
const originalRange = selection.getRangeAt(0);
|
|
1369
|
-
const temporaryRange = element.ownerDocument.createRange();
|
|
1370
|
-
if (selection.containsNode(element, false)) {
|
|
1371
|
-
temporaryRange.selectNodeContents(element);
|
|
1372
|
-
selection.removeAllRanges();
|
|
1373
|
-
selection.addRange(temporaryRange);
|
|
1374
|
-
} else if (element.contains(selection.anchorNode) && element.contains(selection.focusNode)) ;
|
|
1375
|
-
else {
|
|
1376
|
-
const selectionStartsWithinElement = element === originalRange.startContainer || element.contains(originalRange.startContainer);
|
|
1377
|
-
const selectionEndsWithinElement = element === originalRange.endContainer || element.contains(originalRange.endContainer);
|
|
1378
|
-
selection.removeAllRanges();
|
|
1379
|
-
if (selectionStartsWithinElement || selectionEndsWithinElement) {
|
|
1380
|
-
temporaryRange.selectNodeContents(element);
|
|
1381
|
-
if (selectionStartsWithinElement) {
|
|
1382
|
-
temporaryRange.setStart(
|
|
1383
|
-
originalRange.startContainer,
|
|
1384
|
-
originalRange.startOffset
|
|
1385
|
-
);
|
|
1386
|
-
}
|
|
1387
|
-
if (selectionEndsWithinElement) {
|
|
1388
|
-
temporaryRange.setEnd(
|
|
1389
|
-
originalRange.endContainer,
|
|
1390
|
-
originalRange.endOffset
|
|
1391
|
-
);
|
|
1392
|
-
}
|
|
1393
|
-
selection.addRange(temporaryRange);
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
|
-
const result = selection.toString();
|
|
1397
|
-
selection.removeAllRanges();
|
|
1398
|
-
selection.addRange(originalRange);
|
|
1399
|
-
return result;
|
|
1400
|
-
}
|
|
1401
|
-
function toHaveSelection(htmlElement, expectedSelection) {
|
|
1402
|
-
checkHtmlElement(htmlElement, toHaveSelection, this);
|
|
1403
|
-
const expectsSelection = expectedSelection !== void 0;
|
|
1404
|
-
if (expectsSelection && typeof expectedSelection !== "string") {
|
|
1405
|
-
throw new Error(`expected selection must be a string or undefined`);
|
|
1406
|
-
}
|
|
1407
|
-
const receivedSelection = getSelection(htmlElement);
|
|
1408
|
-
return {
|
|
1409
|
-
pass: expectsSelection ? isEqualWith(receivedSelection, expectedSelection, compareArraysAsSet) : Boolean(receivedSelection),
|
|
1410
|
-
message: () => {
|
|
1411
|
-
const to = this.isNot ? "not to" : "to";
|
|
1412
|
-
const matcher = this.utils.matcherHint(
|
|
1413
|
-
`${this.isNot ? ".not" : ""}.toHaveSelection`,
|
|
1414
|
-
"element",
|
|
1415
|
-
expectedSelection
|
|
1416
|
-
);
|
|
1417
|
-
return getMessage(
|
|
1418
|
-
this,
|
|
1419
|
-
matcher,
|
|
1420
|
-
`Expected the element ${to} have selection`,
|
|
1421
|
-
expectsSelection ? expectedSelection : "(any)",
|
|
1422
|
-
"Received",
|
|
1423
|
-
receivedSelection
|
|
1424
|
-
);
|
|
1425
|
-
}
|
|
1426
|
-
};
|
|
1427
|
-
}
|
|
1428
1360
|
function escapeHTML(str) {
|
|
1429
1361
|
return str.replace(/</g, "<").replace(/>/g, ">");
|
|
1430
1362
|
}
|
|
@@ -2145,7 +2077,7 @@ function makeSuggestion(queryName, element, content, _ref) {
|
|
|
2145
2077
|
};
|
|
2146
2078
|
}
|
|
2147
2079
|
function canSuggest(currentMethod, requestedMethod, data) {
|
|
2148
|
-
return data && (
|
|
2080
|
+
return data && (true);
|
|
2149
2081
|
}
|
|
2150
2082
|
function getSuggestedQuery(element, variant, method) {
|
|
2151
2083
|
var _element$getAttribute, _getImplicitAriaRoles;
|
|
@@ -3877,7 +3809,7 @@ typeof document !== "undefined" && document.body ? getQueriesForElement(document
|
|
|
3877
3809
|
return helpers;
|
|
3878
3810
|
}, initialValue);
|
|
3879
3811
|
|
|
3880
|
-
// ../../node_modules/.pnpm/@testing-library+react@16.0.1_@testing-library+dom@10.4.0_@types+react-dom@18.3.1_@types+
|
|
3812
|
+
// ../../node_modules/.pnpm/@testing-library+react@16.0.1_@testing-library+dom@10.4.0_@types+react-dom@18.3.1_@types+reac_22rmz7z5hut5bauznyeu5nmbnq/node_modules/@testing-library/react/dist/@testing-library/react.esm.js
|
|
3881
3813
|
var reactAct = typeof React.act === "function" ? React.act : DeprecatedReactTestUtils.act;
|
|
3882
3814
|
function getGlobalThis() {
|
|
3883
3815
|
if (typeof globalThis !== "undefined") {
|
|
@@ -4022,9 +3954,10 @@ if (typeof process === "undefined" || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
|
|
|
4022
3954
|
});
|
|
4023
3955
|
}
|
|
4024
3956
|
}
|
|
4025
|
-
|
|
3957
|
+
|
|
3958
|
+
// ../../node_modules/.pnpm/vitest@2.1.3_@types+node@20.17.19_jsdom@25.0.1_msw@2.7.0_@types+node@20.17.19_typescript@5.6.3__terser@5.39.0/node_modules/vitest/dist/chunks/utils.Ck2hJTRs.js
|
|
4026
3959
|
function getWorkerState() {
|
|
4027
|
-
const workerState = globalThis
|
|
3960
|
+
const workerState = globalThis.__vitest_worker__;
|
|
4028
3961
|
if (!workerState) {
|
|
4029
3962
|
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';
|
|
4030
3963
|
throw new Error(errorMsg);
|
|
@@ -4035,59 +3968,80 @@ function getCurrentEnvironment() {
|
|
|
4035
3968
|
const state = getWorkerState();
|
|
4036
3969
|
return state?.environment.name;
|
|
4037
3970
|
}
|
|
4038
|
-
|
|
4039
|
-
|
|
3971
|
+
|
|
3972
|
+
// ../../node_modules/.pnpm/vitest@2.1.3_@types+node@20.17.19_jsdom@25.0.1_msw@2.7.0_@types+node@20.17.19_typescript@5.6.3__terser@5.39.0/node_modules/vitest/dist/chunks/index.CxRxs566.js
|
|
3973
|
+
function getRunMode() {
|
|
3974
|
+
return getWorkerState().config.mode;
|
|
4040
3975
|
}
|
|
4041
|
-
function
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
3976
|
+
function isRunningInBenchmark() {
|
|
3977
|
+
return getRunMode() === "benchmark";
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
// ../../node_modules/.pnpm/vitest@2.1.3_@types+node@20.17.19_jsdom@25.0.1_msw@2.7.0_@types+node@20.17.19_typescript@5.6.3__terser@5.39.0/node_modules/vitest/dist/chunks/benchmark.C8CRJYG4.js
|
|
3981
|
+
var benchFns = /* @__PURE__ */ new WeakMap();
|
|
3982
|
+
var benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
3983
|
+
var bench = createBenchmark(function(name, fn2 = noop, options = {}) {
|
|
3984
|
+
if (!isRunningInBenchmark()) {
|
|
3985
|
+
throw new Error("`bench()` is only available in benchmark mode.");
|
|
3986
|
+
}
|
|
3987
|
+
const task = getCurrentSuite().task(formatName(name), {
|
|
3988
|
+
...this,
|
|
3989
|
+
meta: {
|
|
3990
|
+
benchmark: true
|
|
4056
3991
|
}
|
|
4057
|
-
modules.invalidateModule(mod);
|
|
4058
3992
|
});
|
|
3993
|
+
benchFns.set(task, fn2);
|
|
3994
|
+
benchOptsMap.set(task, options);
|
|
3995
|
+
});
|
|
3996
|
+
function createBenchmark(fn2) {
|
|
3997
|
+
const benchmark = createChainable(
|
|
3998
|
+
["skip", "only", "todo"],
|
|
3999
|
+
fn2
|
|
4000
|
+
);
|
|
4001
|
+
benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
|
|
4002
|
+
benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
|
|
4003
|
+
return benchmark;
|
|
4059
4004
|
}
|
|
4060
|
-
function
|
|
4061
|
-
|
|
4062
|
-
return new Promise((resolve) => setTimeout2(resolve, 0));
|
|
4005
|
+
function formatName(name) {
|
|
4006
|
+
return typeof name === "string" ? name : name instanceof Function ? name.name || "<anonymous>" : String(name);
|
|
4063
4007
|
}
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4008
|
+
|
|
4009
|
+
// ../../node_modules/.pnpm/vitest@2.1.3_@types+node@20.17.19_jsdom@25.0.1_msw@2.7.0_@types+node@20.17.19_typescript@5.6.3__terser@5.39.0/node_modules/vitest/dist/chunks/run-once.Sxe67Wng.js
|
|
4010
|
+
var filesCount = /* @__PURE__ */ new Map();
|
|
4011
|
+
var cache = /* @__PURE__ */ new Map();
|
|
4012
|
+
function runOnce(fn2, key) {
|
|
4013
|
+
const filepath = getWorkerState().filepath || "__unknown_files__";
|
|
4014
|
+
if (!key) {
|
|
4015
|
+
filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
|
|
4016
|
+
key = String(filesCount.get(filepath));
|
|
4017
|
+
}
|
|
4018
|
+
const id = `${filepath}:${key}`;
|
|
4019
|
+
if (!cache.has(id)) {
|
|
4020
|
+
cache.set(id, fn2());
|
|
4021
|
+
}
|
|
4022
|
+
return cache.get(id);
|
|
4023
|
+
}
|
|
4024
|
+
function isFirstRun() {
|
|
4025
|
+
let firstRun = false;
|
|
4026
|
+
runOnce(() => {
|
|
4027
|
+
firstRun = true;
|
|
4028
|
+
}, "__vitest_first_run__");
|
|
4029
|
+
return firstRun;
|
|
4082
4030
|
}
|
|
4083
4031
|
|
|
4084
|
-
// ../../node_modules/.pnpm/vitest@2.1.
|
|
4032
|
+
// ../../node_modules/.pnpm/vitest@2.1.3_@types+node@20.17.19_jsdom@25.0.1_msw@2.7.0_@types+node@20.17.19_typescript@5.6.3__terser@5.39.0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
|
|
4085
4033
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
4086
4034
|
function getDefaultExportFromCjs(x) {
|
|
4087
4035
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
4088
4036
|
}
|
|
4037
|
+
function getTestName(task, separator = " > ") {
|
|
4038
|
+
return getNames(task).slice(1).join(separator);
|
|
4039
|
+
}
|
|
4040
|
+
function isChildProcess() {
|
|
4041
|
+
return typeof process !== "undefined" && !!process.send;
|
|
4042
|
+
}
|
|
4089
4043
|
|
|
4090
|
-
// ../../node_modules/.pnpm/vitest@2.1.
|
|
4044
|
+
// ../../node_modules/.pnpm/vitest@2.1.3_@types+node@20.17.19_jsdom@25.0.1_msw@2.7.0_@types+node@20.17.19_typescript@5.6.3__terser@5.39.0/node_modules/vitest/dist/chunks/date.W2xKR2qe.js
|
|
4091
4045
|
var RealDate = Date;
|
|
4092
4046
|
var now = null;
|
|
4093
4047
|
var MockDate = class _MockDate extends RealDate {
|
|
@@ -4139,130 +4093,47 @@ function mockDate(date) {
|
|
|
4139
4093
|
function resetDate() {
|
|
4140
4094
|
globalThis.Date = RealDate;
|
|
4141
4095
|
}
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
// these are not supported because you can call them without `.poll`,
|
|
4158
|
-
// we throw an error inside the rejects/resolves methods to prevent this
|
|
4159
|
-
// rejects,
|
|
4160
|
-
// resolves
|
|
4161
|
-
];
|
|
4162
|
-
function createExpectPoll(expect2) {
|
|
4163
|
-
return function poll(fn2, options = {}) {
|
|
4164
|
-
const state = getWorkerState();
|
|
4165
|
-
const defaults = state.config.expect?.poll ?? {};
|
|
4166
|
-
const {
|
|
4167
|
-
interval = defaults.interval ?? 50,
|
|
4168
|
-
timeout = defaults.timeout ?? 1e3,
|
|
4169
|
-
message
|
|
4170
|
-
} = options;
|
|
4171
|
-
const assertion = expect2(null, message).withContext({
|
|
4172
|
-
poll: true
|
|
4173
|
-
});
|
|
4174
|
-
fn2 = fn2.bind(assertion);
|
|
4175
|
-
const test2 = chai$1.util.flag(assertion, "vitest-test");
|
|
4176
|
-
if (!test2) {
|
|
4177
|
-
throw new Error("expect.poll() must be called inside a test");
|
|
4096
|
+
function resetModules(modules, resetMocks = false) {
|
|
4097
|
+
const skipPaths = [
|
|
4098
|
+
// Vitest
|
|
4099
|
+
/\/vitest\/dist\//,
|
|
4100
|
+
/\/vite-node\/dist\//,
|
|
4101
|
+
// yarn's .store folder
|
|
4102
|
+
/vitest-virtual-\w+\/dist/,
|
|
4103
|
+
// cnpm
|
|
4104
|
+
/@vitest\/dist/,
|
|
4105
|
+
// don't clear mocks
|
|
4106
|
+
...!resetMocks ? [/^mock:/] : []
|
|
4107
|
+
];
|
|
4108
|
+
modules.forEach((mod, path) => {
|
|
4109
|
+
if (skipPaths.some((re) => re.test(path))) {
|
|
4110
|
+
return;
|
|
4178
4111
|
}
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
const assertionFunction = Reflect.get(target, key, receiver);
|
|
4182
|
-
if (typeof assertionFunction !== "function") {
|
|
4183
|
-
return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
|
|
4184
|
-
}
|
|
4185
|
-
if (key === "assert") {
|
|
4186
|
-
return assertionFunction;
|
|
4187
|
-
}
|
|
4188
|
-
if (typeof key === "string" && unsupported.includes(key)) {
|
|
4189
|
-
throw new SyntaxError(
|
|
4190
|
-
`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`
|
|
4191
|
-
);
|
|
4192
|
-
}
|
|
4193
|
-
return function(...args) {
|
|
4194
|
-
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
4195
|
-
const promise = () => new Promise((resolve, reject) => {
|
|
4196
|
-
let intervalId;
|
|
4197
|
-
let lastError;
|
|
4198
|
-
const { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = getSafeTimers();
|
|
4199
|
-
const timeoutId = setTimeout2(() => {
|
|
4200
|
-
clearTimeout2(intervalId);
|
|
4201
|
-
reject(
|
|
4202
|
-
copyStackTrace$1(
|
|
4203
|
-
new Error(`Matcher did not succeed in ${timeout}ms`, {
|
|
4204
|
-
cause: lastError
|
|
4205
|
-
}),
|
|
4206
|
-
STACK_TRACE_ERROR
|
|
4207
|
-
)
|
|
4208
|
-
);
|
|
4209
|
-
}, timeout);
|
|
4210
|
-
const check = async () => {
|
|
4211
|
-
try {
|
|
4212
|
-
chai$1.util.flag(assertion, "_name", key);
|
|
4213
|
-
const obj = await fn2();
|
|
4214
|
-
chai$1.util.flag(assertion, "object", obj);
|
|
4215
|
-
resolve(await assertionFunction.call(assertion, ...args));
|
|
4216
|
-
clearTimeout2(intervalId);
|
|
4217
|
-
clearTimeout2(timeoutId);
|
|
4218
|
-
} catch (err) {
|
|
4219
|
-
lastError = err;
|
|
4220
|
-
intervalId = setTimeout2(check, interval);
|
|
4221
|
-
}
|
|
4222
|
-
};
|
|
4223
|
-
check();
|
|
4224
|
-
});
|
|
4225
|
-
let awaited = false;
|
|
4226
|
-
test2.onFinished ??= [];
|
|
4227
|
-
test2.onFinished.push(() => {
|
|
4228
|
-
if (!awaited) {
|
|
4229
|
-
const negated = chai$1.util.flag(assertion, "negate") ? "not." : "";
|
|
4230
|
-
const name = chai$1.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)";
|
|
4231
|
-
const assertionString = `expect.${name}.${negated}${String(key)}()`;
|
|
4232
|
-
const error = new Error(
|
|
4233
|
-
`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
|
|
4234
|
-
|
|
4235
|
-
await ${assertionString}
|
|
4236
|
-
`
|
|
4237
|
-
);
|
|
4238
|
-
throw copyStackTrace$1(error, STACK_TRACE_ERROR);
|
|
4239
|
-
}
|
|
4240
|
-
});
|
|
4241
|
-
let resultPromise;
|
|
4242
|
-
return {
|
|
4243
|
-
then(onFulfilled, onRejected) {
|
|
4244
|
-
awaited = true;
|
|
4245
|
-
return (resultPromise ||= promise()).then(onFulfilled, onRejected);
|
|
4246
|
-
},
|
|
4247
|
-
catch(onRejected) {
|
|
4248
|
-
return (resultPromise ||= promise()).catch(onRejected);
|
|
4249
|
-
},
|
|
4250
|
-
finally(onFinally) {
|
|
4251
|
-
return (resultPromise ||= promise()).finally(onFinally);
|
|
4252
|
-
},
|
|
4253
|
-
[Symbol.toStringTag]: "Promise"
|
|
4254
|
-
};
|
|
4255
|
-
};
|
|
4256
|
-
}
|
|
4257
|
-
});
|
|
4258
|
-
return proxy;
|
|
4259
|
-
};
|
|
4112
|
+
modules.invalidateModule(mod);
|
|
4113
|
+
});
|
|
4260
4114
|
}
|
|
4261
|
-
function
|
|
4262
|
-
|
|
4263
|
-
|
|
4115
|
+
function waitNextTick() {
|
|
4116
|
+
const { setTimeout: setTimeout2 } = getSafeTimers();
|
|
4117
|
+
return new Promise((resolve) => setTimeout2(resolve, 0));
|
|
4118
|
+
}
|
|
4119
|
+
async function waitForImportsToResolve() {
|
|
4120
|
+
await waitNextTick();
|
|
4121
|
+
const state = getWorkerState();
|
|
4122
|
+
const promises = [];
|
|
4123
|
+
let resolvingCount = 0;
|
|
4124
|
+
for (const mod of state.moduleCache.values()) {
|
|
4125
|
+
if (mod.promise && !mod.evaluated) {
|
|
4126
|
+
promises.push(mod.promise);
|
|
4127
|
+
}
|
|
4128
|
+
if (mod.resolving) {
|
|
4129
|
+
resolvingCount++;
|
|
4130
|
+
}
|
|
4264
4131
|
}
|
|
4265
|
-
|
|
4132
|
+
if (!promises.length && !resolvingCount) {
|
|
4133
|
+
return;
|
|
4134
|
+
}
|
|
4135
|
+
await Promise.allSettled(promises);
|
|
4136
|
+
await waitForImportsToResolve();
|
|
4266
4137
|
}
|
|
4267
4138
|
function commonjsRequire(path) {
|
|
4268
4139
|
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.');
|
|
@@ -4281,12 +4152,12 @@ function requireChaiSubset() {
|
|
|
4281
4152
|
} else {
|
|
4282
4153
|
return chai.use(chaiSubset2);
|
|
4283
4154
|
}
|
|
4284
|
-
})(function(
|
|
4285
|
-
var Assertion2 =
|
|
4155
|
+
})(function(chai4, utils) {
|
|
4156
|
+
var Assertion2 = chai4.Assertion;
|
|
4286
4157
|
var assertionPrototype = Assertion2.prototype;
|
|
4287
4158
|
Assertion2.addMethod("containSubset", function(expected) {
|
|
4288
4159
|
var actual = utils.flag(this, "object");
|
|
4289
|
-
var showDiff =
|
|
4160
|
+
var showDiff = chai4.config.showDiff;
|
|
4290
4161
|
assertionPrototype.assert.call(
|
|
4291
4162
|
this,
|
|
4292
4163
|
compare(expected, actual),
|
|
@@ -4297,8 +4168,8 @@ function requireChaiSubset() {
|
|
|
4297
4168
|
showDiff
|
|
4298
4169
|
);
|
|
4299
4170
|
});
|
|
4300
|
-
|
|
4301
|
-
new
|
|
4171
|
+
chai4.assert.containSubset = function(val, exp, msg) {
|
|
4172
|
+
new chai4.Assertion(val, msg).to.be.containSubset(exp);
|
|
4302
4173
|
};
|
|
4303
4174
|
function compare(expected, actual) {
|
|
4304
4175
|
if (expected === actual) {
|
|
@@ -4350,56 +4221,18 @@ function requireChaiSubset() {
|
|
|
4350
4221
|
}
|
|
4351
4222
|
var chaiSubsetExports = requireChaiSubset();
|
|
4352
4223
|
var Subset = /* @__PURE__ */ getDefaultExportFromCjs(chaiSubsetExports);
|
|
4353
|
-
function
|
|
4354
|
-
|
|
4355
|
-
const name = `${util2.flag(assertion, "_name")}(${"expected"})`;
|
|
4356
|
-
const promiseName = util2.flag(assertion, "promise");
|
|
4357
|
-
const promise = promiseName ? `.${promiseName}` : "";
|
|
4358
|
-
return `expect(actual)${promise}.${not}${name}`;
|
|
4359
|
-
}
|
|
4360
|
-
function recordAsyncExpect(_test, promise, assertion, error) {
|
|
4361
|
-
const test2 = _test;
|
|
4362
|
-
if (test2 && promise instanceof Promise) {
|
|
4224
|
+
function recordAsyncExpect(test3, promise) {
|
|
4225
|
+
if (test3 && promise instanceof Promise) {
|
|
4363
4226
|
promise = promise.finally(() => {
|
|
4364
|
-
|
|
4365
|
-
return;
|
|
4366
|
-
}
|
|
4367
|
-
const index = test2.promises.indexOf(promise);
|
|
4227
|
+
const index = test3.promises.indexOf(promise);
|
|
4368
4228
|
if (index !== -1) {
|
|
4369
|
-
|
|
4370
|
-
}
|
|
4371
|
-
});
|
|
4372
|
-
if (!test2.promises) {
|
|
4373
|
-
test2.promises = [];
|
|
4374
|
-
}
|
|
4375
|
-
test2.promises.push(promise);
|
|
4376
|
-
let resolved = false;
|
|
4377
|
-
test2.onFinished ??= [];
|
|
4378
|
-
test2.onFinished.push(() => {
|
|
4379
|
-
if (!resolved) {
|
|
4380
|
-
const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
|
|
4381
|
-
const stack = processor(error.stack);
|
|
4382
|
-
console.warn([
|
|
4383
|
-
`Promise returned by \`${assertion}\` was not awaited. `,
|
|
4384
|
-
"Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
|
|
4385
|
-
"Please remember to await the assertion.\n",
|
|
4386
|
-
stack
|
|
4387
|
-
].join(""));
|
|
4229
|
+
test3.promises.splice(index, 1);
|
|
4388
4230
|
}
|
|
4389
4231
|
});
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
},
|
|
4395
|
-
catch(onRejected) {
|
|
4396
|
-
return promise.catch(onRejected);
|
|
4397
|
-
},
|
|
4398
|
-
finally(onFinally) {
|
|
4399
|
-
return promise.finally(onFinally);
|
|
4400
|
-
},
|
|
4401
|
-
[Symbol.toStringTag]: "Promise"
|
|
4402
|
-
};
|
|
4232
|
+
if (!test3.promises) {
|
|
4233
|
+
test3.promises = [];
|
|
4234
|
+
}
|
|
4235
|
+
test3.promises.push(promise);
|
|
4403
4236
|
}
|
|
4404
4237
|
return promise;
|
|
4405
4238
|
}
|
|
@@ -4430,28 +4263,27 @@ function getError(expected, promise) {
|
|
|
4430
4263
|
}
|
|
4431
4264
|
throw new Error("snapshot function didn't throw");
|
|
4432
4265
|
}
|
|
4433
|
-
function getTestNames(
|
|
4434
|
-
if (!
|
|
4266
|
+
function getTestNames(test3) {
|
|
4267
|
+
if (!test3) {
|
|
4435
4268
|
return {};
|
|
4436
4269
|
}
|
|
4437
4270
|
return {
|
|
4438
|
-
filepath:
|
|
4439
|
-
name: getNames(
|
|
4271
|
+
filepath: test3.file.filepath,
|
|
4272
|
+
name: getNames(test3).slice(1).join(" > ")
|
|
4440
4273
|
};
|
|
4441
4274
|
}
|
|
4442
|
-
var SnapshotPlugin = (
|
|
4275
|
+
var SnapshotPlugin = (chai4, utils) => {
|
|
4443
4276
|
for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
|
|
4444
4277
|
utils.addMethod(
|
|
4445
|
-
|
|
4278
|
+
chai4.Assertion.prototype,
|
|
4446
4279
|
key,
|
|
4447
4280
|
function(properties, message) {
|
|
4448
|
-
utils.flag(this, "_name", key);
|
|
4449
4281
|
const isNot = utils.flag(this, "negate");
|
|
4450
4282
|
if (isNot) {
|
|
4451
4283
|
throw new Error(`${key} cannot be used with "not"`);
|
|
4452
4284
|
}
|
|
4453
4285
|
const expected = utils.flag(this, "object");
|
|
4454
|
-
const
|
|
4286
|
+
const test3 = utils.flag(this, "vitest-test");
|
|
4455
4287
|
if (typeof properties === "string" && typeof message === "undefined") {
|
|
4456
4288
|
message = properties;
|
|
4457
4289
|
properties = void 0;
|
|
@@ -4463,23 +4295,21 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
4463
4295
|
isInline: false,
|
|
4464
4296
|
properties,
|
|
4465
4297
|
errorMessage,
|
|
4466
|
-
...getTestNames(
|
|
4298
|
+
...getTestNames(test3)
|
|
4467
4299
|
});
|
|
4468
4300
|
}
|
|
4469
4301
|
);
|
|
4470
4302
|
}
|
|
4471
4303
|
utils.addMethod(
|
|
4472
|
-
|
|
4304
|
+
chai4.Assertion.prototype,
|
|
4473
4305
|
"toMatchFileSnapshot",
|
|
4474
4306
|
function(file, message) {
|
|
4475
|
-
utils.flag(this, "_name", "toMatchFileSnapshot");
|
|
4476
4307
|
const isNot = utils.flag(this, "negate");
|
|
4477
4308
|
if (isNot) {
|
|
4478
4309
|
throw new Error('toMatchFileSnapshot cannot be used with "not"');
|
|
4479
4310
|
}
|
|
4480
|
-
const error = new Error("resolves");
|
|
4481
4311
|
const expected = utils.flag(this, "object");
|
|
4482
|
-
const
|
|
4312
|
+
const test3 = utils.flag(this, "vitest-test");
|
|
4483
4313
|
const errorMessage = utils.flag(this, "message");
|
|
4484
4314
|
const promise = getSnapshotClient().assertRaw({
|
|
4485
4315
|
received: expected,
|
|
@@ -4489,27 +4319,21 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
4489
4319
|
file
|
|
4490
4320
|
},
|
|
4491
4321
|
errorMessage,
|
|
4492
|
-
...getTestNames(
|
|
4322
|
+
...getTestNames(test3)
|
|
4493
4323
|
});
|
|
4494
|
-
return recordAsyncExpect(
|
|
4495
|
-
test2,
|
|
4496
|
-
promise,
|
|
4497
|
-
createAssertionMessage(utils, this),
|
|
4498
|
-
error
|
|
4499
|
-
);
|
|
4324
|
+
return recordAsyncExpect(test3, promise);
|
|
4500
4325
|
}
|
|
4501
4326
|
);
|
|
4502
4327
|
utils.addMethod(
|
|
4503
|
-
|
|
4328
|
+
chai4.Assertion.prototype,
|
|
4504
4329
|
"toMatchInlineSnapshot",
|
|
4505
4330
|
function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
|
4506
|
-
utils.flag(this, "_name", "toMatchInlineSnapshot");
|
|
4507
4331
|
const isNot = utils.flag(this, "negate");
|
|
4508
4332
|
if (isNot) {
|
|
4509
4333
|
throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
|
4510
4334
|
}
|
|
4511
|
-
const
|
|
4512
|
-
const isInsideEach =
|
|
4335
|
+
const test3 = utils.flag(this, "vitest-test");
|
|
4336
|
+
const isInsideEach = test3 && (test3.each || test3.suite?.each);
|
|
4513
4337
|
if (isInsideEach) {
|
|
4514
4338
|
throw new Error(
|
|
4515
4339
|
"InlineSnapshot cannot be used inside of test.each or describe.each"
|
|
@@ -4534,15 +4358,14 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
4534
4358
|
inlineSnapshot,
|
|
4535
4359
|
error,
|
|
4536
4360
|
errorMessage,
|
|
4537
|
-
...getTestNames(
|
|
4361
|
+
...getTestNames(test3)
|
|
4538
4362
|
});
|
|
4539
4363
|
}
|
|
4540
4364
|
);
|
|
4541
4365
|
utils.addMethod(
|
|
4542
|
-
|
|
4366
|
+
chai4.Assertion.prototype,
|
|
4543
4367
|
"toThrowErrorMatchingSnapshot",
|
|
4544
4368
|
function(message) {
|
|
4545
|
-
utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
|
|
4546
4369
|
const isNot = utils.flag(this, "negate");
|
|
4547
4370
|
if (isNot) {
|
|
4548
4371
|
throw new Error(
|
|
@@ -4550,19 +4373,19 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
4550
4373
|
);
|
|
4551
4374
|
}
|
|
4552
4375
|
const expected = utils.flag(this, "object");
|
|
4553
|
-
const
|
|
4376
|
+
const test3 = utils.flag(this, "vitest-test");
|
|
4554
4377
|
const promise = utils.flag(this, "promise");
|
|
4555
4378
|
const errorMessage = utils.flag(this, "message");
|
|
4556
4379
|
getSnapshotClient().assert({
|
|
4557
4380
|
received: getError(expected, promise),
|
|
4558
4381
|
message,
|
|
4559
4382
|
errorMessage,
|
|
4560
|
-
...getTestNames(
|
|
4383
|
+
...getTestNames(test3)
|
|
4561
4384
|
});
|
|
4562
4385
|
}
|
|
4563
4386
|
);
|
|
4564
4387
|
utils.addMethod(
|
|
4565
|
-
|
|
4388
|
+
chai4.Assertion.prototype,
|
|
4566
4389
|
"toThrowErrorMatchingInlineSnapshot",
|
|
4567
4390
|
function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
|
|
4568
4391
|
const isNot = utils.flag(this, "negate");
|
|
@@ -4571,8 +4394,8 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
4571
4394
|
'toThrowErrorMatchingInlineSnapshot cannot be used with "not"'
|
|
4572
4395
|
);
|
|
4573
4396
|
}
|
|
4574
|
-
const
|
|
4575
|
-
const isInsideEach =
|
|
4397
|
+
const test3 = utils.flag(this, "vitest-test");
|
|
4398
|
+
const isInsideEach = test3 && (test3.each || test3.suite?.each);
|
|
4576
4399
|
if (isInsideEach) {
|
|
4577
4400
|
throw new Error(
|
|
4578
4401
|
"InlineSnapshot cannot be used inside of test.each or describe.each"
|
|
@@ -4592,23 +4415,114 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
|
4592
4415
|
isInline: true,
|
|
4593
4416
|
error,
|
|
4594
4417
|
errorMessage,
|
|
4595
|
-
...getTestNames(
|
|
4418
|
+
...getTestNames(test3)
|
|
4596
4419
|
});
|
|
4597
4420
|
}
|
|
4598
4421
|
);
|
|
4599
|
-
utils.addMethod(
|
|
4422
|
+
utils.addMethod(chai4.expect, "addSnapshotSerializer", addSerializer);
|
|
4600
4423
|
};
|
|
4601
4424
|
chai$1.use(JestExtend);
|
|
4602
4425
|
chai$1.use(JestChaiExpect);
|
|
4603
4426
|
chai$1.use(Subset);
|
|
4604
4427
|
chai$1.use(SnapshotPlugin);
|
|
4605
4428
|
chai$1.use(JestAsymmetricMatchers);
|
|
4606
|
-
|
|
4429
|
+
var unsupported = [
|
|
4430
|
+
// .poll is meant to retry matchers until they succeed, and
|
|
4431
|
+
// snapshots will always succeed as long as the poll method doesn't thow an error
|
|
4432
|
+
// in this case using the `vi.waitFor` method is more appropriate
|
|
4433
|
+
"matchSnapshot",
|
|
4434
|
+
"toMatchSnapshot",
|
|
4435
|
+
"toMatchInlineSnapshot",
|
|
4436
|
+
"toThrowErrorMatchingSnapshot",
|
|
4437
|
+
"toThrowErrorMatchingInlineSnapshot",
|
|
4438
|
+
// toThrow will never succeed because we call the poll callback until it doesn't throw
|
|
4439
|
+
"throws",
|
|
4440
|
+
"Throw",
|
|
4441
|
+
"throw",
|
|
4442
|
+
"toThrow",
|
|
4443
|
+
"toThrowError"
|
|
4444
|
+
// these are not supported because you can call them without `.poll`,
|
|
4445
|
+
// we throw an error inside the rejects/resolves methods to prevent this
|
|
4446
|
+
// rejects,
|
|
4447
|
+
// resolves
|
|
4448
|
+
];
|
|
4449
|
+
function createExpectPoll(expect2) {
|
|
4450
|
+
return function poll(fn2, options = {}) {
|
|
4451
|
+
const state = getWorkerState();
|
|
4452
|
+
const defaults = state.config.expect?.poll ?? {};
|
|
4453
|
+
const {
|
|
4454
|
+
interval = defaults.interval ?? 50,
|
|
4455
|
+
timeout = defaults.timeout ?? 1e3,
|
|
4456
|
+
message
|
|
4457
|
+
} = options;
|
|
4458
|
+
const assertion = expect2(null, message).withContext({
|
|
4459
|
+
poll: true
|
|
4460
|
+
});
|
|
4461
|
+
fn2 = fn2.bind(assertion);
|
|
4462
|
+
const proxy = new Proxy(assertion, {
|
|
4463
|
+
get(target, key, receiver) {
|
|
4464
|
+
const assertionFunction = Reflect.get(target, key, receiver);
|
|
4465
|
+
if (typeof assertionFunction !== "function") {
|
|
4466
|
+
return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
|
|
4467
|
+
}
|
|
4468
|
+
if (key === "assert") {
|
|
4469
|
+
return assertionFunction;
|
|
4470
|
+
}
|
|
4471
|
+
if (typeof key === "string" && unsupported.includes(key)) {
|
|
4472
|
+
throw new SyntaxError(
|
|
4473
|
+
`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`
|
|
4474
|
+
);
|
|
4475
|
+
}
|
|
4476
|
+
return function(...args) {
|
|
4477
|
+
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
|
4478
|
+
return new Promise((resolve, reject) => {
|
|
4479
|
+
let intervalId;
|
|
4480
|
+
let lastError;
|
|
4481
|
+
const { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = getSafeTimers();
|
|
4482
|
+
const timeoutId = setTimeout2(() => {
|
|
4483
|
+
clearTimeout2(intervalId);
|
|
4484
|
+
reject(
|
|
4485
|
+
copyStackTrace$1(
|
|
4486
|
+
new Error(`Matcher did not succeed in ${timeout}ms`, {
|
|
4487
|
+
cause: lastError
|
|
4488
|
+
}),
|
|
4489
|
+
STACK_TRACE_ERROR
|
|
4490
|
+
)
|
|
4491
|
+
);
|
|
4492
|
+
}, timeout);
|
|
4493
|
+
const check = async () => {
|
|
4494
|
+
try {
|
|
4495
|
+
chai$1.util.flag(assertion, "_name", key);
|
|
4496
|
+
const obj = await fn2();
|
|
4497
|
+
chai$1.util.flag(assertion, "object", obj);
|
|
4498
|
+
resolve(await assertionFunction.call(assertion, ...args));
|
|
4499
|
+
clearTimeout2(intervalId);
|
|
4500
|
+
clearTimeout2(timeoutId);
|
|
4501
|
+
} catch (err) {
|
|
4502
|
+
lastError = err;
|
|
4503
|
+
intervalId = setTimeout2(check, interval);
|
|
4504
|
+
}
|
|
4505
|
+
};
|
|
4506
|
+
check();
|
|
4507
|
+
});
|
|
4508
|
+
};
|
|
4509
|
+
}
|
|
4510
|
+
});
|
|
4511
|
+
return proxy;
|
|
4512
|
+
};
|
|
4513
|
+
}
|
|
4514
|
+
function copyStackTrace$1(target, source) {
|
|
4515
|
+
if (source.stack !== void 0) {
|
|
4516
|
+
target.stack = source.stack.replace(source.message, target.message);
|
|
4517
|
+
}
|
|
4518
|
+
return target;
|
|
4519
|
+
}
|
|
4520
|
+
function createExpect(test3) {
|
|
4607
4521
|
const expect2 = (value, message) => {
|
|
4608
4522
|
const { assertionCalls } = getState(expect2);
|
|
4609
4523
|
setState({ assertionCalls: assertionCalls + 1 }, expect2);
|
|
4610
4524
|
const assert22 = chai$1.expect(value, message);
|
|
4611
|
-
const _test = getCurrentTest();
|
|
4525
|
+
const _test = test3 || getCurrentTest();
|
|
4612
4526
|
if (_test) {
|
|
4613
4527
|
return assert22.withTest(_test);
|
|
4614
4528
|
} else {
|
|
@@ -4633,7 +4547,7 @@ function createExpect(test2) {
|
|
|
4633
4547
|
get testPath() {
|
|
4634
4548
|
return getWorkerState().filepath;
|
|
4635
4549
|
},
|
|
4636
|
-
currentTestName: globalState.currentTestName
|
|
4550
|
+
currentTestName: test3 ? getTestName(test3) : globalState.currentTestName
|
|
4637
4551
|
},
|
|
4638
4552
|
expect2
|
|
4639
4553
|
);
|
|
@@ -6869,6 +6783,108 @@ function getImporter(name) {
|
|
|
6869
6783
|
const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
|
|
6870
6784
|
return stack?.file || "";
|
|
6871
6785
|
}
|
|
6786
|
+
var dist = {};
|
|
6787
|
+
var hasRequiredDist;
|
|
6788
|
+
function requireDist() {
|
|
6789
|
+
if (hasRequiredDist) return dist;
|
|
6790
|
+
hasRequiredDist = 1;
|
|
6791
|
+
(function(exports) {
|
|
6792
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6793
|
+
exports.expectTypeOf = void 0;
|
|
6794
|
+
const fn2 = () => true;
|
|
6795
|
+
const expectTypeOf2 = (_actual) => {
|
|
6796
|
+
const nonFunctionProperties = [
|
|
6797
|
+
"parameters",
|
|
6798
|
+
"returns",
|
|
6799
|
+
"resolves",
|
|
6800
|
+
"not",
|
|
6801
|
+
"items",
|
|
6802
|
+
"constructorParameters",
|
|
6803
|
+
"thisParameter",
|
|
6804
|
+
"instance",
|
|
6805
|
+
"guards",
|
|
6806
|
+
"asserts",
|
|
6807
|
+
"branded"
|
|
6808
|
+
];
|
|
6809
|
+
const obj = {
|
|
6810
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
6811
|
+
toBeAny: fn2,
|
|
6812
|
+
toBeUnknown: fn2,
|
|
6813
|
+
toBeNever: fn2,
|
|
6814
|
+
toBeFunction: fn2,
|
|
6815
|
+
toBeObject: fn2,
|
|
6816
|
+
toBeArray: fn2,
|
|
6817
|
+
toBeString: fn2,
|
|
6818
|
+
toBeNumber: fn2,
|
|
6819
|
+
toBeBoolean: fn2,
|
|
6820
|
+
toBeVoid: fn2,
|
|
6821
|
+
toBeSymbol: fn2,
|
|
6822
|
+
toBeNull: fn2,
|
|
6823
|
+
toBeUndefined: fn2,
|
|
6824
|
+
toBeNullable: fn2,
|
|
6825
|
+
toMatchTypeOf: fn2,
|
|
6826
|
+
toEqualTypeOf: fn2,
|
|
6827
|
+
toBeCallableWith: fn2,
|
|
6828
|
+
toBeConstructibleWith: fn2,
|
|
6829
|
+
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
|
|
6830
|
+
extract: exports.expectTypeOf,
|
|
6831
|
+
exclude: exports.expectTypeOf,
|
|
6832
|
+
pick: exports.expectTypeOf,
|
|
6833
|
+
omit: exports.expectTypeOf,
|
|
6834
|
+
toHaveProperty: exports.expectTypeOf,
|
|
6835
|
+
parameter: exports.expectTypeOf
|
|
6836
|
+
};
|
|
6837
|
+
const getterProperties = nonFunctionProperties;
|
|
6838
|
+
getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
|
|
6839
|
+
return obj;
|
|
6840
|
+
};
|
|
6841
|
+
exports.expectTypeOf = expectTypeOf2;
|
|
6842
|
+
})(dist);
|
|
6843
|
+
return dist;
|
|
6844
|
+
}
|
|
6845
|
+
var distExports = requireDist();
|
|
6846
|
+
function noop2() {
|
|
6847
|
+
}
|
|
6848
|
+
var assertType = noop2;
|
|
6849
|
+
function getRunningMode() {
|
|
6850
|
+
return process.env.VITEST_MODE === "WATCH" ? "watch" : "run";
|
|
6851
|
+
}
|
|
6852
|
+
function isWatchMode() {
|
|
6853
|
+
return getRunningMode() === "watch";
|
|
6854
|
+
}
|
|
6855
|
+
function inject(key) {
|
|
6856
|
+
const workerState = getWorkerState();
|
|
6857
|
+
return workerState.providedContext[key];
|
|
6858
|
+
}
|
|
6859
|
+
/* @__PURE__ */ Object.freeze({
|
|
6860
|
+
__proto__: null,
|
|
6861
|
+
afterAll: afterAll$1,
|
|
6862
|
+
afterEach: afterEach$1,
|
|
6863
|
+
assert: assert,
|
|
6864
|
+
assertType,
|
|
6865
|
+
beforeAll: beforeAll$1,
|
|
6866
|
+
beforeEach,
|
|
6867
|
+
bench,
|
|
6868
|
+
chai: chai$1,
|
|
6869
|
+
createExpect,
|
|
6870
|
+
describe,
|
|
6871
|
+
expect: globalExpect,
|
|
6872
|
+
expectTypeOf: distExports.expectTypeOf,
|
|
6873
|
+
getRunningMode,
|
|
6874
|
+
inject,
|
|
6875
|
+
isFirstRun,
|
|
6876
|
+
isWatchMode,
|
|
6877
|
+
it,
|
|
6878
|
+
onTestFailed,
|
|
6879
|
+
onTestFinished,
|
|
6880
|
+
runOnce,
|
|
6881
|
+
should,
|
|
6882
|
+
suite,
|
|
6883
|
+
test,
|
|
6884
|
+
vi,
|
|
6885
|
+
vitest
|
|
6886
|
+
});
|
|
6887
|
+
distExports.expectTypeOf;
|
|
6872
6888
|
|
|
6873
6889
|
// src/test/setup.ts
|
|
6874
6890
|
globalExpect.extend(matchers_exports);
|