@thisisagile/easy-test 19.1.3 → 20.0.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 (197) hide show
  1. package/dist/index.d.ts +24 -2
  2. package/dist/index.js +22 -618
  3. package/dist/matchers/Check.d.ts +13 -10
  4. package/dist/matchers/Check.js +42 -0
  5. package/dist/matchers/Check.js.map +1 -0
  6. package/dist/matchers/HttpMatchers.d.ts +19 -16
  7. package/dist/matchers/HttpMatchers.js +32 -0
  8. package/dist/matchers/HttpMatchers.js.map +1 -0
  9. package/dist/matchers/Match.d.ts +11 -8
  10. package/dist/matchers/Match.js +35 -0
  11. package/dist/matchers/Match.js.map +1 -0
  12. package/dist/matchers/ResultMatchers.d.ts +10 -7
  13. package/dist/matchers/ResultMatchers.js +18 -0
  14. package/dist/matchers/ResultMatchers.js.map +1 -0
  15. package/dist/matchers/index.d.ts +20 -19
  16. package/dist/matchers/index.js +20 -0
  17. package/dist/matchers/toBeArrayOf.d.ts +9 -6
  18. package/dist/matchers/toBeArrayOf.js +8 -0
  19. package/dist/matchers/toBeArrayOf.js.map +1 -0
  20. package/dist/matchers/toBeArrayOfWithLength.d.ts +9 -6
  21. package/dist/matchers/toBeArrayOfWithLength.js +8 -0
  22. package/dist/matchers/toBeArrayOfWithLength.js.map +1 -0
  23. package/dist/matchers/toBeAt.d.ts +8 -5
  24. package/dist/matchers/toBeAt.js +10 -0
  25. package/dist/matchers/toBeAt.js.map +1 -0
  26. package/dist/matchers/toBeExactlyAt.d.ts +8 -5
  27. package/dist/matchers/toBeExactlyAt.js +15 -0
  28. package/dist/matchers/toBeExactlyAt.js.map +1 -0
  29. package/dist/matchers/toBeQueriedWith.d.ts +8 -5
  30. package/dist/matchers/toBeQueriedWith.js +8 -0
  31. package/dist/matchers/toBeQueriedWith.js.map +1 -0
  32. package/dist/matchers/toBeRoutedTo.d.ts +8 -5
  33. package/dist/matchers/toBeRoutedTo.js +14 -0
  34. package/dist/matchers/toBeRoutedTo.js.map +1 -0
  35. package/dist/matchers/toBeValid.d.ts +7 -4
  36. package/dist/matchers/toBeValid.js +9 -0
  37. package/dist/matchers/toBeValid.js.map +1 -0
  38. package/dist/matchers/toFailMatcher.d.ts +13 -10
  39. package/dist/matchers/toFailMatcher.js +21 -0
  40. package/dist/matchers/toFailMatcher.js.map +1 -0
  41. package/dist/matchers/toMatchArray.d.ts +7 -4
  42. package/dist/matchers/toMatchArray.js +10 -0
  43. package/dist/matchers/toMatchArray.js.map +1 -0
  44. package/dist/matchers/toMatchExactJson.d.ts +11 -8
  45. package/dist/matchers/toMatchExactJson.js +15 -0
  46. package/dist/matchers/toMatchExactJson.js.map +1 -0
  47. package/dist/matchers/toMatchException.d.ts +8 -5
  48. package/dist/matchers/toMatchException.js +9 -0
  49. package/dist/matchers/toMatchException.js.map +1 -0
  50. package/dist/matchers/toMatchJson.d.ts +11 -8
  51. package/dist/matchers/toMatchJson.js +16 -0
  52. package/dist/matchers/toMatchJson.js.map +1 -0
  53. package/dist/matchers/toMatchRoute.d.ts +8 -5
  54. package/dist/matchers/toMatchRoute.js +9 -0
  55. package/dist/matchers/toMatchRoute.js.map +1 -0
  56. package/dist/matchers/toMatchText.d.ts +7 -4
  57. package/dist/matchers/toMatchText.js +9 -0
  58. package/dist/matchers/toMatchText.js.map +1 -0
  59. package/dist/matchers/toPassMatcher.d.ts +13 -10
  60. package/dist/matchers/toPassMatcher.js +21 -0
  61. package/dist/matchers/toPassMatcher.js.map +1 -0
  62. package/dist/mock/Fits.d.ts +19 -16
  63. package/dist/mock/Fits.js +42 -0
  64. package/dist/mock/Fits.js.map +1 -0
  65. package/dist/mock/Mocks.d.ts +38 -35
  66. package/dist/mock/Mocks.js +68 -0
  67. package/dist/mock/Mocks.js.map +1 -0
  68. package/dist/mock/index.d.ts +3 -2
  69. package/dist/mock/index.js +3 -0
  70. package/dist/utils/Eq.d.ts +6 -3
  71. package/dist/utils/Eq.js +12 -0
  72. package/dist/utils/Eq.js.map +1 -0
  73. package/dist/utils/Req.d.ts +15 -12
  74. package/dist/utils/Req.js +35 -0
  75. package/dist/utils/Req.js.map +1 -0
  76. package/dist/utils/Response.d.ts +22 -19
  77. package/dist/utils/Response.js +0 -0
  78. package/dist/utils/Types.d.ts +18 -17
  79. package/dist/utils/Types.js +7 -0
  80. package/dist/utils/Types.js.map +1 -0
  81. package/dist/utils/Utils.d.ts +4 -1
  82. package/dist/utils/Utils.js +19 -0
  83. package/dist/utils/Utils.js.map +1 -0
  84. package/package.json +36 -34
  85. package/dist/chunk-6EKWTLNQ.mjs +0 -12
  86. package/dist/chunk-6EKWTLNQ.mjs.map +0 -1
  87. package/dist/chunk-6FEQASGO.mjs +0 -17
  88. package/dist/chunk-6FEQASGO.mjs.map +0 -1
  89. package/dist/chunk-ART72TJA.mjs +0 -25
  90. package/dist/chunk-ART72TJA.mjs.map +0 -1
  91. package/dist/chunk-BN2IG45X.mjs +0 -24
  92. package/dist/chunk-BN2IG45X.mjs.map +0 -1
  93. package/dist/chunk-BZXBZCMZ.mjs +0 -26
  94. package/dist/chunk-BZXBZCMZ.mjs.map +0 -1
  95. package/dist/chunk-CQPHLHB7.mjs +0 -86
  96. package/dist/chunk-CQPHLHB7.mjs.map +0 -1
  97. package/dist/chunk-DHDFXV7G.mjs +0 -53
  98. package/dist/chunk-DHDFXV7G.mjs.map +0 -1
  99. package/dist/chunk-DMSYYRBM.mjs +0 -59
  100. package/dist/chunk-DMSYYRBM.mjs.map +0 -1
  101. package/dist/chunk-EZNTPFD2.mjs +0 -39
  102. package/dist/chunk-EZNTPFD2.mjs.map +0 -1
  103. package/dist/chunk-GRYVDJXU.mjs +0 -1
  104. package/dist/chunk-GRYVDJXU.mjs.map +0 -1
  105. package/dist/chunk-LN24S2PC.mjs +0 -41
  106. package/dist/chunk-LN24S2PC.mjs.map +0 -1
  107. package/dist/chunk-MBQSBGEE.mjs +0 -1
  108. package/dist/chunk-MBQSBGEE.mjs.map +0 -1
  109. package/dist/chunk-O475TEG2.mjs +0 -30
  110. package/dist/chunk-O475TEG2.mjs.map +0 -1
  111. package/dist/chunk-PPXFT3SX.mjs +0 -14
  112. package/dist/chunk-PPXFT3SX.mjs.map +0 -1
  113. package/dist/chunk-QE3TR4BY.mjs +0 -16
  114. package/dist/chunk-QE3TR4BY.mjs.map +0 -1
  115. package/dist/chunk-QWLALNJL.mjs +0 -30
  116. package/dist/chunk-QWLALNJL.mjs.map +0 -1
  117. package/dist/chunk-RPYWAKYZ.mjs +0 -39
  118. package/dist/chunk-RPYWAKYZ.mjs.map +0 -1
  119. package/dist/chunk-SGV4XPW3.mjs +0 -27
  120. package/dist/chunk-SGV4XPW3.mjs.map +0 -1
  121. package/dist/chunk-SJR3TRWF.mjs +0 -39
  122. package/dist/chunk-SJR3TRWF.mjs.map +0 -1
  123. package/dist/chunk-TUE23FNE.mjs +0 -17
  124. package/dist/chunk-TUE23FNE.mjs.map +0 -1
  125. package/dist/chunk-UFDXFCRK.mjs +0 -19
  126. package/dist/chunk-UFDXFCRK.mjs.map +0 -1
  127. package/dist/chunk-UOO6EMXQ.mjs +0 -20
  128. package/dist/chunk-UOO6EMXQ.mjs.map +0 -1
  129. package/dist/chunk-WAKTWLNU.mjs +0 -32
  130. package/dist/chunk-WAKTWLNU.mjs.map +0 -1
  131. package/dist/chunk-YL7PRCYP.mjs +0 -26
  132. package/dist/chunk-YL7PRCYP.mjs.map +0 -1
  133. package/dist/chunk-Z4XAP66Q.mjs +0 -44
  134. package/dist/chunk-Z4XAP66Q.mjs.map +0 -1
  135. package/dist/chunk-Z6NXMCUL.mjs +0 -17
  136. package/dist/chunk-Z6NXMCUL.mjs.map +0 -1
  137. package/dist/chunk-ZBSBLFC7.mjs +0 -20
  138. package/dist/chunk-ZBSBLFC7.mjs.map +0 -1
  139. package/dist/index.js.map +0 -1
  140. package/dist/index.mjs +0 -151
  141. package/dist/index.mjs.map +0 -1
  142. package/dist/matchers/Check.mjs +0 -10
  143. package/dist/matchers/Check.mjs.map +0 -1
  144. package/dist/matchers/HttpMatchers.mjs +0 -32
  145. package/dist/matchers/HttpMatchers.mjs.map +0 -1
  146. package/dist/matchers/Match.mjs +0 -11
  147. package/dist/matchers/Match.mjs.map +0 -1
  148. package/dist/matchers/ResultMatchers.mjs +0 -14
  149. package/dist/matchers/ResultMatchers.mjs.map +0 -1
  150. package/dist/matchers/index.mjs +0 -133
  151. package/dist/matchers/index.mjs.map +0 -1
  152. package/dist/matchers/toBeArrayOf.mjs +0 -10
  153. package/dist/matchers/toBeArrayOf.mjs.map +0 -1
  154. package/dist/matchers/toBeArrayOfWithLength.mjs +0 -10
  155. package/dist/matchers/toBeArrayOfWithLength.mjs.map +0 -1
  156. package/dist/matchers/toBeAt.mjs +0 -10
  157. package/dist/matchers/toBeAt.mjs.map +0 -1
  158. package/dist/matchers/toBeExactlyAt.mjs +0 -10
  159. package/dist/matchers/toBeExactlyAt.mjs.map +0 -1
  160. package/dist/matchers/toBeQueriedWith.mjs +0 -10
  161. package/dist/matchers/toBeQueriedWith.mjs.map +0 -1
  162. package/dist/matchers/toBeRoutedTo.mjs +0 -15
  163. package/dist/matchers/toBeRoutedTo.mjs.map +0 -1
  164. package/dist/matchers/toBeValid.mjs +0 -10
  165. package/dist/matchers/toBeValid.mjs.map +0 -1
  166. package/dist/matchers/toFailMatcher.mjs +0 -16
  167. package/dist/matchers/toFailMatcher.mjs.map +0 -1
  168. package/dist/matchers/toMatchArray.mjs +0 -9
  169. package/dist/matchers/toMatchArray.mjs.map +0 -1
  170. package/dist/matchers/toMatchExactJson.mjs +0 -13
  171. package/dist/matchers/toMatchExactJson.mjs.map +0 -1
  172. package/dist/matchers/toMatchException.mjs +0 -10
  173. package/dist/matchers/toMatchException.mjs.map +0 -1
  174. package/dist/matchers/toMatchJson.mjs +0 -13
  175. package/dist/matchers/toMatchJson.mjs.map +0 -1
  176. package/dist/matchers/toMatchRoute.mjs +0 -10
  177. package/dist/matchers/toMatchRoute.mjs.map +0 -1
  178. package/dist/matchers/toMatchText.mjs +0 -10
  179. package/dist/matchers/toMatchText.mjs.map +0 -1
  180. package/dist/matchers/toPassMatcher.mjs +0 -16
  181. package/dist/matchers/toPassMatcher.mjs.map +0 -1
  182. package/dist/mock/Fits.mjs +0 -15
  183. package/dist/mock/Fits.mjs.map +0 -1
  184. package/dist/mock/Mocks.mjs +0 -11
  185. package/dist/mock/Mocks.mjs.map +0 -1
  186. package/dist/mock/index.mjs +0 -23
  187. package/dist/mock/index.mjs.map +0 -1
  188. package/dist/utils/Eq.mjs +0 -8
  189. package/dist/utils/Eq.mjs.map +0 -1
  190. package/dist/utils/Req.mjs +0 -8
  191. package/dist/utils/Req.mjs.map +0 -1
  192. package/dist/utils/Response.mjs +0 -1
  193. package/dist/utils/Response.mjs.map +0 -1
  194. package/dist/utils/Types.mjs +0 -8
  195. package/dist/utils/Types.mjs.map +0 -1
  196. package/dist/utils/Utils.mjs +0 -27
  197. package/dist/utils/Utils.mjs.map +0 -1
