@bemedev/dev-utils 1.1.0 → 1.2.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.
Files changed (265) hide show
  1. package/README.md +34 -0
  2. package/lib/_virtual/_rolldown/runtime.cjs +1 -1
  3. package/lib/build-tests/addTarball.cjs +5 -1
  4. package/lib/build-tests/addTarball.cjs.map +1 -1
  5. package/lib/build-tests/addTarball.d.ts +3 -0
  6. package/lib/build-tests/addTarball.js +5 -1
  7. package/lib/build-tests/addTarball.js.map +1 -1
  8. package/lib/build-tests/buildPackageJson.cjs +17 -9
  9. package/lib/build-tests/buildPackageJson.cjs.map +1 -1
  10. package/lib/build-tests/buildPackageJson.d.ts +5 -0
  11. package/lib/build-tests/buildPackageJson.js +17 -9
  12. package/lib/build-tests/buildPackageJson.js.map +1 -1
  13. package/lib/build-tests/cleanup.cjs +3 -0
  14. package/lib/build-tests/cleanup.cjs.map +1 -1
  15. package/lib/build-tests/cleanup.d.ts +3 -0
  16. package/lib/build-tests/cleanup.js +3 -0
  17. package/lib/build-tests/cleanup.js.map +1 -1
  18. package/lib/build-tests/cli/cli.cjs +6 -0
  19. package/lib/build-tests/cli/cli.cjs.map +1 -1
  20. package/lib/build-tests/cli/cli.d.ts +6 -0
  21. package/lib/build-tests/cli/cli.js +6 -0
  22. package/lib/build-tests/cli/cli.js.map +1 -1
  23. package/lib/build-tests/cli/index.cjs.map +1 -1
  24. package/lib/build-tests/cli/post.cjs +3 -0
  25. package/lib/build-tests/cli/post.cjs.map +1 -1
  26. package/lib/build-tests/cli/post.d.ts +3 -0
  27. package/lib/build-tests/cli/post.js +3 -0
  28. package/lib/build-tests/cli/post.js.map +1 -1
  29. package/lib/build-tests/cli/pre.cjs +3 -0
  30. package/lib/build-tests/cli/pre.cjs.map +1 -1
  31. package/lib/build-tests/cli/pre.d.ts +3 -0
  32. package/lib/build-tests/cli/pre.js +3 -0
  33. package/lib/build-tests/cli/pre.js.map +1 -1
  34. package/lib/build-tests/cli/test.cjs +3 -0
  35. package/lib/build-tests/cli/test.cjs.map +1 -1
  36. package/lib/build-tests/cli/test.d.ts +3 -0
  37. package/lib/build-tests/cli/test.js +3 -0
  38. package/lib/build-tests/cli/test.js.map +1 -1
  39. package/lib/build-tests/constants.cjs +42 -0
  40. package/lib/build-tests/constants.cjs.map +1 -1
  41. package/lib/build-tests/constants.d.ts +42 -0
  42. package/lib/build-tests/constants.js +42 -0
  43. package/lib/build-tests/constants.js.map +1 -1
  44. package/lib/build-tests/getRelativePath.cjs +7 -0
  45. package/lib/build-tests/getRelativePath.cjs.map +1 -1
  46. package/lib/build-tests/getRelativePath.d.ts +7 -0
  47. package/lib/build-tests/getRelativePath.js +7 -0
  48. package/lib/build-tests/getRelativePath.js.map +1 -1
  49. package/lib/build-tests/getTypescriptOutdir.cjs +5 -0
  50. package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
  51. package/lib/build-tests/getTypescriptOutdir.d.ts +5 -0
  52. package/lib/build-tests/getTypescriptOutdir.js +5 -0
  53. package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
  54. package/lib/build-tests/import.cjs +9 -0
  55. package/lib/build-tests/import.cjs.map +1 -1
  56. package/lib/build-tests/import.d.ts +9 -0
  57. package/lib/build-tests/import.js +9 -0
  58. package/lib/build-tests/import.js.map +1 -1
  59. package/lib/build-tests/imports/create.cjs +7 -0
  60. package/lib/build-tests/imports/create.cjs.map +1 -1
  61. package/lib/build-tests/imports/create.d.ts +13 -0
  62. package/lib/build-tests/imports/create.js +7 -0
  63. package/lib/build-tests/imports/create.js.map +1 -1
  64. package/lib/build-tests/imports/helper.cjs +9 -0
  65. package/lib/build-tests/imports/helper.cjs.map +1 -1
  66. package/lib/build-tests/imports/helper.d.ts +12 -0
  67. package/lib/build-tests/imports/helper.js +9 -0
  68. package/lib/build-tests/imports/helper.js.map +1 -1
  69. package/lib/build-tests/pack.cjs +7 -1
  70. package/lib/build-tests/pack.cjs.map +1 -1
  71. package/lib/build-tests/pack.d.ts +5 -0
  72. package/lib/build-tests/pack.js +7 -1
  73. package/lib/build-tests/pack.js.map +1 -1
  74. package/lib/plugins/index.cjs +3 -0
  75. package/lib/plugins/index.d.ts +1 -0
  76. package/lib/plugins/index.js +2 -0
  77. package/lib/plugins/suppressWarnings.cjs +37 -0
  78. package/lib/plugins/suppressWarnings.cjs.map +1 -0
  79. package/lib/plugins/suppressWarnings.d.ts +12 -0
  80. package/lib/plugins/suppressWarnings.js +36 -0
  81. package/lib/plugins/suppressWarnings.js.map +1 -0
  82. package/lib/rolldown-config/config.cjs +13 -5
  83. package/lib/rolldown-config/config.cjs.map +1 -1
  84. package/lib/rolldown-config/config.d.ts +7 -0
  85. package/lib/rolldown-config/config.js +13 -5
  86. package/lib/rolldown-config/config.js.map +1 -1
  87. package/lib/rolldown-config/constants.cjs +15 -0
  88. package/lib/rolldown-config/constants.cjs.map +1 -1
  89. package/lib/rolldown-config/constants.d.ts +15 -0
  90. package/lib/rolldown-config/constants.js +15 -0
  91. package/lib/rolldown-config/constants.js.map +1 -1
  92. package/lib/rolldown-config/helpers.cjs +16 -1
  93. package/lib/rolldown-config/helpers.cjs.map +1 -1
  94. package/lib/rolldown-config/helpers.d.ts +14 -0
  95. package/lib/rolldown-config/helpers.js +16 -1
  96. package/lib/rolldown-config/helpers.js.map +1 -1
  97. package/lib/rolldown-config/input.cjs +8 -0
  98. package/lib/rolldown-config/input.cjs.map +1 -1
  99. package/lib/rolldown-config/input.d.ts +8 -0
  100. package/lib/rolldown-config/input.js +8 -0
  101. package/lib/rolldown-config/input.js.map +1 -1
  102. package/lib/rolldown-config/output.cjs +8 -0
  103. package/lib/rolldown-config/output.cjs.map +1 -1
  104. package/lib/rolldown-config/output.d.ts +8 -0
  105. package/lib/rolldown-config/output.js +8 -0
  106. package/lib/rolldown-config/output.js.map +1 -1
  107. package/lib/rolldown-config/plugins/circulars.cjs +4 -4
  108. package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
  109. package/lib/rolldown-config/plugins/circulars.d.ts +7 -4
  110. package/lib/rolldown-config/plugins/circulars.js +4 -4
  111. package/lib/rolldown-config/plugins/circulars.js.map +1 -1
  112. package/lib/rolldown-config/plugins/clean.cjs +10 -1
  113. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  114. package/lib/rolldown-config/plugins/clean.d.ts +10 -0
  115. package/lib/rolldown-config/plugins/clean.js +10 -1
  116. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  117. package/lib/rolldown-config/plugins/externals.cjs +4 -3
  118. package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
  119. package/lib/rolldown-config/plugins/externals.d.ts +7 -3
  120. package/lib/rolldown-config/plugins/externals.js +4 -3
  121. package/lib/rolldown-config/plugins/externals.js.map +1 -1
  122. package/lib/rolldown-config/plugins/index.cjs +6 -0
  123. package/lib/rolldown-config/plugins/index.cjs.map +1 -1
  124. package/lib/rolldown-config/plugins/index.d.ts +6 -0
  125. package/lib/rolldown-config/plugins/index.js +6 -0
  126. package/lib/rolldown-config/plugins/index.js.map +1 -1
  127. package/lib/rolldown-config/plugins/typescript.cjs +7 -0
  128. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  129. package/lib/rolldown-config/plugins/typescript.config.cjs +15 -0
  130. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  131. package/lib/rolldown-config/plugins/typescript.config.d.ts +15 -0
  132. package/lib/rolldown-config/plugins/typescript.config.js +15 -0
  133. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  134. package/lib/rolldown-config/plugins/typescript.d.ts +10 -0
  135. package/lib/rolldown-config/plugins/typescript.fast.cjs +9 -1
  136. package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -1
  137. package/lib/rolldown-config/plugins/typescript.fast.d.ts +10 -0
  138. package/lib/rolldown-config/plugins/typescript.fast.js +9 -1
  139. package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -1
  140. package/lib/rolldown-config/plugins/typescript.js +7 -0
  141. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  142. package/lib/rolldown-config/types.d.ts +18 -0
  143. package/lib/utils/array.cjs +7 -0
  144. package/lib/utils/array.cjs.map +1 -1
  145. package/lib/utils/array.d.ts +8 -0
  146. package/lib/utils/array.js +7 -0
  147. package/lib/utils/array.js.map +1 -1
  148. package/lib/utils/bemedev/globals/types.d.ts +20 -0
  149. package/lib/utils/bemedev/globals/utils/expandFn.cjs +11 -0
  150. package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -1
  151. package/lib/utils/bemedev/globals/utils/expandFn.d.ts +11 -0
  152. package/lib/utils/bemedev/globals/utils/expandFn.js +11 -0
  153. package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -1
  154. package/lib/utils/identity.cjs +9 -0
  155. package/lib/utils/identity.cjs.map +1 -1
  156. package/lib/utils/identity.d.ts +9 -0
  157. package/lib/utils/identity.js +9 -0
  158. package/lib/utils/identity.js.map +1 -1
  159. package/lib/utils/sleep.cjs +7 -0
  160. package/lib/utils/sleep.cjs.map +1 -1
  161. package/lib/utils/sleep.d.ts +7 -0
  162. package/lib/utils/sleep.js +7 -0
  163. package/lib/utils/sleep.js.map +1 -1
  164. package/lib/utils/types.d.ts +9 -0
  165. package/lib/vitest-exclude/constants.cjs +3 -0
  166. package/lib/vitest-exclude/constants.cjs.map +1 -1
  167. package/lib/vitest-exclude/constants.d.ts +3 -0
  168. package/lib/vitest-exclude/constants.js +3 -0
  169. package/lib/vitest-exclude/constants.js.map +1 -1
  170. package/lib/vitest-exclude/types.d.ts +11 -0
  171. package/lib/vitest-exclude/vitest.cjs +25 -12
  172. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  173. package/lib/vitest-exclude/vitest.d.ts +9 -8
  174. package/lib/vitest-exclude/vitest.js +25 -12
  175. package/lib/vitest-exclude/vitest.js.map +1 -1
  176. package/lib/vitest-exclude/vitest.utils.cjs +30 -0
  177. package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
  178. package/lib/vitest-exclude/vitest.utils.d.ts +30 -0
  179. package/lib/vitest-exclude/vitest.utils.js +30 -0
  180. package/lib/vitest-exclude/vitest.utils.js.map +1 -1
  181. package/lib/vitest-extended/acceptation.cjs +11 -2
  182. package/lib/vitest-extended/acceptation.cjs.map +1 -1
  183. package/lib/vitest-extended/acceptation.d.ts +9 -1
  184. package/lib/vitest-extended/acceptation.js +11 -2
  185. package/lib/vitest-extended/acceptation.js.map +1 -1
  186. package/lib/vitest-extended/createTests.cjs +34 -27
  187. package/lib/vitest-extended/createTests.cjs.map +1 -1
  188. package/lib/vitest-extended/createTests.d.ts +20 -37
  189. package/lib/vitest-extended/createTests.js +34 -27
  190. package/lib/vitest-extended/createTests.js.map +1 -1
  191. package/lib/vitest-extended/createTests.types.d.ts +13 -2
  192. package/lib/vitest-extended/done.cjs +18 -15
  193. package/lib/vitest-extended/done.cjs.map +1 -1
  194. package/lib/vitest-extended/done.d.ts +6 -5
  195. package/lib/vitest-extended/done.js +18 -15
  196. package/lib/vitest-extended/done.js.map +1 -1
  197. package/lib/vitest-extended/each/error.cjs +12 -0
  198. package/lib/vitest-extended/each/error.cjs.map +1 -1
  199. package/lib/vitest-extended/each/error.d.ts +12 -0
  200. package/lib/vitest-extended/each/error.js +12 -0
  201. package/lib/vitest-extended/each/error.js.map +1 -1
  202. package/lib/vitest-extended/each/error.types.d.ts +17 -0
  203. package/lib/vitest-extended/each/pass.cjs +9 -20
  204. package/lib/vitest-extended/each/pass.cjs.map +1 -1
  205. package/lib/vitest-extended/each/pass.d.ts +9 -20
  206. package/lib/vitest-extended/each/pass.js +9 -20
  207. package/lib/vitest-extended/each/pass.js.map +1 -1
  208. package/lib/vitest-extended/each/pass.types.d.ts +24 -0
  209. package/lib/vitest-extended/fakeWaiter.cjs +7 -0
  210. package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
  211. package/lib/vitest-extended/fakeWaiter.d.ts +32 -0
  212. package/lib/vitest-extended/fakeWaiter.js +7 -0
  213. package/lib/vitest-extended/fakeWaiter.js.map +1 -1
  214. package/lib/vitest-extended/fixtures/coverage.cjs +11 -0
  215. package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
  216. package/lib/vitest-extended/fixtures/coverage.js +11 -0
  217. package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
  218. package/lib/vitest-extended/fixtures/partialCall.cjs +9 -4
  219. package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
  220. package/lib/vitest-extended/fixtures/partialCall.js +9 -4
  221. package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
  222. package/lib/vitest-extended/fixtures/toUpper.cjs +18 -0
  223. package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
  224. package/lib/vitest-extended/fixtures/toUpper.js +18 -0
  225. package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
  226. package/lib/vitest-extended/fixtures/vitest.cjs +3 -0
  227. package/lib/vitest-extended/fixtures/vitest.cjs.map +1 -1
  228. package/lib/vitest-extended/fixtures/vitest.js +3 -0
  229. package/lib/vitest-extended/fixtures/vitest.js.map +1 -1
  230. package/lib/vitest-extended/fixtures/zod.cjs +22 -0
  231. package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
  232. package/lib/vitest-extended/fixtures/zod.js +22 -0
  233. package/lib/vitest-extended/fixtures/zod.js.map +1 -1
  234. package/lib/vitest-extended/identity.cjs +18 -0
  235. package/lib/vitest-extended/identity.cjs.map +1 -1
  236. package/lib/vitest-extended/identity.d.ts +18 -0
  237. package/lib/vitest-extended/identity.js +18 -0
  238. package/lib/vitest-extended/identity.js.map +1 -1
  239. package/lib/vitest-extended/isDefined.cjs +9 -0
  240. package/lib/vitest-extended/isDefined.cjs.map +1 -1
  241. package/lib/vitest-extended/isDefined.d.ts +9 -0
  242. package/lib/vitest-extended/isDefined.js +9 -0
  243. package/lib/vitest-extended/isDefined.js.map +1 -1
  244. package/lib/vitest-extended/isFunction.cjs +7 -0
  245. package/lib/vitest-extended/isFunction.cjs.map +1 -1
  246. package/lib/vitest-extended/isFunction.d.ts +7 -0
  247. package/lib/vitest-extended/isFunction.js +7 -0
  248. package/lib/vitest-extended/isFunction.js.map +1 -1
  249. package/lib/vitest-extended/project.cjs +7 -0
  250. package/lib/vitest-extended/project.cjs.map +1 -1
  251. package/lib/vitest-extended/project.d.ts +7 -0
  252. package/lib/vitest-extended/project.js +7 -0
  253. package/lib/vitest-extended/project.js.map +1 -1
  254. package/lib/vitest-extended/toArray.cjs +6 -0
  255. package/lib/vitest-extended/toArray.cjs.map +1 -1
  256. package/lib/vitest-extended/toArray.d.ts +6 -0
  257. package/lib/vitest-extended/toArray.js +6 -0
  258. package/lib/vitest-extended/toArray.js.map +1 -1
  259. package/lib/vitest-extended/toStringFlat.cjs +8 -0
  260. package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
  261. package/lib/vitest-extended/toStringFlat.d.ts +8 -0
  262. package/lib/vitest-extended/toStringFlat.js +8 -0
  263. package/lib/vitest-extended/toStringFlat.js.map +1 -1
  264. package/lib/vitest-extended/types.d.ts +64 -0
  265. package/package.json +14 -9
