@bemedev/dev-utils 0.8.3 → 1.0.1
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 +8 -19
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.d.ts +1 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +3 -3
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.d.ts +1 -1
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +0 -1
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.d.ts +1 -51
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs +0 -1
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/index.d.ts +0 -1
- package/lib/build-tests/cli/index.js.map +1 -1
- package/lib/build-tests/cli/post.cjs +0 -1
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.d.ts +1 -5
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +0 -1
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.d.ts +1 -5
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.d.ts +1 -15
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.d.ts +1 -1
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +0 -1
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.d.ts +1 -1
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.d.ts +2 -2
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +0 -1
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.d.ts +3 -3
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +0 -1
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.d.ts +3 -7
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/imports/index.d.ts +1 -1
- package/lib/build-tests/index.d.ts +5 -5
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.d.ts +1 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/rolldown-config/config.cjs +6 -11
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.d.ts +1 -1
- package/lib/rolldown-config/config.js +1 -5
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.d.ts +5 -5
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +0 -1
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.d.ts +2 -2
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/index.d.ts +3 -3
- package/lib/rolldown-config/input.cjs +1 -2
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.d.ts +1 -1
- package/lib/rolldown-config/input.js +1 -1
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +1 -15
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +6 -5
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +9 -7
- package/lib/rolldown-config/plugins/circulars.js +5 -3
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +4 -9
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +4 -13
- package/lib/rolldown-config/plugins/clean.js +4 -7
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +1 -1
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -6
- package/lib/rolldown-config/plugins/externals.js +1 -0
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs +1 -8
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +2 -27
- package/lib/rolldown-config/plugins/index.js +0 -6
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +45 -33
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +39 -46
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +4 -2
- package/lib/rolldown-config/plugins/typescript.config.js +41 -47
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
- package/lib/rolldown-config/plugins/typescript.js +44 -30
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +13 -13
- package/lib/{rolldown-config/utils.cjs → utils/array.cjs} +2 -2
- package/lib/utils/array.cjs.map +1 -0
- package/lib/utils/array.d.ts +2 -0
- package/lib/{rolldown-config/utils.js → utils/array.js} +2 -2
- package/lib/utils/array.js.map +1 -0
- package/lib/utils/identity.d.ts +1 -1
- package/lib/utils/index.cjs +2 -0
- package/lib/utils/index.d.ts +4 -3
- package/lib/utils/index.js +2 -1
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.d.ts +1 -1
- package/lib/utils/sleep.js.map +1 -1
- package/lib/utils/types.d.ts +5 -1
- package/lib/vitest-exclude/index.d.ts +1 -1
- package/lib/vitest-exclude/types.d.ts +8 -11
- package/lib/vitest-exclude/vitest.cjs +6 -9
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +15 -30
- package/lib/vitest-exclude/vitest.js +6 -9
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +1 -2
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
- package/lib/vitest-exclude/vitest.utils.js +1 -1
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +1 -5
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.d.ts +3 -7
- package/lib/vitest-extended/acceptation.js +1 -4
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/bemedev/globals/types.d.ts +4 -1
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.cjs +4 -3
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.cjs.map +1 -1
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +10 -9
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.js +4 -3
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +22 -24
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.d.ts +34 -56
- package/lib/vitest-extended/createTests.js +22 -23
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/createTests.types.d.ts +10 -6
- package/lib/vitest-extended/done.cjs +6 -4
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.d.ts +8 -13
- package/lib/vitest-extended/done.js +6 -3
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +0 -1
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.d.ts +1 -1
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +10 -4
- package/lib/vitest-extended/each/index.d.ts +2 -2
- package/lib/vitest-extended/each/pass.cjs +13 -16
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.d.ts +26 -28
- package/lib/vitest-extended/each/pass.js +13 -15
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/each/pass.types.d.ts +18 -6
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs +2 -2
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js +2 -2
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +0 -1
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.d.ts +2 -2
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/index.d.ts +6 -6
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.d.ts +1 -1
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.d.ts +1 -1
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.d.ts +1 -1
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +1 -1
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/lib/vitest-extended/types.d.ts +40 -42
- package/package.json +14 -10
- package/lib/rolldown-config/plugins/alias.cjs +0 -17
- package/lib/rolldown-config/plugins/alias.cjs.map +0 -1
- package/lib/rolldown-config/plugins/alias.d.ts +0 -25
- package/lib/rolldown-config/plugins/alias.js +0 -14
- package/lib/rolldown-config/plugins/alias.js.map +0 -1
- package/lib/rolldown-config/plugins/tsPaths.cjs +0 -17
- package/lib/rolldown-config/plugins/tsPaths.cjs.map +0 -1
- package/lib/rolldown-config/plugins/tsPaths.d.ts +0 -9
- package/lib/rolldown-config/plugins/tsPaths.js +0 -14
- package/lib/rolldown-config/plugins/tsPaths.js.map +0 -1
- package/lib/rolldown-config/utils.cjs.map +0 -1
- package/lib/rolldown-config/utils.d.ts +0 -2
- package/lib/rolldown-config/utils.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_unknown.cjs","names":[],"sources":["../../../../../src/vitest-extended/bemedev/globals/utils/_unknown.ts"],"sourcesContent":["/**\n * _unknown variable - Auto-generated expression\n *\n * ⚠️ WARNING: This expression is auto-generated and should not be
|
|
1
|
+
{"version":3,"file":"_unknown.cjs","names":[],"sources":["../../../../../src/vitest-extended/bemedev/globals/utils/_unknown.ts"],"sourcesContent":["/**\n * _unknown variable - Auto-generated expression\n *\n * ⚠️ WARNING: This expression is auto-generated and should not be\n * modified. Any manual changes will be overwritten during the next\n * generation.\n *\n * @author chlbri (bri_lvi@icloud.com)\n * @generated\n * @readonly\n */\nexport const _unknown = <T>(value?: unknown) => value as T;\n"],"mappings":";;;;;;;;;;;;;AAWA,MAAa,YAAe,UAAoB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
* _unknown variable - Auto-generated expression
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ WARNING: This expression is auto-generated and should not be
|
|
5
|
+
* modified. Any manual changes will be overwritten during the next
|
|
6
|
+
* generation.
|
|
7
|
+
*
|
|
8
|
+
* @author chlbri (bri_lvi@icloud.com)
|
|
9
|
+
* @generated
|
|
10
|
+
* @readonly
|
|
11
|
+
*/
|
|
11
12
|
export declare const _unknown: <T>(value?: unknown) => T;
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* _unknown variable - Auto-generated expression
|
|
4
4
|
*
|
|
5
|
-
* ⚠️ WARNING: This expression is auto-generated and should not be
|
|
6
|
-
* Any manual changes will be overwritten during the next
|
|
5
|
+
* ⚠️ WARNING: This expression is auto-generated and should not be
|
|
6
|
+
* modified. Any manual changes will be overwritten during the next
|
|
7
|
+
* generation.
|
|
7
8
|
*
|
|
9
|
+
* @author chlbri (bri_lvi@icloud.com)
|
|
8
10
|
* @generated
|
|
9
11
|
* @readonly
|
|
10
|
-
* @author chlbri (bri_lvi@icloud.com)
|
|
11
12
|
*/
|
|
12
13
|
const _unknown = (value) => value;
|
|
13
14
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_unknown.js","names":[],"sources":["../../../../../src/vitest-extended/bemedev/globals/utils/_unknown.ts"],"sourcesContent":["/**\n * _unknown variable - Auto-generated expression\n *\n * ⚠️ WARNING: This expression is auto-generated and should not be
|
|
1
|
+
{"version":3,"file":"_unknown.js","names":[],"sources":["../../../../../src/vitest-extended/bemedev/globals/utils/_unknown.ts"],"sourcesContent":["/**\n * _unknown variable - Auto-generated expression\n *\n * ⚠️ WARNING: This expression is auto-generated and should not be\n * modified. Any manual changes will be overwritten during the next\n * generation.\n *\n * @author chlbri (bri_lvi@icloud.com)\n * @generated\n * @readonly\n */\nexport const _unknown = <T>(value?: unknown) => value as T;\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,YAAe,UAAoB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_vitest_extended_toStringFlat = require("./toStringFlat.cjs");
|
|
4
3
|
const require_vitest_extended_acceptation = require("./acceptation.cjs");
|
|
5
4
|
const require_vitest_extended_each_error = require("./each/error.cjs");
|
|
@@ -37,38 +36,37 @@ const _create = (func, transform, toError, name) => {
|
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
38
|
/**
|
|
40
|
-
* Creates tests for function in a better way
|
|
41
|
-
*
|
|
42
|
-
* @param library The test library
|
|
43
|
-
* @param f The function to test
|
|
44
|
-
* @param
|
|
45
|
-
* @returns A test.each like function to tests many cases
|
|
46
|
-
*
|
|
47
|
-
* NB: If the first argument is an array, wrap the value in another array,
|
|
39
|
+
* Creates tests for function in a better way NB : We use strict-equality,
|
|
40
|
+
* {@link useEach|see}
|
|
48
41
|
*
|
|
49
42
|
* @example
|
|
50
|
-
*
|
|
51
|
-
*export const add = (args: string[]) => args.reduce(
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
43
|
+
* // ./add.ts
|
|
44
|
+
* *export const add = (args: string[]) => args.reduce(
|
|
45
|
+
* (acc, value) => {
|
|
46
|
+
* acc+=value
|
|
47
|
+
* return acc;
|
|
48
|
+
* },
|
|
49
|
+
* 0)
|
|
57
50
|
*
|
|
58
51
|
*
|
|
59
|
-
*
|
|
60
|
-
*import { createTests } from '@bemedev/vitest-extended';
|
|
61
|
-
*import { add } from './add';
|
|
52
|
+
* // .add.test.ts
|
|
53
|
+
* *import { createTests } from '@bemedev/vitest-extended';
|
|
54
|
+
* *import { add } from './add';
|
|
62
55
|
*
|
|
63
|
-
*const useTests = createTests(add)
|
|
56
|
+
* *const useTests = createTests(add)
|
|
64
57
|
*
|
|
65
|
-
*useTests(
|
|
58
|
+
* *useTests(
|
|
66
59
|
* {
|
|
67
|
-
*
|
|
68
|
-
*
|
|
60
|
+
* invite: 'For : 1,2,3,4,5,6,7,8,9',
|
|
61
|
+
* parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
|
|
69
62
|
* }
|
|
70
|
-
*)
|
|
63
|
+
* )
|
|
71
64
|
*
|
|
65
|
+
* @param library The test library
|
|
66
|
+
* @param f The function to test
|
|
67
|
+
* @param *
|
|
68
|
+
* @returns A test.each like function to tests many cases NB: If the first
|
|
69
|
+
* argument is an array, wrap the value in another array,
|
|
72
70
|
*/
|
|
73
71
|
const createTests = (func, args) => {
|
|
74
72
|
const { transform, toError } = args || {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTests.cjs","names":["useTFA","useErrorAsyncEach","toStringFlat","useEachAsync","vi"],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\nimport { useTFA } from './acceptation';\nimport type { Fn } from './bemedev/globals/types';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way
|
|
1
|
+
{"version":3,"file":"createTests.cjs","names":["useTFA","useErrorAsyncEach","toStringFlat","useEachAsync","vi"],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport { useTFA } from './acceptation';\nimport type { Fn } from './bemedev/globals/types';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way NB : We use strict-equality,\n * {@link useEach|see}\n *\n * @example\n * // ./add.ts\n * *export const add = (args: string[]) => args.reduce(\n * (acc, value) => {\n * acc+=value\n * return acc;\n * },\n * 0)\n *\n *\n * // .add.test.ts\n * *import { createTests } from '@bemedev/vitest-extended';\n * *import { add } from './add';\n *\n * *const useTests = createTests(add)\n *\n * *useTests(\n * {\n * invite: 'For : 1,2,3,4,5,6,7,8,9',\n * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!\n * }\n * )\n *\n * @param library The test library\n * @param f The function to test\n * @param *\n * @returns A test.each like function to tests many cases NB: If the first\n * argument is an array, wrap the value in another array,\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;;AAeA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmBA,oCAAAA,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiBC,mCAAAA,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADKC,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViBC,kCAAAA,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADKD,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;AAEA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAOE,OAAAA,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,CAAA,GAAA,OAAA,UAAA,CAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
|
|
@@ -1,58 +1,36 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { _CreateTests_F } from './createTests.types';
|
|
1
|
+
import type { _CreateTests_F } from "./createTests.types";
|
|
3
2
|
export type { _CreateTests_F };
|
|
4
3
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export declare const createTests: {
|
|
39
|
-
<F0 extends any[], F1, F2 = F1>(func: Fn<F0, F1>, args?: {
|
|
40
|
-
transform?: Fn<[Awaited<F1>], F2>;
|
|
41
|
-
toError?: Fn<F0, string | undefined>;
|
|
42
|
-
}): {
|
|
43
|
-
acceptation: () => void;
|
|
44
|
-
success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
|
|
45
|
-
fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
|
|
46
|
-
};
|
|
47
|
-
withImplementation<F0 extends any[], F1, F2 = F1>(f: Fn<NoInfer<F0>, NoInfer<F1>>, { instanciation, name, transform, toError, }: {
|
|
48
|
-
instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;
|
|
49
|
-
name: string;
|
|
50
|
-
transform?: Fn<[Awaited<F1>], F2>;
|
|
51
|
-
toError?: Fn<F0, string | undefined>;
|
|
52
|
-
}): {
|
|
53
|
-
acceptation: () => void;
|
|
54
|
-
success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
|
|
55
|
-
fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
|
|
56
|
-
};
|
|
57
|
-
withoutImplementation: /*elided*/ any;
|
|
58
|
-
};
|
|
4
|
+
* Creates tests for function in a better way NB : We use strict-equality,
|
|
5
|
+
* {@link useEach|see}
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // ./add.ts
|
|
9
|
+
* *export const add = (args: string[]) => args.reduce(
|
|
10
|
+
* (acc, value) => {
|
|
11
|
+
* acc+=value
|
|
12
|
+
* return acc;
|
|
13
|
+
* },
|
|
14
|
+
* 0)
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* // .add.test.ts
|
|
18
|
+
* *import { createTests } from '@bemedev/vitest-extended';
|
|
19
|
+
* *import { add } from './add';
|
|
20
|
+
*
|
|
21
|
+
* *const useTests = createTests(add)
|
|
22
|
+
*
|
|
23
|
+
* *useTests(
|
|
24
|
+
* {
|
|
25
|
+
* invite: 'For : 1,2,3,4,5,6,7,8,9',
|
|
26
|
+
* parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
|
|
27
|
+
* }
|
|
28
|
+
* )
|
|
29
|
+
*
|
|
30
|
+
* @param library The test library
|
|
31
|
+
* @param f The function to test
|
|
32
|
+
* @param *
|
|
33
|
+
* @returns A test.each like function to tests many cases NB: If the first
|
|
34
|
+
* argument is an array, wrap the value in another array,
|
|
35
|
+
*/
|
|
36
|
+
export declare const createTests: unknown;
|
|
@@ -35,38 +35,37 @@ const _create = (func, transform, toError, name) => {
|
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
38
|
-
* Creates tests for function in a better way
|
|
39
|
-
*
|
|
40
|
-
* @param library The test library
|
|
41
|
-
* @param f The function to test
|
|
42
|
-
* @param
|
|
43
|
-
* @returns A test.each like function to tests many cases
|
|
44
|
-
*
|
|
45
|
-
* NB: If the first argument is an array, wrap the value in another array,
|
|
38
|
+
* Creates tests for function in a better way NB : We use strict-equality,
|
|
39
|
+
* {@link useEach|see}
|
|
46
40
|
*
|
|
47
41
|
* @example
|
|
48
|
-
*
|
|
49
|
-
*export const add = (args: string[]) => args.reduce(
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
42
|
+
* // ./add.ts
|
|
43
|
+
* *export const add = (args: string[]) => args.reduce(
|
|
44
|
+
* (acc, value) => {
|
|
45
|
+
* acc+=value
|
|
46
|
+
* return acc;
|
|
47
|
+
* },
|
|
48
|
+
* 0)
|
|
55
49
|
*
|
|
56
50
|
*
|
|
57
|
-
*
|
|
58
|
-
*import { createTests } from '@bemedev/vitest-extended';
|
|
59
|
-
*import { add } from './add';
|
|
51
|
+
* // .add.test.ts
|
|
52
|
+
* *import { createTests } from '@bemedev/vitest-extended';
|
|
53
|
+
* *import { add } from './add';
|
|
60
54
|
*
|
|
61
|
-
*const useTests = createTests(add)
|
|
55
|
+
* *const useTests = createTests(add)
|
|
62
56
|
*
|
|
63
|
-
*useTests(
|
|
57
|
+
* *useTests(
|
|
64
58
|
* {
|
|
65
|
-
*
|
|
66
|
-
*
|
|
59
|
+
* invite: 'For : 1,2,3,4,5,6,7,8,9',
|
|
60
|
+
* parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
|
|
67
61
|
* }
|
|
68
|
-
*)
|
|
62
|
+
* )
|
|
69
63
|
*
|
|
64
|
+
* @param library The test library
|
|
65
|
+
* @param f The function to test
|
|
66
|
+
* @param *
|
|
67
|
+
* @returns A test.each like function to tests many cases NB: If the first
|
|
68
|
+
* argument is an array, wrap the value in another array,
|
|
70
69
|
*/
|
|
71
70
|
const createTests = (func, args) => {
|
|
72
71
|
const { transform, toError } = args || {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\nimport { useTFA } from './acceptation';\nimport type { Fn } from './bemedev/globals/types';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way
|
|
1
|
+
{"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport { useTFA } from './acceptation';\nimport type { Fn } from './bemedev/globals/types';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way NB : We use strict-equality,\n * {@link useEach|see}\n *\n * @example\n * // ./add.ts\n * *export const add = (args: string[]) => args.reduce(\n * (acc, value) => {\n * acc+=value\n * return acc;\n * },\n * 0)\n *\n *\n * // .add.test.ts\n * *import { createTests } from '@bemedev/vitest-extended';\n * *import { add } from './add';\n *\n * *const useTests = createTests(add)\n *\n * *useTests(\n * {\n * invite: 'For : 1,2,3,4,5,6,7,8,9',\n * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!\n * }\n * )\n *\n * @param library The test library\n * @param f The function to test\n * @param *\n * @returns A test.each like function to tests many cases NB: If the first\n * argument is an array, wrap the value in another array,\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;AAeA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmB,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiB,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViB,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;AAEA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAO,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,UAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type { Fn } from
|
|
2
|
-
import type { TestArgs, TestErrors } from
|
|
1
|
+
import type { Fn } from "./bemedev/globals/types";
|
|
2
|
+
import type { TestArgs, TestErrors } from "./types";
|
|
3
3
|
type ReturnR<F extends Fn> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
acceptation: () => void;
|
|
5
|
+
success: (...cases: TestArgs<F>) => () => void;
|
|
6
|
+
fails: (...cases: TestErrors<F>) => () => void;
|
|
7
7
|
};
|
|
8
|
-
export type _CreateTests_F = <
|
|
8
|
+
export type _CreateTests_F = <
|
|
9
|
+
F0 extends any[],
|
|
10
|
+
F1,
|
|
11
|
+
F2 = F1
|
|
12
|
+
>(func: Fn<F0, F1>, transform?: Fn<[Awaited<F1>], F2>, toError?: Fn<F0, string | undefined>, name?: string) => ReturnR<Fn<F0, F2>>;
|
|
9
13
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_utils_sleep = require("../utils/sleep.cjs");
|
|
4
3
|
let vitest = require("vitest");
|
|
5
4
|
//#region src/vitest-extended/done.ts
|
|
@@ -32,10 +31,11 @@ const objectify = (options) => {
|
|
|
32
31
|
};
|
|
33
32
|
/**
|
|
34
33
|
* Build a test with a done function with a timeout
|
|
34
|
+
*
|
|
35
35
|
* @param invite The description of the test
|
|
36
36
|
* @param fn Where you can test, Don't async this function
|
|
37
37
|
* @param options Options for the test like TestAPI from vitest
|
|
38
|
-
* @returns
|
|
38
|
+
* @returns A vitest test
|
|
39
39
|
*/
|
|
40
40
|
const doneTest = (invite, fn, options = 100) => {
|
|
41
41
|
const [_options, ms] = objectify(options);
|
|
@@ -47,10 +47,11 @@ const doneTest = (invite, fn, options = 100) => {
|
|
|
47
47
|
};
|
|
48
48
|
/**
|
|
49
49
|
* Build a test that fails with a done function with a timeout
|
|
50
|
+
*
|
|
50
51
|
* @param invite The description of the test
|
|
51
52
|
* @param fn Where you can test, Don't async this function
|
|
52
53
|
* @param options Options for the test like TestAPI from vitest
|
|
53
|
-
* @returns
|
|
54
|
+
* @returns A vitest test
|
|
54
55
|
*/
|
|
55
56
|
doneTest.fails = (invite, fn, options = 100) => {
|
|
56
57
|
const [_options, ms] = objectify(options);
|
|
@@ -62,10 +63,11 @@ doneTest.fails = (invite, fn, options = 100) => {
|
|
|
62
63
|
};
|
|
63
64
|
/**
|
|
64
65
|
* Build a concurrent test with a done function with a timeout
|
|
66
|
+
*
|
|
65
67
|
* @param invite The description of the test
|
|
66
68
|
* @param fn Where you can test, Don't async this function
|
|
67
69
|
* @param options Options for the test like TestAPI from vitest
|
|
68
|
-
* @returns
|
|
70
|
+
* @returns A vitest test
|
|
69
71
|
*/
|
|
70
72
|
doneTest.concurrent = (invite, fn, options = 100) => {
|
|
71
73
|
const [_options, ms] = objectify(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"done.cjs","names":["sleep","test"],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"done.cjs","names":["sleep","test"],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { expect, test, type TestOptions } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done function with a timeout\n *\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns A vitest test\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test that fails with a done function with a timeout\n *\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns A vitest test\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done function with a timeout\n *\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns A vitest test\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;;AAMA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;EAC3B,MAAMA,oBAAAA,MAAM,EAAE;EACd,CAAA,GAAA,OAAA,OAAA,CAAO,QAAQ,CAAC,CAAC,KAAK,IAAI;CAC5B;CAEA,OAAO;EAAE;EAAM;CAAS;AAC1B;AAEA,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;AAG3C,MAAM,cAAc,YAAmC;CACrD,IAAI,OAAO,YAAY,UAAU,OAAO,OAAO,OAAO;CACtD,OAAO,OAAO,SAAS,OAAO;AAChC;AAEA,MAAM,aACJ,YAC0B;CAC1B,MAAM,WAAW,WAAW,OAAO;CACnC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,QAAQ;CACzB,IAAI,EAAE,OAAO,YAAY,WACvB,WAAW;EAAE,GAAG;EAAS;CAAQ;CAGnC,OAAO,CAAC,UAAU,QAAQ;AAC5B;;;;;;;;;AAWA,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,QAAA,GAAA,OAAA,KAAA,CAAY,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;AAUA,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAOC,OAAAA,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;AAUA,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAOA,OAAAA,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { type TestOptions } from 'vitest';
|
|
2
|
-
import type { TestDoneFunction } from './types';
|
|
3
1
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
fails(invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
|
|
13
|
-
concurrent(invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
|
|
14
|
-
};
|
|
2
|
+
* Build a test with a done function with a timeout
|
|
3
|
+
*
|
|
4
|
+
* @param invite The description of the test
|
|
5
|
+
* @param fn Where you can test, Don't async this function
|
|
6
|
+
* @param options Options for the test like TestAPI from vitest
|
|
7
|
+
* @returns A vitest test
|
|
8
|
+
*/
|
|
9
|
+
export declare const doneTest: unknown;
|
|
@@ -30,10 +30,11 @@ const objectify = (options) => {
|
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Build a test with a done function with a timeout
|
|
33
|
+
*
|
|
33
34
|
* @param invite The description of the test
|
|
34
35
|
* @param fn Where you can test, Don't async this function
|
|
35
36
|
* @param options Options for the test like TestAPI from vitest
|
|
36
|
-
* @returns
|
|
37
|
+
* @returns A vitest test
|
|
37
38
|
*/
|
|
38
39
|
const doneTest = (invite, fn, options = 100) => {
|
|
39
40
|
const [_options, ms] = objectify(options);
|
|
@@ -45,10 +46,11 @@ const doneTest = (invite, fn, options = 100) => {
|
|
|
45
46
|
};
|
|
46
47
|
/**
|
|
47
48
|
* Build a test that fails with a done function with a timeout
|
|
49
|
+
*
|
|
48
50
|
* @param invite The description of the test
|
|
49
51
|
* @param fn Where you can test, Don't async this function
|
|
50
52
|
* @param options Options for the test like TestAPI from vitest
|
|
51
|
-
* @returns
|
|
53
|
+
* @returns A vitest test
|
|
52
54
|
*/
|
|
53
55
|
doneTest.fails = (invite, fn, options = 100) => {
|
|
54
56
|
const [_options, ms] = objectify(options);
|
|
@@ -60,10 +62,11 @@ doneTest.fails = (invite, fn, options = 100) => {
|
|
|
60
62
|
};
|
|
61
63
|
/**
|
|
62
64
|
* Build a concurrent test with a done function with a timeout
|
|
65
|
+
*
|
|
63
66
|
* @param invite The description of the test
|
|
64
67
|
* @param fn Where you can test, Don't async this function
|
|
65
68
|
* @param options Options for the test like TestAPI from vitest
|
|
66
|
-
* @returns
|
|
69
|
+
* @returns A vitest test
|
|
67
70
|
*/
|
|
68
71
|
doneTest.concurrent = (invite, fn, options = 100) => {
|
|
69
72
|
const [_options, ms] = objectify(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"done.js","names":[],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"done.js","names":[],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { expect, test, type TestOptions } from 'vitest';\n\nimport { sleep } from '#utils/sleep';\n\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done function with a timeout\n *\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns A vitest test\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test that fails with a done function with a timeout\n *\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns A vitest test\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done function with a timeout\n *\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns A vitest test\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;AAMA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;EAC3B,MAAM,MAAM,EAAE;EACd,OAAO,QAAQ,CAAC,CAAC,KAAK,IAAI;CAC5B;CAEA,OAAO;EAAE;EAAM;CAAS;AAC1B;AAEA,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE;AAG3C,MAAM,cAAc,YAAmC;CACrD,IAAI,OAAO,YAAY,UAAU,OAAO,OAAO,OAAO;CACtD,OAAO,OAAO,SAAS,OAAO;AAChC;AAEA,MAAM,aACJ,YAC0B;CAC1B,MAAM,WAAW,WAAW,OAAO;CACnC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,QAAQ;CACzB,IAAI,EAAE,OAAO,YAAY,WACvB,WAAW;EAAE,GAAG;EAAS;CAAQ;CAGnC,OAAO,CAAC,UAAU,QAAQ;AAC5B;;;;;;;;;AAWA,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;AAUA,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH;;;;;;;;;AAUA,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,OAAO;CAExC,OAAO,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,EAAE;EACrC,GAAG,IAAI;EACP,OAAO,SAAS;CAClB,CAAC;AACH"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_vitest_extended_toArray = require("../toArray.cjs");
|
|
4
3
|
const require_vitest_extended_identity = require("../identity.cjs");
|
|
5
4
|
let vitest = require("vitest");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.cjs","names":["identity","toArrayVitest"],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.cjs","names":["identity","toArrayVitest"],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;;AAMA,MAAa,0BACX,GACA,YAAYA,iCAAAA,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;CACH,OAAA,KAAK,WAAW,KAAKC,gCAAAA,cAAc,MAAM,KAAK,CAAC,CAAC,CAC9C,MACA,OAAO,GAAG,MAAM,WAAW;EACzB,MAAM,SAAS,YAAY;GAEzB,OAAO,UAAU,MADC,EAAE,GAAG,IAAI,CACP;EACtB;EAEA,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,IAAI,IAAI;EAEzC,OAAA,GAAA,OAAA,OAAA,CAAa,MAAM,CAAC,CAAC,QAAQ,aAAa,KAAK;CACjD,CACF;AACF;AAEA,MAAa,qBACX,GACA,WACA,YACG;CACH,QAAQ,GAAG,UACT,uBAAuB,GAAG,WAAW,SAAS,GAAG,KAAK;AAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;AAMA,MAAa,0BACX,GACA,YAAY,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;CACH,KAAK,WAAW,KAAK,cAAc,MAAM,KAAK,CAAC,CAAC,CAC9C,MACA,OAAO,GAAG,MAAM,WAAW;EACzB,MAAM,SAAS,YAAY;GAEzB,OAAO,UAAU,MADC,EAAE,GAAG,IAAI,CACP;EACtB;EAEA,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,IAAI,IAAI;EAEzC,MAAM,OAAO,MAAM,CAAC,CAAC,QAAQ,aAAa,KAAK;CACjD,CACF;AACF;AAEA,MAAa,qBACX,GACA,WACA,YACG;CACH,QAAQ,GAAG,UACT,uBAAuB,GAAG,WAAW,SAAS,GAAG,KAAK;AAC1D"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { Fn } from
|
|
2
|
-
import type { Identity, NextFn, TestErrors } from
|
|
1
|
+
import type { Fn } from "../bemedev/globals/types";
|
|
2
|
+
import type { Identity, NextFn, TestErrors } from "../types";
|
|
3
3
|
export type ToError_F<F extends Fn> = (...params: Parameters<F>) => string | undefined;
|
|
4
|
-
export type _UseErrorEach_F = <
|
|
5
|
-
|
|
4
|
+
export type _UseErrorEach_F = <
|
|
5
|
+
F extends Fn,
|
|
6
|
+
T extends NextFn<F> = Identity<F>
|
|
7
|
+
>(f: F, transform?: T, toError?: ToError_F<F>, ...cases: TestErrors<F>) => void;
|
|
8
|
+
export type UseErrorEach_F = <
|
|
9
|
+
F extends Fn,
|
|
10
|
+
T extends NextFn<F> = Identity<F>
|
|
11
|
+
>(f: F, transform?: T, toError?: ToError_F<F>) => Fn<TestErrors<F>, void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from "./error";
|
|
2
|
+
export * from "./pass";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
2
|
const require_vitest_extended_toArray = require("../toArray.cjs");
|
|
4
3
|
const require_vitest_extended_identity = require("../identity.cjs");
|
|
5
4
|
let vitest = require("vitest");
|
|
@@ -16,22 +15,21 @@ const useEachCases = (func, transform = require_vitest_extended_identity.identit
|
|
|
16
15
|
*
|
|
17
16
|
* @type A Parameters of the function, extends Array type
|
|
18
17
|
* @type R ReturnType of the function
|
|
19
|
-
*
|
|
20
|
-
* @if R are not provided, the return is a function to test with TestArgs arguments
|
|
21
|
-
*
|
|
22
|
-
* @else It tests every cases provided
|
|
23
|
-
*
|
|
24
18
|
* @param func The function to test
|
|
25
|
-
* @param cases The cases to test, The invite is the first arguments.
|
|
26
|
-
*
|
|
27
|
-
* * #1 The first arg is the invite of the test
|
|
19
|
+
* @param cases The cases to test, The invite is the first arguments. It's
|
|
20
|
+
* an array of Array.
|
|
28
21
|
*
|
|
29
|
-
*
|
|
22
|
+
* - #1 The first arg is the invite of the test
|
|
23
|
+
* - #2 The second arg is the parameters to to pass to the function. It's
|
|
24
|
+
* an array (param array).
|
|
25
|
+
* - #3 The third arg is the expected result
|
|
30
26
|
*
|
|
31
|
-
*
|
|
27
|
+
* Example: For a function like **_(arg1: string)=>any**_, the second arg
|
|
28
|
+
* with be : **_[string]**_
|
|
29
|
+
* @if R are not provided, the return is a function to test with TestArgs arguments
|
|
32
30
|
*
|
|
33
|
-
*
|
|
34
|
-
|
|
31
|
+
* @else It tests every cases provided
|
|
32
|
+
*/
|
|
35
33
|
const useEach = (func, transform) => {
|
|
36
34
|
return (...cases) => useEachCases(func, transform, ...cases);
|
|
37
35
|
};
|
|
@@ -41,11 +39,10 @@ const useEachAsyncCases = (f, transform = require_vitest_extended_identity.ident
|
|
|
41
39
|
});
|
|
42
40
|
};
|
|
43
41
|
/**
|
|
44
|
-
* Same as
|
|
42
|
+
* Same as _**useEach**_
|
|
45
43
|
*
|
|
46
44
|
* But for async functions
|
|
47
|
-
|
|
48
|
-
* */
|
|
45
|
+
*/
|
|
49
46
|
const useEachAsync = (func, transform) => {
|
|
50
47
|
return (...cases) => useEachAsyncCases(func, transform, ...cases);
|
|
51
48
|
};
|