@@ -0,0 +1,9 @@
1
+ import { isA } from "../utils/Utils.js";
2
+ import { match } from "./Match.js";
3
+ //#region src/matchers/toBeValid.ts
4
+ const toBeValid = (v) => match(v).undefined((s) => s, "Subject is undefined.").not((s) => isA(s, "isValid"), "Subject is not validatable.").not((s) => s.isValid, `Subject is not valid.`).else(`Subject is valid`);
5
+ expect.extend({ toBeValid });
6
+ //#endregion
7
+ export { toBeValid };
8
+
9
+ //# sourceMappingURL=toBeValid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toBeValid.js","names":[],"sources":["../../src/matchers/toBeValid.ts"],"sourcesContent":["import { Validatable } from '../utils/Types';\nimport { isA } from '../utils/Utils';\nimport { match } from './Match';\n\nexport const toBeValid = (v?: unknown): jest.CustomMatcherResult =>\n match<Validatable>(v as Validatable)\n .undefined(s => s, 'Subject is undefined.')\n .not(s => isA<Validatable>(s, 'isValid'), 'Subject is not validatable.')\n .not(s => s.isValid, `Subject is not valid.`)\n .else(`Subject is valid`);\n\nexpect.extend({\n toBeValid,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeValid(): R;\n }\n }\n}\n"],"mappings":";;;AAIA,MAAa,aAAa,MACxB,MAAmB,CAAgB,CAAC,CACjC,WAAU,MAAK,GAAG,uBAAuB,CAAC,CAC1C,KAAI,MAAK,IAAiB,GAAG,SAAS,GAAG,6BAA6B,CAAC,CACvE,KAAI,MAAK,EAAE,SAAS,uBAAuB,CAAC,CAC5C,KAAK,kBAAkB;AAE5B,OAAO,OAAO,EACZ,UACF,CAAC"}
@@ -1,19 +1,22 @@
1
- import { Message } from '../utils/Types';
1
+ import { Message } from "../utils/Types.js";
2
+ //#region src/matchers/toFailMatcher.d.ts
2
3
  export declare const Fails: {
3
- Yes: string;
4
- No: (reason: string) => string;
4
+ Yes: string;
5
+ No: (reason: string) => string;
5
6
  };