@@ -3,20 +3,50 @@ let fs = require("fs");
3
3
  let path = require("path");
4
4
  let glob = require("glob");
5
5
  //#region src/vitest-exclude/vitest.utils.ts
6
+ /**
7
+ * Checks if a `src` directory exists at the specified project root.
8
+ *
9
+ * @param root - Root directory path, defaults to `process.cwd()`.
10
+ *
11
+ * @returns `true` if `src` exists, otherwise `false`.
12
+ */
6
13
  const hasSrc = (root = process.cwd()) => {
7
14
  return (0, fs.existsSync)((0, path.join)(root, "src"));
8
15
  };
16
+ /**
17
+ * Computes default coverage glob patterns based on directory structure.
18
+ *
19
+ * @param root - Optional root directory path.
20
+ *
21
+ * @returns Coverage glob pattern string.
22
+ */
9
23
  const defaultCovPattern = (root) => {
10
24
  /* v8 ignore next */
11
25
  return `${hasSrc(root) ? "src/" : ""}**/*.t{s,sx}`;
12
26
  };
13
27
  const mapper = (str) => str.replace(/\\/g, "/");
28
+ /**
29
+ * Resolves glob matches and normalizes file path separators.
30
+ *
31
+ * @param pattern - Glob pattern(s) to match.
32
+ * @param ignore - Optional array of patterns to ignore.
33
+ * @param root - Root working directory.
34
+ *
35
+ * @returns Array of normalized matched file paths.
36
+ */
14
37
  const buildInclude = async (pattern, ignore, root = process.cwd()) => {
15
38
  return (await (0, glob.glob)(pattern, {
16
39
  ignore,
17
40
  cwd: root
18
41
  })).map(mapper).sort();
19
42
  };
43
+ /**
44
+ * Computes default test glob patterns based on directory structure.
45
+ *
46
+ * @param root - Optional root directory path.
47
+ *
48
+ * @returns Test glob pattern string.
49
+ */
20
50
  const testPattern = (root) => {
21
51
  /* v8 ignore next */
22
52
  return `${hasSrc(root) ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.utils.cjs","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;AAKA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,QAAA,GAAA,GAAA,WAAA,EAAA,GAAA,KAAA,KAAA,CAAuB,MAAM,KAAK,CAAC;AACrC;AAEA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;AACtD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,IAAI,MAChB;CAGH,QAAO,OAAA,GAAA,KAAA,KAAA,CAFoB,SAAS;EAAE;EAAQ,KAAK;CAAK,CAAC,EAAA,CAE1C,IAAI,MAAM,CAAC,CAAC,KAAK;AAClC;AAEA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
1
+ {"version":3,"file":"vitest.utils.cjs","names":["existsSync","join"],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\n/**\n * Checks if a `src` directory exists at the specified project root.\n *\n * @param root - Root directory path, defaults to `process.cwd()`.\n *\n * @returns `true` if `src` exists, otherwise `false`.\n */\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\n/**\n * Computes default coverage glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Coverage glob pattern string.\n */\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\n\n/**\n * Resolves glob matches and normalizes file path separators.\n *\n * @param pattern - Glob pattern(s) to match.\n * @param ignore - Optional array of patterns to ignore.\n * @param root - Root working directory.\n *\n * @returns Array of normalized matched file paths.\n */\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\n/**\n * Computes default test glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Test glob pattern string.\n */\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;;;;;;;;AAYA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,QAAA,GAAOA,GAAAA,WAAAA,EAAAA,GAAWC,KAAAA,KAAAA,CAAK,MAAM,KAAK,CAAC;AACrC;;;;;;;;AASA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;;;;;;;;;;AAWtD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,IAAI,MAChB;CAGH,QAAO,OAAA,GAFe,KAAA,KAAA,CAAK,SAAS;EAAE;EAAQ,KAAK;CAAK,CAAC,EAAA,CAE1C,IAAI,MAAM,CAAC,CAAC,KAAK;AAClC;;;;;;;;AASA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
@@ -1,4 +1,34 @@
1
+ /**
2
+ * Checks if a `src` directory exists at the specified project root.
3
+ *
4
+ * @param root - Root directory path, defaults to `process.cwd()`.
5
+ *
6
+ * @returns `true` if `src` exists, otherwise `false`.
7
+ */
1
8
  export declare const hasSrc: (root?: string) => boolean;
9
+ /**
10
+ * Computes default coverage glob patterns based on directory structure.
11
+ *
12
+ * @param root - Optional root directory path.
13
+ *
14
+ * @returns Coverage glob pattern string.
15
+ */
2
16
  export declare const defaultCovPattern: (root?: string) => string;
17
+ /**
18
+ * Resolves glob matches and normalizes file path separators.
19
+ *
20
+ * @param pattern - Glob pattern(s) to match.
21
+ * @param ignore - Optional array of patterns to ignore.
22
+ * @param root - Root working directory.
23
+ *
24
+ * @returns Array of normalized matched file paths.
25
+ */
3
26
  export declare const buildInclude: (pattern: string | string[], ignore?: string[], root?: string) => Promise<string[]>;
27
+ /**
28
+ * Computes default test glob patterns based on directory structure.
29
+ *
30
+ * @param root - Optional root directory path.
31
+ *
32
+ * @returns Test glob pattern string.
33
+ */
4
34
  export declare const testPattern: (root?: string) => string;
@@ -2,20 +2,50 @@ import { existsSync } from "fs";
2
2
  import { join } from "path";
3
3
  import { glob } from "glob";
4
4
  //#region src/vitest-exclude/vitest.utils.ts
5
+ /**
6
+ * Checks if a `src` directory exists at the specified project root.
7
+ *
8
+ * @param root - Root directory path, defaults to `process.cwd()`.
9
+ *
10
+ * @returns `true` if `src` exists, otherwise `false`.
11
+ */
5
12
  const hasSrc = (root = process.cwd()) => {
6
13
  return existsSync(join(root, "src"));
7
14
  };
15
+ /**
16
+ * Computes default coverage glob patterns based on directory structure.
17
+ *
18
+ * @param root - Optional root directory path.
19
+ *
20
+ * @returns Coverage glob pattern string.
21
+ */
8
22
  const defaultCovPattern = (root) => {
9
23
  /* v8 ignore next */
10
24
  return `${hasSrc(root) ? "src/" : ""}**/*.t{s,sx}`;
11
25
  };
12
26
  const mapper = (str) => str.replace(/\\/g, "/");
27
+ /**
28
+ * Resolves glob matches and normalizes file path separators.
29
+ *
30
+ * @param pattern - Glob pattern(s) to match.
31
+ * @param ignore - Optional array of patterns to ignore.
32
+ * @param root - Root working directory.
33
+ *
34
+ * @returns Array of normalized matched file paths.
35
+ */
13
36
  const buildInclude = async (pattern, ignore, root = process.cwd()) => {
14
37
  return (await glob(pattern, {
15
38
  ignore,
16
39
  cwd: root
17
40
  })).map(mapper).sort();
18
41
  };
42
+ /**
43
+ * Computes default test glob patterns based on directory structure.
44
+ *
45
+ * @param root - Optional root directory path.
46
+ *
47
+ * @returns Test glob pattern string.
48
+ */
19
49
  const testPattern = (root) => {
20
50
  /* v8 ignore next */
21
51
  return `${hasSrc(root) ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.utils.js","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;AAKA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,OAAO,WAAW,KAAK,MAAM,KAAK,CAAC;AACrC;AAEA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;AACtD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,IAAI,MAChB;CAGH,QAAO,MAFe,KAAK,SAAS;EAAE;EAAQ,KAAK;CAAK,CAAC,EAAA,CAE1C,IAAI,MAAM,CAAC,CAAC,KAAK;AAClC;AAEA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
1
+ {"version":3,"file":"vitest.utils.js","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { join } from 'node:path';\n\nimport { glob } from 'glob';\n\n/**\n * Checks if a `src` directory exists at the specified project root.\n *\n * @param root - Root directory path, defaults to `process.cwd()`.\n *\n * @returns `true` if `src` exists, otherwise `false`.\n */\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\n/**\n * Computes default coverage glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Coverage glob pattern string.\n */\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\n\n/**\n * Resolves glob matches and normalizes file path separators.\n *\n * @param pattern - Glob pattern(s) to match.\n * @param ignore - Optional array of patterns to ignore.\n * @param root - Root working directory.\n *\n * @returns Array of normalized matched file paths.\n */\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, { ignore, cwd: root });\n\n return include.map(mapper).sort();\n};\n\n/**\n * Computes default test glob patterns based on directory structure.\n *\n * @param root - Optional root directory path.\n *\n * @returns Test glob pattern string.\n */\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;;;;;;;AAYA,MAAa,UAAU,OAAO,QAAQ,IAAI,MAAM;CAC9C,OAAO,WAAW,KAAK,MAAM,KAAK,CAAC;AACrC;;;;;;;;AASA,MAAa,qBAAqB,SAAkB;;CAGlD,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B;AAEA,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,GAAG;;;;;;;;;;AAWtD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,IAAI,MAChB;CAGH,QAAO,MAFe,KAAK,SAAS;EAAE;EAAQ,KAAK;CAAK,CAAC,EAAA,CAE1C,IAAI,MAAM,CAAC,CAAC,KAAK;AAClC;;;;;;;;AASA,MAAa,eAAe,SAAkB;;CAG5C,OAAO,GAFM,OAAO,IAEP,IAAI,SAAS,GAAG;AAC/B"}
@@ -2,16 +2,25 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_vitest_extended_isFunction = require("./isFunction.cjs");
3
3
  let vitest = require("vitest");
4
4
  //#region src/vitest-extended/acceptation.ts
5
+ /**
6
+ * Creates baseline definition and function type tests for a given function.
7
+ *
8
+ * @param f - Target function to test of type {@linkcode Fn}.
9
+ * @param _name - Optional custom name for test assertions.
10
+ */
5
11
  const useTestFunctionAcceptation = (f, _name) => {
6
12
  const name = _name ?? f.name;
7
13
  (0, vitest.test)(`#01 => ${name} is defined`, () => {
8
14
  (0, vitest.expect)(f).toBeDefined();
9
15
  });