6
7
  export declare const FailsWith: {
7
- Yes: string;
8
- No: (message: string, instead: string) => string;
8
+ Yes: string;
9
+ No: (message: string, instead: string) => string;
9
10
  };
10
11
  export declare const toFailMatcher: (result: jest.CustomMatcherResult) => jest.CustomMatcherResult;
11
12
  export declare const toFailMatcherWith: (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>) => jest.CustomMatcherResult;
12
13
  declare global {
13
- namespace jest {
14
- interface Matchers<R, T> {
15
- toFailMatcher(): R;
16
- toFailMatcherWith(message: string): R;
17
- }
14
+ namespace jest {
15
+ interface Matchers<R, T> {
16
+ toFailMatcher(): R;
17
+ toFailMatcherWith(message: string): R;
18
18
  }
19
+ }
19
20
  }
21
+ //#endregion
22
+ //# sourceMappingURL=toFailMatcher.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { toMessage } from "../utils/Types.js";
2
+ import { match } from "./Match.js";
3
+ //#region src/matchers/toFailMatcher.ts
4
+ const Fails = {
5
+ Yes: "Match fails, instead of passes.",
6
+ No: (reason) => `Match doesn't fail, because '${reason}'`
7
+ };
8
+ const FailsWith = {
9
+ Yes: "Match fails with correct message.",
10
+ No: (message, instead) => `Match does fail, however not with message '${message}', but with message '${instead}' instead.`
11
+ };
12
+ const toFailMatcher = (result) => match(result).not((c) => !c.pass, (c) => Fails.No(c.message())).else(Fails.Yes);
13
+ const toFailMatcherWith = (result, message) => match(result).not((c) => !c.pass, (c) => Fails.No(c.message())).not((c) => c.message().includes(toMessage(message)), (c) => FailsWith.No(toMessage(message), c.message())).else(FailsWith.Yes);
14
+ expect.extend({
15
+ toFailMatcher,
16
+ toFailMatcherWith
17
+ });
18
+ //#endregion
19
+ export { Fails, FailsWith, toFailMatcher, toFailMatcherWith };
20
+
21
+ //# sourceMappingURL=toFailMatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toFailMatcher.js","names":[],"sources":["../../src/matchers/toFailMatcher.ts"],"sourcesContent":["import { match } from './Match';\nimport { Message, toMessage } from '../utils/Types';\n\n// Handles CustomMatcherResult validations.\n\nexport const Fails = {\n Yes: 'Match fails, instead of passes.',\n No: (reason: string): string => `Match doesn't fail, because '${reason}'`,\n};\n\nexport const FailsWith = {\n Yes: 'Match fails with correct message.',\n No: (message: string, instead: string): string => `Match does fail, however not with message '${message}', but with message '${instead}' instead.`,\n};\n\nexport const toFailMatcher = (result: jest.CustomMatcherResult): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => !c.pass,\n c => Fails.No(c.message())\n )\n .else(Fails.Yes);\n\nexport const toFailMatcherWith = (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => !c.pass,\n c => Fails.No(c.message())\n )\n .not(\n c => c.message().includes(toMessage(message)),\n c => FailsWith.No(toMessage(message), c.message())\n )\n .else(FailsWith.Yes);\n\nexpect.extend({\n toFailMatcher: toFailMatcher,\n toFailMatcherWith: toFailMatcherWith,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toFailMatcher(): R;\n\n toFailMatcherWith(message: string): R;\n }\n }\n}\n"],"mappings":";;;AAKA,MAAa,QAAQ;CACnB,KAAK;CACL,KAAK,WAA2B,gCAAgC,OAAO;AACzE;AAEA,MAAa,YAAY;CACvB,KAAK;CACL,KAAK,SAAiB,YAA4B,8CAA8C,QAAQ,uBAAuB,QAAQ;AACzI;AAEA,MAAa,iBAAiB,WAC5B,MAAM,MAAM,CAAC,CACV,KACC,MAAK,CAAC,EAAE,OACR,MAAK,MAAM,GAAG,EAAE,QAAQ,CAAC,CAC3B,CAAC,CACA,KAAK,MAAM,GAAG;AAEnB,MAAa,qBAAqB,QAAkC,YAClE,MAAM,MAAM,CAAC,CACV,KACC,MAAK,CAAC,EAAE,OACR,MAAK,MAAM,GAAG,EAAE,QAAQ,CAAC,CAC3B,CAAC,CACA,KACC,MAAK,EAAE,QAAQ,CAAC,CAAC,SAAS,UAAU,OAAO,CAAC,IAC5C,MAAK,UAAU,GAAG,UAAU,OAAO,GAAG,EAAE,QAAQ,CAAC,CACnD,CAAC,CACA,KAAK,UAAU,GAAG;AAEvB,OAAO,OAAO;CACG;CACI;AACrB,CAAC"}
@@ -1,8 +1,11 @@
1
+ //#region src/matchers/toMatchArray.d.ts
1
2
  export declare function toMatchArray(this: jest.MatcherContext, received: any[], expected: any[]): jest.CustomMatcherResult;
2
3
  declare global {
3
- namespace jest {
4
- interface Matchers<R, T> {
5
- toMatchArray(expected: any[]): R;
6
- }
4
+ namespace jest {
5
+ interface Matchers<R, T> {
6
+ toMatchArray(expected: any[]): R;
7
7
  }
8
+ }
8
9
  }
10
+ //#endregion
11
+ //# sourceMappingURL=toMatchArray.d.ts.map
@@ -0,0 +1,10 @@
1
+ import { checkDefined } from "./Check.js";
2
+ //#region src/matchers/toMatchArray.ts
3
+ function toMatchArray(received, expected) {
4
+ return checkDefined(this, received, expected).not(([r, e]) => r.length === e.length, ([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`).not(([r, e]) => r.every((el, i) => this.equals(el, e[i])), "Elements in {r} do not match elements in {e}. \n\n {diff}.").else();
5
+ }
6
+ expect.extend({ toMatchArray });
7
+ //#endregion
8
+ export { toMatchArray };
9
+
10
+ //# sourceMappingURL=toMatchArray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMatchArray.js","names":[],"sources":["../../src/matchers/toMatchArray.ts"],"sourcesContent":["import { checkDefined } from './Check';\n\nexport function toMatchArray(this: jest.MatcherContext, received: any[], expected: any[]) {\n return checkDefined(this, received, expected)\n .not(\n ([r, e]) => r.length === e.length,\n ([r, e]) => `Received array has length ${r.length}, while expected array has length ${e.length}.`\n )\n .not(([r, e]) => r.every((el, i) => this.equals(el, e[i])), 'Elements in {r} do not match elements in {e}. \\n\\n {diff}.')\n .else();\n}\n\nexpect.extend({\n toMatchArray,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchArray(expected: any[]): R;\n }\n }\n}\n"],"mappings":";;AAEA,SAAgB,aAAwC,UAAiB,UAAiB;CACxF,OAAO,aAAa,MAAM,UAAU,QAAQ,CAAC,CAC1C,KACE,CAAC,GAAG,OAAO,EAAE,WAAW,EAAE,SAC1B,CAAC,GAAG,OAAO,6BAA6B,EAAE,OAAO,oCAAoC,EAAE,OAAO,EACjG,CAAC,CACA,KAAK,CAAC,GAAG,OAAO,EAAE,OAAO,IAAI,MAAM,KAAK,OAAO,IAAI,EAAE,EAAE,CAAC,GAAG,4DAA4D,CAAC,CACxH,KAAK;AACV;AAEA,OAAO,OAAO,EACZ,aACF,CAAC"}
@@ -1,14 +1,17 @@
1
+ //#region src/matchers/toMatchExactJson.d.ts
1
2
  export declare const MatchesExactJson: {
2
- SubjectUndefined: string;
3
- SubsetUndefined: string;
4
- DoesNotMatch: string;
5
- Yes: string;
3
+ SubjectUndefined: string;
4
+ SubsetUndefined: string;
5
+ DoesNotMatch: string;
6
+ Yes: string;
6
7
  };
7
8
  export declare const toMatchExactJson: (value?: unknown, json?: unknown) => jest.CustomMatcherResult;
8
9
  declare global {
9
- namespace jest {
10
- interface Matchers<R, T> {
11
- toMatchExactJson(json?: unknown): R;
12
- }
10
+ namespace jest {
11
+ interface Matchers<R, T> {
12
+ toMatchExactJson(json?: unknown): R;
13
13
  }
14
+ }
14
15
  }
16
+ //#endregion
17
+ //# sourceMappingURL=toMatchExactJson.d.ts.map
@@ -0,0 +1,15 @@
1
+ import { match } from "./Match.js";
2
+ import { eq } from "../utils/Eq.js";
3
+ //#region src/matchers/toMatchExactJson.ts
4
+ const MatchesExactJson = {
5
+ SubjectUndefined: "Subject is undefined.",
6
+ SubsetUndefined: "Object to match with is undefined.",
7
+ DoesNotMatch: "Object does not exactly match subject.",
8
+ Yes: "Object matches subject exactly"
9
+ };
10
+ const toMatchExactJson = (value, json) => match(value).undefined((v) => v, MatchesExactJson.SubjectUndefined).undefined(() => json, MatchesExactJson.SubsetUndefined).not((v) => eq.exact(v, json), MatchesExactJson.DoesNotMatch).else(() => MatchesExactJson.Yes);
11
+ expect.extend({ toMatchExactJson });
12
+ //#endregion
13
+ export { MatchesExactJson, toMatchExactJson };
14
+
15
+ //# sourceMappingURL=toMatchExactJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMatchExactJson.js","names":[],"sources":["../../src/matchers/toMatchExactJson.ts"],"sourcesContent":["import { match } from './Match';\nimport { eq } from '../utils/Eq';\n\nexport const MatchesExactJson = {\n SubjectUndefined: 'Subject is undefined.',\n SubsetUndefined: 'Object to match with is undefined.',\n DoesNotMatch: 'Object does not exactly match subject.',\n Yes: 'Object matches subject exactly',\n};\n\nexport const toMatchExactJson = (value?: unknown, json?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, MatchesExactJson.SubjectUndefined)\n .undefined(() => json, MatchesExactJson.SubsetUndefined)\n .not(v => eq.exact(v, json), MatchesExactJson.DoesNotMatch)\n .else(() => MatchesExactJson.Yes);\n\nexpect.extend({\n toMatchExactJson: toMatchExactJson,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchExactJson(json?: unknown): R;\n }\n }\n}\n"],"mappings":";;;AAGA,MAAa,mBAAmB;CAC9B,kBAAkB;CAClB,iBAAiB;CACjB,cAAc;CACd,KAAK;AACP;AAEA,MAAa,oBAAoB,OAAiB,SAChD,MAAe,KAAK,CAAC,CAClB,WAAU,MAAK,GAAG,iBAAiB,gBAAgB,CAAC,CACpD,gBAAgB,MAAM,iBAAiB,eAAe,CAAC,CACvD,KAAI,MAAK,GAAG,MAAM,GAAG,IAAI,GAAG,iBAAiB,YAAY,CAAC,CAC1D,WAAW,iBAAiB,GAAG;AAEpC,OAAO,OAAO,EACM,iBACpB,CAAC"}
@@ -1,9 +1,12 @@
1
- import { Exception } from '../utils/Types';
1
+ import { Exception } from "../utils/Types.js";
2
+ //#region src/matchers/toMatchException.d.ts
2
3
  export declare const toMatchException: (received: Exception, expected: unknown, reason?: string) => jest.CustomMatcherResult;
3
4
  declare global {
4
- namespace jest {
5
- interface Matchers<R, T> {
6
- toMatchException(exception: unknown, reason?: string): R;
7
- }
5
+ namespace jest {
6
+ interface Matchers<R, T> {
7
+ toMatchException(exception: unknown, reason?: string): R;
8
8
  }
9
+ }
9
10
  }
11
+ //#endregion
12
+ //# sourceMappingURL=toMatchException.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { isDefined } from "../utils/Utils.js";
2
+ import { match } from "./Match.js";
3
+ //#region src/matchers/toMatchException.ts
4
+ const toMatchException = (received, expected, reason) => match(expected).undefined((e) => e.id, "Expected value is not an exception.").not((e) => e.id === received.id, (e) => `Expected exception has id '${e.id}', while the received exception has id '${received.id}'.`).not(() => !isDefined(reason) || isDefined(reason) && isDefined(received.reason), () => `We expected to have reason '${reason}', but we received no reason.`).not(() => !isDefined(reason) || isDefined(reason) && received.reason === reason, () => `We expected to have reason '${reason}', but we received reason '${received.reason}'.`).else(`Expected exception matches received exception`);
5
+ expect.extend({ toMatchException });
6
+ //#endregion
7
+ export { toMatchException };
8
+
9
+ //# sourceMappingURL=toMatchException.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMatchException.js","names":[],"sources":["../../src/matchers/toMatchException.ts"],"sourcesContent":["import { Exception } from '../utils/Types';\nimport { match } from './Match';\nimport { isDefined } from '../utils/Utils';\n\nexport const toMatchException = (received: Exception, expected: unknown, reason?: string): jest.CustomMatcherResult =>\n match<Exception>(expected as Exception)\n .undefined(e => e.id, 'Expected value is not an exception.')\n .not(\n e => e.id === received.id,\n e => `Expected exception has id '${e.id}', while the received exception has id '${received.id}'.`\n )\n .not(\n () => !isDefined(reason) || (isDefined(reason) && isDefined(received.reason)),\n () => `We expected to have reason '${reason}', but we received no reason.`\n )\n .not(\n () => !isDefined(reason) || (isDefined(reason) && received.reason === reason),\n () => `We expected to have reason '${reason}', but we received reason '${received.reason}'.`\n )\n .else(`Expected exception matches received exception`);\n\nexpect.extend({\n toMatchException,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchException(exception: unknown, reason?: string): R;\n }\n }\n}\n"],"mappings":";;;AAIA,MAAa,oBAAoB,UAAqB,UAAmB,WACvE,MAAiB,QAAqB,CAAC,CACpC,WAAU,MAAK,EAAE,IAAI,qCAAqC,CAAC,CAC3D,KACC,MAAK,EAAE,OAAO,SAAS,KACvB,MAAK,8BAA8B,EAAE,GAAG,0CAA0C,SAAS,GAAG,GAChG,CAAC,CACA,UACO,CAAC,UAAU,MAAM,KAAM,UAAU,MAAM,KAAK,UAAU,SAAS,MAAM,SACrE,+BAA+B,OAAO,8BAC9C,CAAC,CACA,UACO,CAAC,UAAU,MAAM,KAAM,UAAU,MAAM,KAAK,SAAS,WAAW,cAChE,+BAA+B,OAAO,6BAA6B,SAAS,OAAO,GAC3F,CAAC,CACA,KAAK,+CAA+C;AAEzD,OAAO,OAAO,EACZ,iBACF,CAAC"}
@@ -1,14 +1,17 @@
1
+ //#region src/matchers/toMatchJson.d.ts
1
2
  export declare const MatchesJson: {
2
- SubjectUndefined: string;
3
- SubsetUndefined: string;
4
- DoesNotMatch: string;
5
- Yes: string;
3
+ SubjectUndefined: string;
4
+ SubsetUndefined: string;
5
+ DoesNotMatch: string;
6
+ Yes: string;
6
7
  };
7
8
  export declare const toMatchJson: (value?: unknown, subset?: unknown) => jest.CustomMatcherResult;
8
9
  declare global {
9
- namespace jest {
10
- interface Matchers<R, T> {
11
- toMatchJson(subset?: unknown): R;
12
- }
10
+ namespace jest {
11
+ interface Matchers<R, T> {
12
+ toMatchJson(subset?: unknown): R;
13
13
  }
14
+ }
14
15
  }
16
+ //#endregion
17
+ //# sourceMappingURL=toMatchJson.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { asJson } from "../utils/Utils.js";
2
+ import { match } from "./Match.js";
3
+ import { eq } from "../utils/Eq.js";
4
+ //#region src/matchers/toMatchJson.ts
5
+ const MatchesJson = {
6
+ SubjectUndefined: "Subject is undefined.",
7
+ SubsetUndefined: "Subset to match with is undefined.",
8
+ DoesNotMatch: "Subset does not match subject.",
9
+ Yes: "Subset matches subject"
10
+ };
11
+ const toMatchJson = (value, subset) => match(value).undefined((v) => v, MatchesJson.SubjectUndefined).undefined(() => subset, MatchesJson.SubsetUndefined).not((v) => eq.subset(asJson(v), asJson(subset)), MatchesJson.DoesNotMatch).else(() => MatchesJson.Yes);
12
+ expect.extend({ toMatchJson });
13
+ //#endregion
14
+ export { MatchesJson, toMatchJson };
15
+
16
+ //# sourceMappingURL=toMatchJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMatchJson.js","names":[],"sources":["../../src/matchers/toMatchJson.ts"],"sourcesContent":["import { match } from './Match';\nimport { eq } from '../utils/Eq';\nimport { asJson } from '../utils/Utils';\n\nexport const MatchesJson = {\n SubjectUndefined: 'Subject is undefined.',\n SubsetUndefined: 'Subset to match with is undefined.',\n DoesNotMatch: 'Subset does not match subject.',\n Yes: 'Subset matches subject',\n};\n\nexport const toMatchJson = (value?: unknown, subset?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, MatchesJson.SubjectUndefined)\n .undefined(() => subset, MatchesJson.SubsetUndefined)\n .not(v => eq.subset(asJson(v), asJson(subset)), MatchesJson.DoesNotMatch)\n .else(() => MatchesJson.Yes);\n\nexpect.extend({\n toMatchJson: toMatchJson,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchJson(subset?: unknown): R;\n }\n }\n}\n"],"mappings":";;;;AAIA,MAAa,cAAc;CACzB,kBAAkB;CAClB,iBAAiB;CACjB,cAAc;CACd,KAAK;AACP;AAEA,MAAa,eAAe,OAAiB,WAC3C,MAAe,KAAK,CAAC,CAClB,WAAU,MAAK,GAAG,YAAY,gBAAgB,CAAC,CAC/C,gBAAgB,QAAQ,YAAY,eAAe,CAAC,CACpD,KAAI,MAAK,GAAG,OAAO,OAAO,CAAC,GAAG,OAAO,MAAM,CAAC,GAAG,YAAY,YAAY,CAAC,CACxE,WAAW,YAAY,GAAG;AAE/B,OAAO,OAAO,EACC,YACf,CAAC"}
@@ -1,9 +1,12 @@
1
- import { Uri } from '../utils/Types';
1
+ import { Uri } from "../utils/Types.js";
2
+ //#region src/matchers/toMatchRoute.d.ts
2
3
  export declare const toMatchRoute: (uri?: Uri, route?: Uri | string) => jest.CustomMatcherResult;
3
4
  declare global {
4
- namespace jest {
5
- interface Matchers<R, T> {
6
- toMatchRoute(route?: Uri | string): R;
7
- }
5
+ namespace jest {
6
+ interface Matchers<R, T> {
7
+ toMatchRoute(route?: Uri | string): R;
8
8
  }
9
+ }
9
10
  }
11
+ //#endregion
12
+ //# sourceMappingURL=toMatchRoute.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { asString } from "../utils/Utils.js";
2
+ import { match } from "./Match.js";
3
+ //#region src/matchers/toMatchRoute.ts
4
+ const toMatchRoute = (uri, route) => match(uri).undefined((u) => u, "Subject is undefined.").undefined(() => route, "Route to include is undefined.").not((u) => asString(u).includes(asString(route)), (u) => `Uri '${u}' does not include '${route}'.`).else((u) => `Uri '${u}' includes '${route}'`);
5
+ expect.extend({ toMatchRoute });
6
+ //#endregion
7
+ export { toMatchRoute };
8
+
9
+ //# sourceMappingURL=toMatchRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMatchRoute.js","names":[],"sources":["../../src/matchers/toMatchRoute.ts"],"sourcesContent":["import { Uri } from '../utils/Types';\nimport { match } from './Match';\nimport { asString } from '../utils/Utils';\n\nexport const toMatchRoute = (uri?: Uri, route?: Uri | string): jest.CustomMatcherResult =>\n match<Uri | undefined>(uri)\n .undefined(u => u, 'Subject is undefined.')\n .undefined(() => route, 'Route to include is undefined.')\n .not(\n u => asString(u).includes(asString(route)),\n u => `Uri '${u}' does not include '${route}'.`\n )\n .else(u => `Uri '${u}' includes '${route}'`);\n\nexpect.extend({\n toMatchRoute: toMatchRoute,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchRoute(route?: Uri | string): R;\n }\n }\n}\n"],"mappings":";;;AAIA,MAAa,gBAAgB,KAAW,UACtC,MAAuB,GAAG,CAAC,CACxB,WAAU,MAAK,GAAG,uBAAuB,CAAC,CAC1C,gBAAgB,OAAO,gCAAgC,CAAC,CACxD,KACC,MAAK,SAAS,CAAC,CAAC,CAAC,SAAS,SAAS,KAAK,CAAC,IACzC,MAAK,QAAQ,EAAE,sBAAsB,MAAM,GAC7C,CAAC,CACA,MAAK,MAAK,QAAQ,EAAE,cAAc,MAAM,EAAE;AAE/C,OAAO,OAAO,EACE,aAChB,CAAC"}
@@ -1,8 +1,11 @@
1
+ //#region src/matchers/toMatchText.d.ts
1
2
  export declare const toMatchText: (value?: unknown, text?: unknown) => jest.CustomMatcherResult;
2
3
  declare global {
3
- namespace jest {
4
- interface Matchers<R, T> {
5
- toMatchText(text?: unknown): R;
6
- }
4
+ namespace jest {
5
+ interface Matchers<R, T> {
6
+ toMatchText(text?: unknown): R;
7
7
  }
8
+ }
8
9
  }
10
+ //#endregion
11
+ //# sourceMappingURL=toMatchText.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { asString } from "../utils/Utils.js";
2
+ import { match } from "./Match.js";
3
+ //#region src/matchers/toMatchText.ts
4
+ const toMatchText = (value, text) => match(value).undefined((v) => v, "Subject is undefined.").undefined(() => text, "Text to match with is undefined.").not((v) => asString(v) === asString(text), (v) => `Text '${v}' does not match with text '${text}'.`).else((v) => `Text '${v}' matches`);
5
+ expect.extend({ toMatchText });
6
+ //#endregion
7
+ export { toMatchText };
8
+
9
+ //# sourceMappingURL=toMatchText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toMatchText.js","names":[],"sources":["../../src/matchers/toMatchText.ts"],"sourcesContent":["import { match } from './Match';\nimport { asString } from '../utils/Utils';\n\nexport const toMatchText = (value?: unknown, text?: unknown): jest.CustomMatcherResult =>\n match<unknown>(value)\n .undefined(v => v, 'Subject is undefined.')\n .undefined(() => text, 'Text to match with is undefined.')\n .not(\n v => asString(v) === asString(text),\n v => `Text '${v}' does not match with text '${text}'.`\n )\n .else(v => `Text '${v}' matches`);\n\nexpect.extend({\n toMatchText: toMatchText,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toMatchText(text?: unknown): R;\n }\n }\n}\n"],"mappings":";;;AAGA,MAAa,eAAe,OAAiB,SAC3C,MAAe,KAAK,CAAC,CAClB,WAAU,MAAK,GAAG,uBAAuB,CAAC,CAC1C,gBAAgB,MAAM,kCAAkC,CAAC,CACzD,KACC,MAAK,SAAS,CAAC,MAAM,SAAS,IAAI,IAClC,MAAK,SAAS,EAAE,8BAA8B,KAAK,GACrD,CAAC,CACA,MAAK,MAAK,SAAS,EAAE,UAAU;AAEpC,OAAO,OAAO,EACC,YACf,CAAC"}
@@ -1,19 +1,22 @@
1
- import { Message } from '../utils/Types';
1
+ import { Message } from "../utils/Types.js";
2
+ //#region src/matchers/toPassMatcher.d.ts
2
3
  export declare const Passes: {
3
- Yes: string;
4
- No: (reason: string) => string;
4
+ Yes: string;
5
+ No: (reason: string) => string;
5
6
  };
6
7
  export declare const PassesWith: {
7
- Yes: string;
8
- No: (message: string, instead: string) => string;
8
+ Yes: string;
9
+ No: (message: string, instead: string) => string;
9
10
  };
10
11
  export declare const toPassMatcher: (result: jest.CustomMatcherResult) => jest.CustomMatcherResult;
11
12
  export declare const toPassMatcherWith: (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>) => jest.CustomMatcherResult;
12
13
  declare global {
13
- namespace jest {
14
- interface Matchers<R, T> {
15
- toPassMatcher(): R;
16
- toPassMatcherWith(message: string): R;
17
- }
14
+ namespace jest {
15
+ interface Matchers<R, T> {
16
+ toPassMatcher(): R;
17
+ toPassMatcherWith(message: string): R;
18
18
  }
19
+ }
19
20
  }
21
+ //#endregion
22
+ //# sourceMappingURL=toPassMatcher.d.ts.map
@@ -0,0 +1,21 @@
1
+ import { toMessage } from "../utils/Types.js";
2
+ import { match } from "./Match.js";
3
+ //#region src/matchers/toPassMatcher.ts
4
+ const Passes = {
5
+ Yes: "Match passes, instead of fails.",
6
+ No: (reason) => `Match doesn't pass, because '${reason}'`
7
+ };
8
+ const PassesWith = {
9
+ Yes: "Match passes with correct message.",
10
+ No: (message, instead) => `Match does pass, however not with message '${message}', but with message '${instead}' instead.`
11
+ };
12
+ const toPassMatcher = (result) => match(result).not((c) => c.pass, (c) => Passes.No(c.message())).else(Passes.Yes);
13
+ const toPassMatcherWith = (result, message) => match(result).not((c) => c.pass, (c) => Passes.No(c.message())).not((c) => c.message().includes(toMessage(message)), (c) => PassesWith.No(toMessage(message), c.message())).else(PassesWith.Yes);
14
+ expect.extend({
15
+ toPassMatcher,
16
+ toPassMatcherWith
17
+ });
18
+ //#endregion
19
+ export { Passes, PassesWith, toPassMatcher, toPassMatcherWith };
20
+
21
+ //# sourceMappingURL=toPassMatcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toPassMatcher.js","names":[],"sources":["../../src/matchers/toPassMatcher.ts"],"sourcesContent":["import { match } from './Match';\n\nimport { Message, toMessage } from '../utils/Types';\n\n// Handles CustomMatcherResult validations.\n\nexport const Passes = {\n Yes: 'Match passes, instead of fails.',\n No: (reason: string): string => `Match doesn't pass, because '${reason}'`,\n};\n\nexport const PassesWith = {\n Yes: 'Match passes with correct message.',\n No: (message: string, instead: string): string => `Match does pass, however not with message '${message}', but with message '${instead}' instead.`,\n};\n\nexport const toPassMatcher = (result: jest.CustomMatcherResult): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => c.pass,\n c => Passes.No(c.message())\n )\n .else(Passes.Yes);\n\nexport const toPassMatcherWith = (result: jest.CustomMatcherResult, message: Message<jest.CustomMatcherResult>): jest.CustomMatcherResult =>\n match(result)\n .not(\n c => c.pass,\n c => Passes.No(c.message())\n )\n .not(\n c => c.message().includes(toMessage(message)),\n c => PassesWith.No(toMessage(message), c.message())\n )\n .else(PassesWith.Yes);\n\nexpect.extend({\n toPassMatcher: toPassMatcher,\n toPassMatcherWith: toPassMatcherWith,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toPassMatcher(): R;\n toPassMatcherWith(message: string): R;\n }\n }\n}\n"],"mappings":";;;AAMA,MAAa,SAAS;CACpB,KAAK;CACL,KAAK,WAA2B,gCAAgC,OAAO;AACzE;AAEA,MAAa,aAAa;CACxB,KAAK;CACL,KAAK,SAAiB,YAA4B,8CAA8C,QAAQ,uBAAuB,QAAQ;AACzI;AAEA,MAAa,iBAAiB,WAC5B,MAAM,MAAM,CAAC,CACV,KACC,MAAK,EAAE,OACP,MAAK,OAAO,GAAG,EAAE,QAAQ,CAAC,CAC5B,CAAC,CACA,KAAK,OAAO,GAAG;AAEpB,MAAa,qBAAqB,QAAkC,YAClE,MAAM,MAAM,CAAC,CACV,KACC,MAAK,EAAE,OACP,MAAK,OAAO,GAAG,EAAE,QAAQ,CAAC,CAC5B,CAAC,CACA,KACC,MAAK,EAAE,QAAQ,CAAC,CAAC,SAAS,UAAU,OAAO,CAAC,IAC5C,MAAK,WAAW,GAAG,UAAU,OAAO,GAAG,EAAE,QAAQ,CAAC,CACpD,CAAC,CACA,KAAK,WAAW,GAAG;AAExB,OAAO,OAAO;CACG;CACI;AACrB,CAAC"}
@@ -1,24 +1,27 @@
1
- import { AsymmetricMatcher } from 'expect';
2
- import { Uri } from '../utils/Types';
1
+ import { Uri } from "../utils/Types.js";
2
+ import { AsymmetricMatcher } from "expect";
3
+ //#region src/mock/Fits.d.ts
3
4
  export declare class ObjectContainingText extends AsymmetricMatcher<string> {
4
- asymmetricMatch(other: any): boolean;
5
- toString(): string;
5
+ asymmetricMatch(other: any): boolean;
6
+ toString(): string;
6
7
  }
7
8
  export declare class ObjectContainingTextExact extends AsymmetricMatcher<string> {
8
- asymmetricMatch(other: any): boolean;
9
- toString(): string;
9
+ asymmetricMatch(other: any): boolean;
10
+ toString(): string;
10
11
  }
11
12
  export declare class ObjectContainingJson extends AsymmetricMatcher<any> {
12
- asymmetricMatch(other: any): boolean;
13
- toString(): string;
13
+ asymmetricMatch(other: any): boolean;
14
+ toString(): string;
14
15
  }
15
16
  export declare const fits: {
16
- any: () => any;
17
- type: (type?: unknown) => any;
18
- with: (o: unknown) => any;
19
- text: (s: any) => any;
20
- textExact: (s: any) => any;
21
- uri: (u: Uri) => any;
22
- json: (s: any) => any;
23
- items: (...items: any[]) => any;
17
+ any: () => any;
18
+ type: (type?: unknown) => any;
19
+ with: (o: unknown) => any;
20
+ text: (s: any) => any;
21
+ textExact: (s: any) => any;
22
+ uri: (u: Uri) => any;
23
+ json: (s: any) => any;
24
+ items: (...items: any[]) => any;
24
25
  };
26
+ //#endregion
27
+ //# sourceMappingURL=Fits.d.ts.map
@@ -0,0 +1,42 @@
1
+ import { asJson, asString, toArray } from "../utils/Utils.js";
2
+ import { eq } from "../utils/Eq.js";
3
+ import { AsymmetricMatcher } from "expect";
4
+ //#region src/mock/Fits.ts
5
+ var ObjectContainingText = class extends AsymmetricMatcher {
6
+ asymmetricMatch(other) {
7
+ return asString(other).includes(asString(this.sample));
8
+ }
9
+ toString() {
10
+ return `String${this.inverse ? "Not" : ""}Containing`;
11
+ }
12
+ };
13
+ var ObjectContainingTextExact = class extends AsymmetricMatcher {
14
+ asymmetricMatch(other) {
15
+ return asString(other) === asString(this.sample);
16
+ }
17
+ toString() {
18
+ return `String${this.inverse ? "Not" : ""}Containing`;
19
+ }
20
+ };
21
+ var ObjectContainingJson = class extends AsymmetricMatcher {
22
+ asymmetricMatch(other) {
23
+ return eq.subset(asJson(other), asJson(this.sample));
24
+ }
25
+ toString() {
26
+ return `Object${this.inverse ? "Not" : ""}Containing`;
27
+ }
28
+ };
29
+ const fits = {
30
+ any: () => expect.anything(),
31
+ type: (type) => expect.any(type),
32
+ with: (o) => expect.objectContaining(o),
33
+ text: (s) => new ObjectContainingText(s),
34
+ textExact: (s) => new ObjectContainingTextExact(s),
35
+ uri: (u) => fits.textExact(u),
36
+ json: (s) => new ObjectContainingJson(s),
37
+ items: (...items) => expect.arrayContaining(toArray(...items))
38
+ };
39
+ //#endregion
40
+ export { ObjectContainingJson, ObjectContainingText, ObjectContainingTextExact, fits };
41
+
42
+ //# sourceMappingURL=Fits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Fits.js","names":[],"sources":["../../src/mock/Fits.ts"],"sourcesContent":["import { asJson, asString, toArray } from '../utils/Utils';\nimport { eq } from '../utils/Eq';\nimport { AsymmetricMatcher } from 'expect';\nimport { Uri } from '../utils/Types';\n\nexport class ObjectContainingText extends AsymmetricMatcher<string> {\n asymmetricMatch(other: any) {\n return asString(other).includes(asString(this.sample));\n }\n\n toString() {\n return `String${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport class ObjectContainingTextExact extends AsymmetricMatcher<string> {\n asymmetricMatch(other: any) {\n return asString(other) === asString(this.sample);\n }\n\n toString() {\n return `String${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport class ObjectContainingJson extends AsymmetricMatcher<any> {\n asymmetricMatch(other: any) {\n return eq.subset(asJson(other), asJson(this.sample));\n }\n\n toString() {\n return `Object${this.inverse ? 'Not' : ''}Containing`;\n }\n}\n\nexport const fits = {\n any: (): any => expect.anything(),\n type: (type?: unknown): any => expect.any(type),\n with: (o: unknown): any => expect.objectContaining(o),\n text: (s: any): any => new ObjectContainingText(s),\n textExact: (s: any): any => new ObjectContainingTextExact(s),\n uri: (u: Uri): any => fits.textExact(u),\n json: (s: any): any => new ObjectContainingJson(s),\n items: (...items: any[]): any => expect.arrayContaining(toArray(...items)),\n};\n"],"mappings":";;;;AAKA,IAAa,uBAAb,cAA0C,kBAA0B;CAClE,gBAAgB,OAAY;EAC1B,OAAO,SAAS,KAAK,CAAC,CAAC,SAAS,SAAS,KAAK,MAAM,CAAC;CACvD;CAEA,WAAW;EACT,OAAO,SAAS,KAAK,UAAU,QAAQ,GAAG;CAC5C;AACF;AAEA,IAAa,4BAAb,cAA+C,kBAA0B;CACvE,gBAAgB,OAAY;EAC1B,OAAO,SAAS,KAAK,MAAM,SAAS,KAAK,MAAM;CACjD;CAEA,WAAW;EACT,OAAO,SAAS,KAAK,UAAU,QAAQ,GAAG;CAC5C;AACF;AAEA,IAAa,uBAAb,cAA0C,kBAAuB;CAC/D,gBAAgB,OAAY;EAC1B,OAAO,GAAG,OAAO,OAAO,KAAK,GAAG,OAAO,KAAK,MAAM,CAAC;CACrD;CAEA,WAAW;EACT,OAAO,SAAS,KAAK,UAAU,QAAQ,GAAG;CAC5C;AACF;AAEA,MAAa,OAAO;CAClB,WAAgB,OAAO,SAAS;CAChC,OAAO,SAAwB,OAAO,IAAI,IAAI;CAC9C,OAAO,MAAoB,OAAO,iBAAiB,CAAC;CACpD,OAAO,MAAgB,IAAI,qBAAqB,CAAC;CACjD,YAAY,MAAgB,IAAI,0BAA0B,CAAC;CAC3D,MAAM,MAAgB,KAAK,UAAU,CAAC;CACtC,OAAO,MAAgB,IAAI,qBAAqB,CAAC;CACjD,QAAQ,GAAG,UAAsB,OAAO,gBAAgB,QAAQ,GAAG,KAAK,CAAC;AAC3E"}
@@ -1,39 +1,42 @@
1
- import { Id, Json } from '../utils/Types';
2
- import { Req } from '../utils/Req';
3
- import { HttpStatus, Response } from '../utils/Response';
1
+ import { Id, Json } from "../utils/Types.js";
2
+ import { HttpStatus, Response } from "../utils/Response.js";
3
+ import { Req } from "../utils/Req.js";
4
+ //#region src/mock/Mocks.d.ts
4
5
  export declare class Mocks {
5
- req: {
6
- id: (id: Id) => Req;
7
- q: (q: unknown) => Req;
8
- with: (a: Json) => Req;
9
- body: <B = unknown>(body: B) => Req<B>;
10
- path: (path: Json) => Req;
11
- query: (query: Json) => Req;
6
+ req: {
7
+ id: (id: Id) => Req;
8
+ q: (q: unknown) => Req;
9
+ with: (a: Json) => Req;
10
+ body: <B = unknown>(body: B) => Req<B>;
11
+ path: (path: Json) => Req;
12
+ query: (query: Json) => Req;
13
+ };
14
+ resp: {
15
+ items: (status: HttpStatus, items?: unknown[]) => Response;
16
+ errors: (status: HttpStatus, message: string, errors?: unknown[]) => Response;
17
+ };
18
+ provider: {
19
+ data: (...items: any[]) => {
20
+ execute: jest.Mock;
12
21
  };
13
- resp: {
14
- items: (status: HttpStatus, items?: unknown[]) => Response;
15
- errors: (status: HttpStatus, message: string, errors?: unknown[]) => Response;
16
- };
17
- provider: {
18
- data: (...items: any[]) => {
19
- execute: jest.Mock;
20
- };
21
- };
22
- static readonly getArg: <T>(mock: unknown, call?: number, arg?: number) => T | undefined;
23
- clear: () => typeof jest;
24
- impl: (f?: (...args: any[]) => any) => jest.Mock;
25
- property: <T extends object, P extends jest.NonFunctionPropertyNames<Required<T>>>(object: T, getter: P, value: T[P]) => jest.SpyInstance;
26
- reject: (value?: unknown) => jest.Mock;
27
- rejectWith: <T = any>(props?: Partial<T>) => jest.Mock;
28
- resolve: (value?: unknown) => jest.Mock;
29
- resolveWith: <T = any>(props?: Partial<T>) => jest.Mock;
30
- return: (value?: unknown) => jest.Mock;
31
- returnWith: <T = any>(props?: Partial<T>) => jest.Mock;
32
- this: () => jest.Mock;
33
- empty: <T = any>(props?: Partial<T>) => T;
34
- a: <T = any>(props?: Partial<T>) => T;
35
- an: <T = any>(props?: Partial<T>) => T;
36
- date: (epoch?: number) => Date;
37
- once: (...values: unknown[]) => jest.Mock;
22
+ };
23
+ static readonly getArg: <T>(mock: unknown, call?: number, arg?: number) => T | undefined;
24
+ clear: () => typeof jest;
25
+ impl: (f?: (...args: any[]) => any) => jest.Mock;
26
+ property: <T extends object, P extends jest.NonFunctionPropertyNames<Required<T>>>(object: T, getter: P, value: T[P]) => jest.SpyInstance;
27
+ reject: (value?: unknown) => jest.Mock;
28
+ rejectWith: <T = any>(props?: Partial<T>) => jest.Mock;
29
+ resolve: (value?: unknown) => jest.Mock;
30
+ resolveWith: <T = any>(props?: Partial<T>) => jest.Mock;
31
+ return: (value?: unknown) => jest.Mock;
32
+ returnWith: <T = any>(props?: Partial<T>) => jest.Mock;
33
+ this: () => jest.Mock;
34
+ empty: <T = any>(props?: Partial<T>) => T;
35
+ a: <T = any>(props?: Partial<T>) => T;
36
+ an: <T = any>(props?: Partial<T>) => T;
37
+ date: (epoch?: number) => Date;
38
+ once: (...values: unknown[]) => jest.Mock;
38
39
  }
39
40
  export declare const mock: Mocks;
41
+ //#endregion
42
+ //# sourceMappingURL=Mocks.d.ts.map
@@ -0,0 +1,68 @@
1
+ import { Req } from "../utils/Req.js";
2
+ //#region src/mock/Mocks.ts
3
+ var Mocks = class {
4
+ req = {
5
+ id: (id) => new Req({ id }),
6
+ q: (q) => new Req({ q }),
7
+ with: (a) => new Req(a),
8
+ body: (body) => new Req({ body }),
9
+ path: (path) => new Req({ path }),
10
+ query: (query) => new Req({ query })
11
+ };
12
+ resp = {
13
+ items: (status, items = []) => ({
14
+ status,
15
+ body: { data: {
16
+ code: status.id,
17
+ itemCount: items.length,
18
+ items
19
+ } }
20
+ }),
21
+ errors: (status, message, errors = []) => ({
22
+ status,
23
+ body: { error: {
24
+ code: status.id,
25
+ message,
26
+ errorCount: errors.length,
27
+ errors
28
+ } }
29
+ })
30
+ };
31
+ provider = { data: (...items) => ({ execute: jest.fn().mockResolvedValue({ body: { data: {
32
+ itemCount: items.length,
33
+ items
34
+ } } }) }) };
35
+ static getArg = (mock, call = 0, arg = 0) => {
36
+ if (!isJestMock(mock)) throw new Error("Function provided is not a Jest mock");
37
+ return mock.mock.calls[call]?.[arg];
38
+ };
39
+ clear = () => jest.clearAllMocks();
40
+ impl = (f) => jest.fn().mockImplementation(f);
41
+ property = (object, getter, value) => jest.spyOn(object, getter, "get").mockReturnValue(value);
42
+ reject = (value) => jest.fn().mockRejectedValue(value);
43
+ rejectWith = (props = {}) => jest.fn().mockRejectedValue(mock.a(props));
44
+ resolve = (value) => jest.fn().mockResolvedValue(value);
45
+ resolveWith = (props = {}) => jest.fn().mockResolvedValue(mock.a(props));
46
+ return = (value) => jest.fn().mockReturnValue(value);
47
+ returnWith = (props = {}) => jest.fn().mockReturnValue(mock.a(props));
48
+ this = () => jest.fn().mockReturnThis();
49
+ empty = (props = {}) => props;
50
+ a = this.empty;
51
+ an = this.empty;
52
+ date = (epoch = 1621347575) => {
53
+ const date = new Date(epoch);
54
+ date.toString = mock.return("Mon Jan 19 1970 19:22:27 GMT+0100 (Central European Standard Time)");
55
+ date.toLocaleDateString = mock.return("19/01/1970");
56
+ date.toDateString = mock.return("19/01/1970");
57
+ return date;
58
+ };
59
+ once = (...values) => values.reduce((m, v) => m.mockImplementationOnce(() => v), jest.fn());
60
+ };
61
+ function isJestMock(fn) {
62
+ return typeof fn === "function" && "mock" in fn && Array.isArray(fn.mock?.calls);
63
+ }
64
+ const mock = new Mocks();
65
+ //#endregion
66
+ export { Mocks, mock };
67
+
68
+ //# sourceMappingURL=Mocks.js.map