10
16
  (0, vitest.test)(`#02 => ${name} is a function`, () => {
11
- (0, vitest.expect)(require_vitest_extended_isFunction.isFunction(f)).toBe(true);
17
+ const check = require_vitest_extended_isFunction.isFunction(f);
18
+ (0, vitest.expect)(check).toBe(true);
12
19
  });
13
20
  };
14
- /** For test only useTestFunctionAcceptation */
21
+ /**
22
+ * Alias for {@linkcode useTestFunctionAcceptation}.
23
+ */
15
24
  const useTFA = useTestFunctionAcceptation;
16
25
  //#endregion
17
26
  exports.useTFA = useTFA;
@@ -1 +1 @@
1
- {"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;AAKA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,oBAAoB;EACtC,CAAA,GAAA,OAAA,OAAA,CAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,uBAAuB;EAEzC,CAAA,GAAA,OAAA,OAAA,CADcA,mCAAAA,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
1
+ {"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\n/**\n * Creates baseline definition and function type tests for a given function.\n *\n * @param f - Target function to test of type {@linkcode Fn}.\n * @param _name - Optional custom name for test assertions.\n */\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/**\n * Alias for {@linkcode useTestFunctionAcceptation}.\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;;;;;;;AAWA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,oBAAoB;EACtC,CAAA,GAAA,OAAA,OAAA,CAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,uBAAuB;EACzC,MAAM,QAAQA,mCAAAA,WAAW,CAAC;EAC1B,CAAA,GAAA,OAAA,OAAA,CAAO,KAAK,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;;;AAKA,MAAa,SAAS"}
@@ -1,4 +1,12 @@
1
1
  import type { Fn } from '../utils/bemedev/globals/types';
2
+ /**
3
+ * Creates baseline definition and function type tests for a given function.
4
+ *
5
+ * @param f - Target function to test of type {@linkcode Fn}.
6
+ * @param _name - Optional custom name for test assertions.
7
+ */
2
8
  export declare const useTestFunctionAcceptation: (f: Fn, _name?: string) => void;
3
- /** For test only useTestFunctionAcceptation */
9
+ /**
10
+ * Alias for {@linkcode useTestFunctionAcceptation}.
11
+ */
4
12
  export declare const useTFA: (f: Fn, _name?: string) => void;
@@ -1,16 +1,25 @@
1
1
  import { isFunction } from "./isFunction.js";
2
2
  import { expect, test } from "vitest";
3
3
  //#region src/vitest-extended/acceptation.ts
4
+ /**
5
+ * Creates baseline definition and function type tests for a given function.
6
+ *
7
+ * @param f - Target function to test of type {@linkcode Fn}.
8
+ * @param _name - Optional custom name for test assertions.
9
+ */
4
10
  const useTestFunctionAcceptation = (f, _name) => {
5
11
  const name = _name ?? f.name;
6
12
  test(`#01 => ${name} is defined`, () => {
7
13
  expect(f).toBeDefined();
8
14
  });
9
15
  test(`#02 => ${name} is a function`, () => {
10
- expect(isFunction(f)).toBe(true);
16
+ const check = isFunction(f);
17
+ expect(check).toBe(true);
11
18
  });
12
19
  };
13
- /** For test only useTestFunctionAcceptation */
20
+ /**
21
+ * Alias for {@linkcode useTestFunctionAcceptation}.
22
+ */
14
23
  const useTFA = useTestFunctionAcceptation;
15
24
  //#endregion
16
25
  export { useTFA, useTestFunctionAcceptation };
@@ -1 +1 @@
1
- {"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;AAKA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,KAAK,UAAU,KAAK,oBAAoB;EACtC,OAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,KAAK,UAAU,KAAK,uBAAuB;EAEzC,OADc,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
1
+ {"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\n/**\n * Creates baseline definition and function type tests for a given function.\n *\n * @param f - Target function to test of type {@linkcode Fn}.\n * @param _name - Optional custom name for test assertions.\n */\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/**\n * Alias for {@linkcode useTestFunctionAcceptation}.\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;;;;;;AAWA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,KAAK,UAAU,KAAK,oBAAoB;EACtC,OAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,KAAK,UAAU,KAAK,uBAAuB;EACzC,MAAM,QAAQ,WAAW,CAAC;EAC1B,OAAO,KAAK,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;;;AAKA,MAAa,SAAS"}
@@ -36,42 +36,49 @@ const _create = (func, transform, toError, name) => {
36
36
  };
37
37
  };
38
38
  /**
39
- * Creates tests for function in a better way NB : We use strict-equality,
40
- * {@link useEach|see}
39
+ * Creates structured test suites with acceptation, success, and failure runners.
41
40
  *
42
- * @example
43
- * // ./add.ts
44
- * *export const add = (args: string[]) => args.reduce(
45
- * (acc, value) => {
46
- * acc+=value
47
- * return acc;
48
- * },
49
- * 0)
50
- *
51
- *
52
- * // .add.test.ts
53
- * *import { createTests } from '@bemedev/vitest-extended';
54
- * *import { add } from './add';
41
+ * @template `F0` - Function parameters array type.
42
+ * @template `F1` - Function return value type.
43
+ * @template `F2` - Transformed return value type, defaults to `F1`.
55
44
  *
56
- * *const useTests = createTests(add)
45
+ * @param func - Function under test of type {@linkcode Fn}.
46
+ * @param args - Configuration options.
47
+ * @param args.transform - Optional output transformer of type {@linkcode Fn}.
48
+ * @param args.toError - Optional error mapping function of type {@linkcode Fn}.
57
49
  *
58
- * *useTests(
59
- * {
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!
62
- * }
63
- * )
50
+ * @returns Test suite object with acceptation, success, and fails methods.
64
51
  *
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,
52
+ * @example
53
+ * ```ts
54
+ * const useTests = createTests(add);
55
+ * useTests.success({
56
+ * invite: 'For : 1,2,3',
57
+ * parameters: [[1, 2, 3]],
58
+ * expected: 6,
59
+ * })();
60
+ * ```
70
61
  */
71
62
  const createTests = (func, args) => {
72
63
  const { transform, toError } = args || {};
73
64
  return _create(func, transform, toError);
74
65
  };
66
+ /**
67
+ * Creates structured test suites with an async instantiation or mock implementation.
68
+ *
69
+ * @template `F0` - Function parameters array type.
70
+ * @template `F1` - Function return value type.
71
+ * @template `F2` - Transformed return value type, defaults to `F1`.
72
+ *
73
+ * @param f - Fallback or default function of type {@linkcode Fn}.
74
+ * @param options - Configuration options for instantiation and formatting.
75
+ * @param options.instanciation - Async function returning the target implementation.
76
+ * @param options.name - Name identifier for test descriptions.
77
+ * @param options.transform - Optional output transformer.
78
+ * @param options.toError - Optional error mapping function.
79
+ *
80
+ * @returns Test suite object with acceptation, success, and fails methods.
81
+ */
75
82
  createTests.withImplementation = (f, { instanciation, name, transform, toError }) => {
76
83
  const func = vitest.vi.fn(f);
77
84
  if (instanciation) (0, vitest.beforeAll)(async () => {
@@ -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';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\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
+ {"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 type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport { useEachAsync } 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 structured test suites with acceptation, success, and failure runners.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param func - Function under test of type {@linkcode Fn}.\n * @param args - Configuration options.\n * @param args.transform - Optional output transformer of type {@linkcode Fn}.\n * @param args.toError - Optional error mapping function of type {@linkcode Fn}.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n *\n * @example\n * ```ts\n * const useTests = createTests(add);\n * useTests.success({\n * invite: 'For : 1,2,3',\n * parameters: [[1, 2, 3]],\n * expected: 6,\n * })();\n * ```\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\n/**\n * Creates structured test suites with an async instantiation or mock implementation.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param f - Fallback or default function of type {@linkcode Fn}.\n * @param options - Configuration options for instantiation and formatting.\n * @param options.instanciation - Async function returning the target implementation.\n * @param options.name - Name identifier for test descriptions.\n * @param options.transform - Optional output transformer.\n * @param options.toError - Optional error mapping function.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\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":";;;;;;;AAWA,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;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;;;;;;;;;;;;;;;;;AAkBA,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"}
@@ -2,56 +2,39 @@ import type { Fn } from '../utils/bemedev/globals/types';
2
2
  import type { _CreateTests_F } from './createTests.types';
3
3
  export type { _CreateTests_F };
4
4
  /**
5
- * Creates tests for function in a better way NB : We use strict-equality,
6
- * {@link useEach|see}
7
- *
8
- * @example
9
- * // ./add.ts
10
- * *export const add = (args: string[]) => args.reduce(
11
- * (acc, value) => {
12
- * acc+=value
13
- * return acc;
14
- * },
15
- * 0)
5
+ * Creates structured test suites with acceptation, success, and failure runners.
16
6
  *
7
+ * @template `F0` - Function parameters array type.
8
+ * @template `F1` - Function return value type.
9
+ * @template `F2` - Transformed return value type, defaults to `F1`.
17
10
  *
18
- * // .add.test.ts
19
- * *import { createTests } from '@bemedev/vitest-extended';
20
- * *import { add } from './add';
11
+ * @param func - Function under test of type {@linkcode Fn}.
12
+ * @param args - Configuration options.
13
+ * @param args.transform - Optional output transformer of type {@linkcode Fn}.
14
+ * @param args.toError - Optional error mapping function of type {@linkcode Fn}.
21
15
  *
22
- * *const useTests = createTests(add)
16
+ * @returns Test suite object with acceptation, success, and fails methods.
23
17
  *
24
- * *useTests(
25
- * {
26
- * invite: 'For : 1,2,3,4,5,6,7,8,9',
27
- * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
28
- * }
29
- * )
30
- *
31
- * @param library The test library
32
- * @param f The function to test
33
- * @param *
34
- * @returns A test.each like function to tests many cases NB: If the first
35
- * argument is an array, wrap the value in another array,
18
+ * @example
19
+ * ```ts
20
+ * const useTests = createTests(add);
21
+ * useTests.success({
22
+ * invite: 'For : 1,2,3',
23
+ * parameters: [[1, 2, 3]],
24
+ * expected: 6,
25
+ * })();
26
+ * ```
36
27
  */
37
28
  export declare const createTests: {
38
29
  <F0 extends any[], F1, F2 = F1>(func: Fn<F0, F1>, args?: {
39
30
  transform?: Fn<[Awaited<F1>], F2>;
40
31
  toError?: Fn<F0, string | undefined>;
41
- }): {
42
- acceptation: () => void;
43
- success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
44
- fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
45
- };
32
+ }): import("./createTests.types").ReturnR<Fn<F0, F2>>;
46
33
  withImplementation<F0 extends any[], F1, F2 = F1>(f: Fn<NoInfer<F0>, NoInfer<F1>>, { instanciation, name, transform, toError, }: {
47
34
  instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;
48
35
  name: string;
49
36
  transform?: Fn<[Awaited<F1>], F2>;
50
37
  toError?: Fn<F0, string | undefined>;
51
- }): {
52
- acceptation: () => void;
53
- success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
54
- fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
55
- };
38
+ }): import("./createTests.types").ReturnR<Fn<F0, F2>>;
56
39
  withoutImplementation: /*elided*/ any;
57
40
  };
@@ -35,42 +35,49 @@ const _create = (func, transform, toError, name) => {
35
35
  };
36
36
  };
37
37
  /**
38
- * Creates tests for function in a better way NB : We use strict-equality,
39
- * {@link useEach|see}
38
+ * Creates structured test suites with acceptation, success, and failure runners.
40
39
  *
41
- * @example
42
- * // ./add.ts
43
- * *export const add = (args: string[]) => args.reduce(
44
- * (acc, value) => {
45
- * acc+=value
46
- * return acc;
47
- * },
48
- * 0)
49
- *
50
- *
51
- * // .add.test.ts
52
- * *import { createTests } from '@bemedev/vitest-extended';
53
- * *import { add } from './add';
40
+ * @template `F0` - Function parameters array type.
41
+ * @template `F1` - Function return value type.
42
+ * @template `F2` - Transformed return value type, defaults to `F1`.
54
43
  *
55
- * *const useTests = createTests(add)
44
+ * @param func - Function under test of type {@linkcode Fn}.
45
+ * @param args - Configuration options.
46
+ * @param args.transform - Optional output transformer of type {@linkcode Fn}.
47
+ * @param args.toError - Optional error mapping function of type {@linkcode Fn}.
56
48
  *
57
- * *useTests(
58
- * {
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!
61
- * }
62
- * )
49
+ * @returns Test suite object with acceptation, success, and fails methods.
63
50
  *
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,
51
+ * @example
52
+ * ```ts
53
+ * const useTests = createTests(add);
54
+ * useTests.success({
55
+ * invite: 'For : 1,2,3',
56
+ * parameters: [[1, 2, 3]],
57
+ * expected: 6,
58
+ * })();
59
+ * ```
69
60
  */
70
61
  const createTests = (func, args) => {
71
62
  const { transform, toError } = args || {};
72
63
  return _create(func, transform, toError);
73
64
  };
65
+ /**
66
+ * Creates structured test suites with an async instantiation or mock implementation.
67
+ *
68
+ * @template `F0` - Function parameters array type.
69
+ * @template `F1` - Function return value type.
70
+ * @template `F2` - Transformed return value type, defaults to `F1`.
71
+ *
72
+ * @param f - Fallback or default function of type {@linkcode Fn}.
73
+ * @param options - Configuration options for instantiation and formatting.
74
+ * @param options.instanciation - Async function returning the target implementation.
75
+ * @param options.name - Name identifier for test descriptions.
76
+ * @param options.transform - Optional output transformer.
77
+ * @param options.toError - Optional error mapping function.
78
+ *
79
+ * @returns Test suite object with acceptation, success, and fails methods.
80
+ */
74
81
  createTests.withImplementation = (f, { instanciation, name, transform, toError }) => {
75
82
  const func = vi.fn(f);
76
83
  if (instanciation) beforeAll(async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\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
+ {"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport { useEachAsync } 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 structured test suites with acceptation, success, and failure runners.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param func - Function under test of type {@linkcode Fn}.\n * @param args - Configuration options.\n * @param args.transform - Optional output transformer of type {@linkcode Fn}.\n * @param args.toError - Optional error mapping function of type {@linkcode Fn}.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\n *\n * @example\n * ```ts\n * const useTests = createTests(add);\n * useTests.success({\n * invite: 'For : 1,2,3',\n * parameters: [[1, 2, 3]],\n * expected: 6,\n * })();\n * ```\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\n/**\n * Creates structured test suites with an async instantiation or mock implementation.\n *\n * @template `F0` - Function parameters array type.\n * @template `F1` - Function return value type.\n * @template `F2` - Transformed return value type, defaults to `F1`.\n *\n * @param f - Fallback or default function of type {@linkcode Fn}.\n * @param options - Configuration options for instantiation and formatting.\n * @param options.instanciation - Async function returning the target implementation.\n * @param options.name - Name identifier for test descriptions.\n * @param options.transform - Optional output transformer.\n * @param options.toError - Optional error mapping function.\n *\n * @returns Test suite object with acceptation, success, and fails methods.\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":";;;;;;AAWA,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;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;;;;;;;;;;;;;;;;;AAkBA,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,20 @@
1
1
  import type { Fn } from '../utils/bemedev/globals/types';
2
2
  import type { TestArgs, TestErrors } from './types';
3
- type ReturnR<F extends Fn> = {
3
+ /**
4
+ * Return interface for test suite generator containing acceptation, success, and fails methods.
5
+ *
6
+ * @template | {@linkcode Fn} `F` - Target test function type.
7
+ */
8
+ export type ReturnR<F extends Fn> = {
4
9
  acceptation: () => void;
5
10
  success: (...cases: TestArgs<F>) => () => void;
6
11
  fails: (...cases: TestErrors<F>) => () => void;
7
12
  };
13
+ /**
14
+ * Internal function signature for creating a test suite structure.
15
+ *
16
+ * @template `F0` - Function parameters array type.
17
+ * @template `F1` - Function return value type.
18
+ * @template `F2` - Transformed return type, defaults to `F1`.
19
+ */
8
20
  export type _CreateTests_F = <F0 extends any[], F1, F2 = F1>(func: Fn<F0, F1>, transform?: Fn<[Awaited<F1>], F2>, toError?: Fn<F0, string | undefined>, name?: string) => ReturnR<Fn<F0, F2>>;
9
- export {};
@@ -30,12 +30,13 @@ const objectify = (options) => {
30
30
  return [_options, _timeout];
31
31
  };
32
32
  /**
33
- * Build a test with a done function with a timeout
33
+ * Build a test with a done callback function and a timeout.
34
34
  *
35
- * @param invite The description of the test
36
- * @param fn Where you can test, Don't async this function
37
- * @param options Options for the test like TestAPI from vitest
38
- * @returns A vitest test
35
+ * @param invite - The description of the test.
36
+ * @param fn - Test callback function of type {@linkcode TestDoneFunction}.
37
+ * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.
38
+ *
39
+ * @returns A Vitest test execution result.
39
40
  */
40
41
  const doneTest = (invite, fn, options = 100) => {
41
42
  const [_options, ms] = objectify(options);
@@ -46,12 +47,13 @@ const doneTest = (invite, fn, options = 100) => {
46
47
  });
47
48
  };
48
49
  /**
49
- * Build a test that fails with a done function with a timeout
50
+ * Build a test expected to fail with a done callback function and a timeout.
51
+ *
52
+ * @param invite - The description of the test.
53
+ * @param fn - Test callback function of type {@linkcode TestDoneFunction}.
54
+ * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.
50
55
  *
51
- * @param invite The description of the test
52
- * @param fn Where you can test, Don't async this function
53
- * @param options Options for the test like TestAPI from vitest
54
- * @returns A vitest test
56
+ * @returns A Vitest test execution result.
55
57
  */
56
58
  doneTest.fails = (invite, fn, options = 100) => {
57
59
  const [_options, ms] = objectify(options);
@@ -62,12 +64,13 @@ doneTest.fails = (invite, fn, options = 100) => {
62
64
  });
63
65
  };
64
66
  /**
65
- * Build a concurrent test with a done function with a timeout
67
+ * Build a concurrent test with a done callback function and a timeout.
68
+ *
69
+ * @param invite - The description of the test.
70
+ * @param fn - Test callback function of type {@linkcode TestDoneFunction}.
71
+ * @param options - Timeout in milliseconds or test options of type {@linkcode TestOptions}.
66
72
  *
67
- * @param invite The description of the test
68
- * @param fn Where you can test, Don't async this function
69
- * @param options Options for the test like TestAPI from vitest
70
- * @returns A vitest test
73
+ * @returns A Vitest test execution result.
71
74
  */
72
75
  doneTest.concurrent = (invite, fn, options = 100) => {
73
76
  const [_options, ms] = objectify(options);