@thisisagile/easy-test 19.1.4 → 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 @@
1
+ {"version":3,"file":"Mocks.js","names":[],"sources":["../../src/mock/Mocks.ts"],"sourcesContent":["import { Id, Json } from '../utils/Types';\nimport { Req } from '../utils/Req';\nimport { HttpStatus, Response } from '../utils/Response';\n\nexport class Mocks {\n req = {\n id: (id: Id): Req => new Req({ id }),\n q: (q: unknown): Req => new Req({ q }),\n with: (a: Json): Req => new Req(a),\n body: <B = unknown>(body: B): Req<B> => new Req<B>({ body }),\n path: (path: Json): Req => new Req({ path }),\n query: (query: Json): Req => new Req({ query }),\n };\n resp = {\n items: (status: HttpStatus, items: unknown[] = []): Response => ({\n status: status,\n body: {\n data: {\n code: status.id as number,\n itemCount: items.length,\n items,\n },\n },\n }),\n errors: (status: HttpStatus, message: string, errors: unknown[] = []): Response => ({\n status: status,\n body: {\n error: {\n code: status.id as number,\n message: message,\n errorCount: errors.length,\n errors,\n },\n },\n }),\n };\n provider = {\n data: (...items: any[]): { execute: jest.Mock } => ({\n execute: jest.fn().mockResolvedValue({\n body: {\n data: {\n itemCount: items.length,\n items,\n },\n },\n }),\n }),\n };\n\n static readonly getArg = <T>(mock: unknown, call = 0, arg = 0): T | undefined => {\n if (!isJestMock(mock)) throw new Error('Function provided is not a Jest mock');\n return mock.mock.calls[call]?.[arg] as T;\n };\n\n clear = (): typeof jest => jest.clearAllMocks();\n\n impl = (f?: (...args: any[]) => any): jest.Mock => jest.fn().mockImplementation(f);\n\n property = <T extends object, P extends jest.NonFunctionPropertyNames<Required<T>>>(object: T, getter: P, value: T[P]): jest.SpyInstance =>\n jest.spyOn(object, getter, 'get' as jest.PropertyAccessors<P, T>).mockReturnValue(value as any);\n\n reject = (value?: unknown): jest.Mock => jest.fn().mockRejectedValue(value);\n\n rejectWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockRejectedValue(mock.a(props));\n\n resolve = (value?: unknown): jest.Mock => jest.fn().mockResolvedValue(value);\n\n resolveWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockResolvedValue(mock.a(props));\n\n return = (value?: unknown): jest.Mock => jest.fn().mockReturnValue(value);\n\n returnWith = <T = any>(props: Partial<T> = {}): jest.Mock => jest.fn().mockReturnValue(mock.a(props));\n\n this = (): jest.Mock => jest.fn().mockReturnThis();\n\n empty = <T = any>(props: Partial<T> = {}): T => props as T;\n a = this.empty;\n an = this.empty;\n date = (epoch = 1621347575): Date => {\n const date = new Date(epoch);\n date.toString = mock.return('Mon Jan 19 1970 19:22:27 GMT+0100 (Central European Standard Time)');\n date.toLocaleDateString = mock.return('19/01/1970');\n date.toDateString = mock.return('19/01/1970');\n return date;\n };\n once = (...values: unknown[]): jest.Mock => values.reduce((m: jest.Mock, v: unknown) => m.mockImplementationOnce(() => v), jest.fn());\n}\n\nfunction isJestMock(fn: any): fn is jest.Mock {\n return typeof fn === 'function' && 'mock' in fn && Array.isArray(fn.mock?.calls);\n}\n\nexport const mock = new Mocks();\n"],"mappings":";;AAIA,IAAa,QAAb,MAAmB;CACjB,MAAM;EACJ,KAAK,OAAgB,IAAI,IAAI,EAAE,GAAG,CAAC;EACnC,IAAI,MAAoB,IAAI,IAAI,EAAE,EAAE,CAAC;EACrC,OAAO,MAAiB,IAAI,IAAI,CAAC;EACjC,OAAoB,SAAoB,IAAI,IAAO,EAAE,KAAK,CAAC;EAC3D,OAAO,SAAoB,IAAI,IAAI,EAAE,KAAK,CAAC;EAC3C,QAAQ,UAAqB,IAAI,IAAI,EAAE,MAAM,CAAC;CAChD;CACA,OAAO;EACL,QAAQ,QAAoB,QAAmB,CAAC,OAAiB;GACvD;GACR,MAAM,EACJ,MAAM;IACJ,MAAM,OAAO;IACb,WAAW,MAAM;IACjB;GACF,EACF;EACF;EACA,SAAS,QAAoB,SAAiB,SAAoB,CAAC,OAAiB;GAC1E;GACR,MAAM,EACJ,OAAO;IACL,MAAM,OAAO;IACJ;IACT,YAAY,OAAO;IACnB;GACF,EACF;EACF;CACF;CACA,WAAW,EACT,OAAO,GAAG,WAA0C,EAClD,SAAS,KAAK,GAAG,CAAC,CAAC,kBAAkB,EACnC,MAAM,EACJ,MAAM;EACJ,WAAW,MAAM;EACjB;CACF,EACF,EACF,CAAC,EACH,GACF;CAEA,OAAgB,UAAa,MAAe,OAAO,GAAG,MAAM,MAAqB;EAC/E,IAAI,CAAC,WAAW,IAAI,GAAG,MAAM,IAAI,MAAM,sCAAsC;EAC7E,OAAO,KAAK,KAAK,MAAM,KAAK,GAAG;CACjC;CAEA,cAA2B,KAAK,cAAc;CAE9C,QAAQ,MAA2C,KAAK,GAAG,CAAC,CAAC,mBAAmB,CAAC;CAEjF,YAAoF,QAAW,QAAW,UACxG,KAAK,MAAM,QAAQ,QAAQ,KAAqC,CAAC,CAAC,gBAAgB,KAAY;CAEhG,UAAU,UAA+B,KAAK,GAAG,CAAC,CAAC,kBAAkB,KAAK;CAE1E,cAAuB,QAAoB,CAAC,MAAiB,KAAK,GAAG,CAAC,CAAC,kBAAkB,KAAK,EAAE,KAAK,CAAC;CAEtG,WAAW,UAA+B,KAAK,GAAG,CAAC,CAAC,kBAAkB,KAAK;CAE3E,eAAwB,QAAoB,CAAC,MAAiB,KAAK,GAAG,CAAC,CAAC,kBAAkB,KAAK,EAAE,KAAK,CAAC;CAEvG,UAAU,UAA+B,KAAK,GAAG,CAAC,CAAC,gBAAgB,KAAK;CAExE,cAAuB,QAAoB,CAAC,MAAiB,KAAK,GAAG,CAAC,CAAC,gBAAgB,KAAK,EAAE,KAAK,CAAC;CAEpG,aAAwB,KAAK,GAAG,CAAC,CAAC,eAAe;CAEjD,SAAkB,QAAoB,CAAC,MAAS;CAChD,IAAI,KAAK;CACT,KAAK,KAAK;CACV,QAAQ,QAAQ,eAAqB;EACnC,MAAM,OAAO,IAAI,KAAK,KAAK;EAC3B,KAAK,WAAW,KAAK,OAAO,oEAAoE;EAChG,KAAK,qBAAqB,KAAK,OAAO,YAAY;EAClD,KAAK,eAAe,KAAK,OAAO,YAAY;EAC5C,OAAO;CACT;CACA,QAAQ,GAAG,WAAiC,OAAO,QAAQ,GAAc,MAAe,EAAE,6BAA6B,CAAC,GAAG,KAAK,GAAG,CAAC;AACtI;AAEA,SAAS,WAAW,IAA0B;CAC5C,OAAO,OAAO,OAAO,cAAc,UAAU,MAAM,MAAM,QAAQ,GAAG,MAAM,KAAK;AACjF;AAEA,MAAa,OAAO,IAAI,MAAM"}
@@ -1,2 +1,3 @@
1
- export * from './Fits';
2
- export * from './Mocks';
1
+ import { ObjectContainingJson, ObjectContainingText, ObjectContainingTextExact, fits } from "./Fits.js";
2
+ import { Mocks, mock } from "./Mocks.js";
3
+ export { Mocks, ObjectContainingJson, ObjectContainingText, ObjectContainingTextExact, fits, mock };
@@ -0,0 +1,3 @@
1
+ import { ObjectContainingJson, ObjectContainingText, ObjectContainingTextExact, fits } from "./Fits.js";
2
+ import { Mocks, mock } from "./Mocks.js";
3
+ export { Mocks, ObjectContainingJson, ObjectContainingText, ObjectContainingTextExact, fits, mock };
@@ -1,5 +1,8 @@
1
+ //#region src/utils/Eq.d.ts
1
2
  export declare const eq: {
2
- exact: (a?: unknown, b?: unknown) => boolean;
3
- subset: (a?: unknown, b?: unknown) => boolean;
4
- string: (a?: unknown, b?: unknown) => boolean;
3
+ exact: (a?: unknown, b?: unknown) => boolean;
4
+ subset: (a?: unknown, b?: unknown) => boolean;
5
+ string: (a?: unknown, b?: unknown) => boolean;
5
6
  };
7
+ //#endregion
8
+ //# sourceMappingURL=Eq.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { asString } from "./Utils.js";
2
+ import { equals, iterableEquality, subsetEquality } from "@jest/expect-utils";
3
+ //#region src/utils/Eq.ts
4
+ const eq = {
5
+ exact: (a, b) => equals(a, b, []),
6
+ subset: (a, b) => equals(a, b, [iterableEquality, subsetEquality]),
7
+ string: (a, b) => asString(a) === asString(b)
8
+ };
9
+ //#endregion
10
+ export { eq };
11
+
12
+ //# sourceMappingURL=Eq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Eq.js","names":[],"sources":["../../src/utils/Eq.ts"],"sourcesContent":["import { asString } from './Utils';\nimport { equals, iterableEquality, subsetEquality } from '@jest/expect-utils';\n\nexport const eq = {\n exact: (a?: unknown, b?: unknown): boolean => equals(a, b, []),\n subset: (a?: unknown, b?: unknown): boolean => equals(a, b, [iterableEquality, subsetEquality]),\n string: (a?: unknown, b?: unknown): boolean => asString(a) === asString(b),\n};\n"],"mappings":";;;AAGA,MAAa,KAAK;CAChB,QAAQ,GAAa,MAAyB,OAAO,GAAG,GAAG,CAAC,CAAC;CAC7D,SAAS,GAAa,MAAyB,OAAO,GAAG,GAAG,CAAC,kBAAkB,cAAc,CAAC;CAC9F,SAAS,GAAa,MAAyB,SAAS,CAAC,MAAM,SAAS,CAAC;AAC3E"}
@@ -1,14 +1,17 @@
1
- import { Id, Json, JsonValue, OneOrMore, Text } from './Types';
1
+ import { Id, Json, JsonValue, OneOrMore, Text } from "./Types.js";
2
+ //#region src/utils/Req.d.ts
2
3
  export declare class Req<B = unknown> {
3
- readonly state: any;
4
- readonly skip: number | undefined;
5
- readonly take: number | undefined;
6
- constructor(state?: any);
7
- get id(): Id;
8
- get q(): JsonValue;
9
- get path(): Json;
10
- get query(): Json;
11
- get body(): B;
12
- get headers(): Record<string, OneOrMore<string>>;
13
- get: (key: Text) => any;
4
+ readonly state: any;
5
+ readonly skip: number | undefined;
6
+ readonly take: number | undefined;
7
+ constructor(state?: any);
8
+ get id(): Id;
9
+ get q(): JsonValue;
10
+ get path(): Json;
11
+ get query(): Json;
12
+ get body(): B;
13
+ get headers(): Record<string, OneOrMore<string>>;
14
+ get: (key: Text) => any;
14
15
  }
16
+ //#endregion
17
+ //# sourceMappingURL=Req.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { asNumber, isDefined } from "./Utils.js";
2
+ //#region src/utils/Req.ts
3
+ var Req = class {
4
+ state;
5
+ skip;
6
+ take;
7
+ constructor(state = {}) {
8
+ this.state = state;
9
+ this.skip = isDefined(this.query?.skip) ? asNumber(this.query?.skip) : void 0;
10
+ this.take = isDefined(this.query?.take) ? asNumber(this.query?.take) : void 0;
11
+ }
12
+ get id() {
13
+ return this.state.id ?? this.path.id;
14
+ }
15
+ get q() {
16
+ return this.state.q ?? this.query.q;
17
+ }
18
+ get path() {
19
+ return this.state?.path ?? {};
20
+ }
21
+ get query() {
22
+ return this.state?.query ?? {};
23
+ }
24
+ get body() {
25
+ return this.state.body;
26
+ }
27
+ get headers() {
28
+ return this.state.headers;
29
+ }
30
+ get = (key) => this?.state[key.toString()] ?? this.path[key.toString()] ?? this.query[key.toString()];
31
+ };
32
+ //#endregion
33
+ export { Req };
34
+
35
+ //# sourceMappingURL=Req.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Req.js","names":[],"sources":["../../src/utils/Req.ts"],"sourcesContent":["import { asNumber, isDefined } from './Utils';\nimport { Id, Json, JsonValue, OneOrMore, Text } from './Types';\n\nexport class Req<B = unknown> {\n readonly skip: number | undefined;\n readonly take: number | undefined;\n\n constructor(readonly state: any = {}) {\n this.skip = isDefined(this.query?.skip) ? asNumber(this.query?.skip) : undefined;\n this.take = isDefined(this.query?.take) ? asNumber(this.query?.take) : undefined;\n }\n\n get id(): Id {\n return this.state.id ?? this.path.id;\n }\n\n get q(): JsonValue {\n return this.state.q ?? this.query.q;\n }\n\n get path(): Json {\n return this.state?.path ?? {};\n }\n\n get query(): Json {\n return this.state?.query ?? {};\n }\n\n get body(): B {\n return this.state.body;\n }\n\n get headers(): Record<string, OneOrMore<string>> {\n return this.state.headers;\n }\n\n get = (key: Text): any => this?.state[key.toString()] ?? this.path[key.toString()] ?? this.query[key.toString()];\n}\n"],"mappings":";;AAGA,IAAa,MAAb,MAA8B;CAIP;CAHrB;CACA;CAEA,YAAY,QAAsB,CAAC,GAAG;EAAjB,KAAA,QAAA;EACnB,KAAK,OAAO,UAAU,KAAK,OAAO,IAAI,IAAI,SAAS,KAAK,OAAO,IAAI,IAAI,KAAA;EACvE,KAAK,OAAO,UAAU,KAAK,OAAO,IAAI,IAAI,SAAS,KAAK,OAAO,IAAI,IAAI,KAAA;CACzE;CAEA,IAAI,KAAS;EACX,OAAO,KAAK,MAAM,MAAM,KAAK,KAAK;CACpC;CAEA,IAAI,IAAe;EACjB,OAAO,KAAK,MAAM,KAAK,KAAK,MAAM;CACpC;CAEA,IAAI,OAAa;EACf,OAAO,KAAK,OAAO,QAAQ,CAAC;CAC9B;CAEA,IAAI,QAAc;EAChB,OAAO,KAAK,OAAO,SAAS,CAAC;CAC/B;CAEA,IAAI,OAAU;EACZ,OAAO,KAAK,MAAM;CACpB;CAEA,IAAI,UAA6C;EAC/C,OAAO,KAAK,MAAM;CACpB;CAEA,OAAO,QAAmB,MAAM,MAAM,IAAI,SAAS,MAAM,KAAK,KAAK,IAAI,SAAS,MAAM,KAAK,MAAM,IAAI,SAAS;AAChH"}
@@ -1,25 +1,28 @@
1
- import { Id } from './Types';
1
+ import { Id } from "./Types.js";
2
+ //#region src/utils/Response.d.ts
2
3
  export type HttpStatus = {
3
- name: string;
4
- id: Id;
4
+ name: string;
5
+ id: Id;
5
6
  };
6
7
  export type RestResult = {
7
- data?: {
8
- code: number;
9
- items: unknown[];
10
- itemCount: number;
11
- };
12
- error?: {
13
- code: number;
14
- message: string;
15
- errorCount: number;
16
- errors: unknown[];
17
- };
8
+ data?: {
9
+ code: number;
10
+ items: unknown[];
11
+ itemCount: number;
12
+ };
13
+ error?: {
14
+ code: number;
15
+ message: string;
16
+ errorCount: number;
17
+ errors: unknown[];
18
+ };
18
19
  };
19
20
  export type Response = {
20
- status: HttpStatus;
21
- headers?: {
22
- [key: string]: any;
23
- };
24
- body?: RestResult;
21
+ status: HttpStatus;
22
+ headers?: {
23
+ [key: string]: any;
24
+ };
25
+ body?: RestResult;
25
26
  };
27
+ //#endregion
28
+ //# sourceMappingURL=Response.d.ts.map
File without changes
@@ -1,44 +1,45 @@
1
+ //#region src/utils/Types.d.ts
1
2
  export type OneOrMore<T> = T | Array<T>;
2
3
  export type ArrayLike<T> = OneOrMore<T>[];
3
4
  export type Constructor<T> = {
4
- new (...args: any[]): T;
5
+ new (...args: any[]): T;
5
6
  };
6
7
  export type Message<P> = Text | ((...params: P[]) => Text);
7
8
  export declare const toMessage: <P>(g: Message<P>, ...params: P[]) => string;
8
9
  export type Validatable = {
9
- isValid: boolean;
10
+ isValid: boolean;
10
11
  };
11
12
  export type Result = {
12
- domain?: string;
13
- location?: string;
14
- message: string;
13
+ domain?: string;
14
+ location?: string;
15
+ message: string;
15
16
  };
16
17
  export type Results = Validatable & {
17
- results: Result[];
18
+ results: Result[];
18
19
  };
19
20
  export type Uri = Text;
20
21
  export type Id = string | number;
21
22
  export type JsonValue = string | number | boolean | null | Json | JsonValue[];
22
23
  export type Json = {
23
- [key: string]: JsonValue;
24
+ [key: string]: JsonValue;
24
25
  };
25
26
  export type Exception = {
26
- id: Id;
27
- reason?: string;
27
+ id: Id;
28
+ reason?: string;
28
29
  };
29
30
  export type Text = {
30
- toString: () => string;
31
+ toString: () => string;
31
32
  };
32
33
  export type Query = Text;
33
34
  export type UseCase = {
34
- app: {
35
- id: Text;
36
- };
35
+ app: {
37
36
  id: Text;
37
+ };
38
+ id: Text;
38
39
  };
39
40
  export type Tester = {
40
- url: string;
41
- };
42
- export type CreateMutable<T> = {
43
- -readonly [P in keyof T]: T[P];
41
+ url: string;
44
42
  };
43
+ export type CreateMutable<T> = { -readonly [P in keyof T]: T[P]; };
44
+ //#endregion
45
+ //# sourceMappingURL=Types.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { asString, isFunction } from "./Utils.js";
2
+ //#region src/utils/Types.ts
3
+ const toMessage = (g, ...params) => asString(isFunction(g) ? g(...params) : g);
4
+ //#endregion
5
+ export { toMessage };
6
+
7
+ //# sourceMappingURL=Types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Types.js","names":[],"sources":["../../src/utils/Types.ts"],"sourcesContent":["import { asString, isFunction } from './Utils';\n\nexport type OneOrMore<T> = T | Array<T>;\n\nexport type ArrayLike<T> = OneOrMore<T>[];\n\nexport type Constructor<T> = { new (...args: any[]): T };\n\nexport type Message<P> = Text | ((...params: P[]) => Text);\n\nexport const toMessage = <P>(g: Message<P>, ...params: P[]): string => asString(isFunction(g) ? g(...params) : g);\n\nexport type Validatable = { isValid: boolean };\n\nexport type Result = { domain?: string; location?: string; message: string };\n\nexport type Results = Validatable & { results: Result[] };\n\nexport type Uri = Text;\n\nexport type Id = string | number;\n\nexport type JsonValue = string | number | boolean | null | Json | JsonValue[];\n\nexport type Json = { [key: string]: JsonValue };\n\nexport type Exception = { id: Id; reason?: string };\n\nexport type Text = { toString: () => string };\n\nexport type Query = Text;\n\nexport type UseCase = { app: { id: Text }; id: Text };\n\nexport type Tester = { url: string };\n\nexport type CreateMutable<T> = { -readonly [P in keyof T]: T[P] };\n"],"mappings":";;AAUA,MAAa,aAAgB,GAAe,GAAG,WAAwB,SAAS,WAAW,CAAC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC"}
@@ -1,4 +1,5 @@
1
- import { ArrayLike } from './Types';
1
+ import { ArrayLike } from "./Types.js";
2
+ //#region src/utils/Utils.d.ts
2
3
  export declare const isDefined: <T = unknown>(o?: T) => boolean;
3
4
  export declare const isNumber: (o?: unknown) => o is number;
4
5
  export declare const isFunction: (o?: unknown) => o is (...params: unknown[]) => unknown;
@@ -10,3 +11,5 @@ export declare const asJson: (a?: unknown) => any;
10
11
  export declare const asString: (a?: unknown) => string;
11
12
  export declare const asNumber: (num: unknown, alt?: number | (() => number)) => number;
12
13
  export declare const toArray: <T>(...items: ArrayLike<T>) => T[];
14
+ //#endregion
15
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1,19 @@
1
+ //#region src/utils/Utils.ts
2
+ const isDefined = (o) => o !== void 0 && o !== null;
3
+ const isNumber = (o) => isDefined(o) && typeof o === "number" && !Number.isNaN(o);
4
+ const isFunction = (o) => isDefined(o) && typeof o === "function";
5
+ const isA = (t, ...properties) => isDefined(t) && properties.every((p) => isDefined(t[p]));
6
+ const isAn = isA;
7
+ const isArray = (o) => isDefined(o) && o instanceof Array;
8
+ const isObject = (o) => o != null && (typeof o === "object" || typeof o === "function") && !isArray(o);
9
+ const asJson = (a) => a?.toJSON ? a.toJSON() : isObject(a) ? a : void 0;
10
+ const asString = (a) => a?.toString();
11
+ const asNumber = (num, alt) => {
12
+ const n = parseInt(asString(num));
13
+ return isNumber(n) ? n : isFunction(alt) ? alt() : isNumber(alt) ? alt : NaN;
14
+ };
15
+ const toArray = (...items) => items.length > 1 ? items : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];
16
+ //#endregion
17
+ export { asJson, asNumber, asString, isA, isAn, isArray, isDefined, isFunction, isNumber, isObject, toArray };
18
+
19
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js","names":[],"sources":["../../src/utils/Utils.ts"],"sourcesContent":["import { ArrayLike } from './Types';\n\nexport const isDefined = <T = unknown>(o?: T): boolean => o !== undefined && o !== null;\n\nexport const isNumber = (o?: unknown): o is number => isDefined(o) && typeof o === 'number' && !Number.isNaN(o);\nexport const isFunction = (o?: unknown): o is (...params: unknown[]) => unknown => isDefined(o) && typeof o === 'function';\n\nexport const isA = <T>(t?: unknown, ...properties: (keyof T)[]): t is T => isDefined(t) && properties.every(p => isDefined((t as T)[p]));\nexport const isAn = isA;\n\nexport const isArray = <T = any>(o?: unknown): o is Array<T> => isDefined(o) && o instanceof Array;\nexport const isObject = (o?: unknown): o is Record<string, unknown> => o != null && (typeof o === 'object' || typeof o === 'function') && !isArray(o);\n\nexport const asJson = (a?: unknown): any => ((a as any)?.toJSON ? (a as any).toJSON() : isObject(a) ? a : undefined);\nexport const asString = (a?: unknown): string => (a as any)?.toString();\n\nexport const asNumber = (num: unknown, alt?: number | (() => number)): number => {\n const n = parseInt(asString(num));\n return isNumber(n) ? n : isFunction(alt) ? alt() : isNumber(alt) ? alt : NaN;\n};\n\nexport const toArray = <T>(...items: ArrayLike<T>): T[] =>\n items.length > 1 ? (items as T[]) : isArray(items[0]) ? items[0] : isDefined(items[0]) ? [items[0]] : [];\n"],"mappings":";AAEA,MAAa,aAA0B,MAAmB,MAAM,KAAA,KAAa,MAAM;AAEnF,MAAa,YAAY,MAA6B,UAAU,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,OAAO,MAAM,CAAC;AAC9G,MAAa,cAAc,MAAwD,UAAU,CAAC,KAAK,OAAO,MAAM;AAEhH,MAAa,OAAU,GAAa,GAAG,eAAoC,UAAU,CAAC,KAAK,WAAW,OAAM,MAAK,UAAW,EAAQ,EAAE,CAAC;AACvI,MAAa,OAAO;AAEpB,MAAa,WAAoB,MAA+B,UAAU,CAAC,KAAK,aAAa;AAC7F,MAAa,YAAY,MAA8C,KAAK,SAAS,OAAO,MAAM,YAAY,OAAO,MAAM,eAAe,CAAC,QAAQ,CAAC;AAEpJ,MAAa,UAAU,MAAuB,GAAW,SAAU,EAAU,OAAO,IAAI,SAAS,CAAC,IAAI,IAAI,KAAA;AAC1G,MAAa,YAAY,MAAyB,GAAW,SAAS;AAEtE,MAAa,YAAY,KAAc,QAA0C;CAC/E,MAAM,IAAI,SAAS,SAAS,GAAG,CAAC;CAChC,OAAO,SAAS,CAAC,IAAI,IAAI,WAAW,GAAG,IAAI,IAAI,IAAI,SAAS,GAAG,IAAI,MAAM;AAC3E;AAEA,MAAa,WAAc,GAAG,UAC5B,MAAM,SAAS,IAAK,QAAgB,QAAQ,MAAM,EAAE,IAAI,MAAM,KAAK,UAAU,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@thisisagile/easy-test",
3
- "version": "19.1.4",
3
+ "version": "20.0.0",
4
4
  "description": "Straightforward library for testing microservices built with @thisisagile/easy",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
7
+ "type": "module",
7
8
  "main": "dist/index.js",
8
- "module": "dist/index.mjs",
9
+ "module": "dist/index.js",
9
10
  "types": "dist/index.d.ts",
10
11
  "repository": {
11
12
  "type": "git",
@@ -22,8 +23,7 @@
22
23
  "scripts": {
23
24
  "lint": "yarn g:eslint . --ext .js,.jsx,.ts,.tsx --fix",
24
25
  "format": "yarn g:prettier --check --write src test *.json",
25
- "build": "yarn build:tsup",
26
- "build:tsup": "yarn g:tsup && yarn g:tsc --emitDeclarationOnly --declaration",
26
+ "build": "yarn g:tsdown && yarn g:exports",
27
27
  "test": "yarn g:jest --coverage",
28
28
  "prepack": "yarn g:copy-readme"
29
29
  },
@@ -35,6 +35,9 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
+ "engines": {
39
+ "node": ">=20.19.0"
40
+ },
38
41
  "devDependencies": {
39
42
  "typescript": "^5.7.3",
40
43
  "weak-napi": "^2.0.2"
@@ -52,120 +55,119 @@
52
55
  "exports": {
53
56
  ".": {
54
57
  "types": "./dist/index.d.ts",
55
- "import": "./dist/index.mjs",
56
- "require": "./dist/index.js"
58
+ "default": "./dist/index.js"
57
59
  },
58
60
  "./matchers/Check": {
59
61
  "types": "./dist/matchers/Check.d.ts",
60
- "import": "./dist/matchers/Check.mjs"
62
+ "default": "./dist/matchers/Check.js"
61
63
  },
62
64
  "./matchers/HttpMatchers": {
63
65
  "types": "./dist/matchers/HttpMatchers.d.ts",
64
- "import": "./dist/matchers/HttpMatchers.mjs"
66
+ "default": "./dist/matchers/HttpMatchers.js"
65
67
  },
66
68
  "./matchers/Match": {
67
69
  "types": "./dist/matchers/Match.d.ts",
68
- "import": "./dist/matchers/Match.mjs"
70
+ "default": "./dist/matchers/Match.js"
69
71
  },
70
72
  "./matchers/ResultMatchers": {
71
73
  "types": "./dist/matchers/ResultMatchers.d.ts",
72
- "import": "./dist/matchers/ResultMatchers.mjs"
74
+ "default": "./dist/matchers/ResultMatchers.js"
73
75
  },
74
76
  "./matchers/index": {
75
77
  "types": "./dist/matchers/index.d.ts",
76
- "import": "./dist/matchers/index.mjs"
78
+ "default": "./dist/matchers/index.js"
77
79
  },
78
80
  "./matchers/toBeArrayOf": {
79
81
  "types": "./dist/matchers/toBeArrayOf.d.ts",
80
- "import": "./dist/matchers/toBeArrayOf.mjs"
82
+ "default": "./dist/matchers/toBeArrayOf.js"
81
83
  },
82
84
  "./matchers/toBeArrayOfWithLength": {
83
85
  "types": "./dist/matchers/toBeArrayOfWithLength.d.ts",
84
- "import": "./dist/matchers/toBeArrayOfWithLength.mjs"
86
+ "default": "./dist/matchers/toBeArrayOfWithLength.js"
85
87
  },
86
88
  "./matchers/toBeAt": {
87
89
  "types": "./dist/matchers/toBeAt.d.ts",
88
- "import": "./dist/matchers/toBeAt.mjs"
90
+ "default": "./dist/matchers/toBeAt.js"
89
91
  },
90
92
  "./matchers/toBeExactlyAt": {
91
93
  "types": "./dist/matchers/toBeExactlyAt.d.ts",
92
- "import": "./dist/matchers/toBeExactlyAt.mjs"
94
+ "default": "./dist/matchers/toBeExactlyAt.js"
93
95
  },
94
96
  "./matchers/toBeQueriedWith": {
95
97
  "types": "./dist/matchers/toBeQueriedWith.d.ts",
96
- "import": "./dist/matchers/toBeQueriedWith.mjs"
98
+ "default": "./dist/matchers/toBeQueriedWith.js"
97
99
  },
98
100
  "./matchers/toBeRoutedTo": {
99
101
  "types": "./dist/matchers/toBeRoutedTo.d.ts",
100
- "import": "./dist/matchers/toBeRoutedTo.mjs"
102
+ "default": "./dist/matchers/toBeRoutedTo.js"
101
103
  },
102
104
  "./matchers/toBeValid": {
103
105
  "types": "./dist/matchers/toBeValid.d.ts",
104
- "import": "./dist/matchers/toBeValid.mjs"
106
+ "default": "./dist/matchers/toBeValid.js"
105
107
  },
106
108
  "./matchers/toFailMatcher": {
107
109
  "types": "./dist/matchers/toFailMatcher.d.ts",
108
- "import": "./dist/matchers/toFailMatcher.mjs"
110
+ "default": "./dist/matchers/toFailMatcher.js"
109
111
  },
110
112
  "./matchers/toMatchArray": {
111
113
  "types": "./dist/matchers/toMatchArray.d.ts",
112
- "import": "./dist/matchers/toMatchArray.mjs"
114
+ "default": "./dist/matchers/toMatchArray.js"
113
115
  },
114
116
  "./matchers/toMatchExactJson": {
115
117
  "types": "./dist/matchers/toMatchExactJson.d.ts",
116
- "import": "./dist/matchers/toMatchExactJson.mjs"
118
+ "default": "./dist/matchers/toMatchExactJson.js"
117
119
  },
118
120
  "./matchers/toMatchException": {
119
121
  "types": "./dist/matchers/toMatchException.d.ts",
120
- "import": "./dist/matchers/toMatchException.mjs"
122
+ "default": "./dist/matchers/toMatchException.js"
121
123
  },
122
124
  "./matchers/toMatchJson": {
123
125
  "types": "./dist/matchers/toMatchJson.d.ts",
124
- "import": "./dist/matchers/toMatchJson.mjs"
126
+ "default": "./dist/matchers/toMatchJson.js"
125
127
  },
126
128
  "./matchers/toMatchRoute": {
127
129
  "types": "./dist/matchers/toMatchRoute.d.ts",
128
- "import": "./dist/matchers/toMatchRoute.mjs"
130
+ "default": "./dist/matchers/toMatchRoute.js"
129
131
  },
130
132
  "./matchers/toMatchText": {
131
133
  "types": "./dist/matchers/toMatchText.d.ts",
132
- "import": "./dist/matchers/toMatchText.mjs"
134
+ "default": "./dist/matchers/toMatchText.js"
133
135
  },
134
136
  "./matchers/toPassMatcher": {
135
137
  "types": "./dist/matchers/toPassMatcher.d.ts",
136
- "import": "./dist/matchers/toPassMatcher.mjs"
138
+ "default": "./dist/matchers/toPassMatcher.js"
137
139
  },
138
140
  "./mock/Fits": {
139
141
  "types": "./dist/mock/Fits.d.ts",
140
- "import": "./dist/mock/Fits.mjs"
142
+ "default": "./dist/mock/Fits.js"
141
143
  },
142
144
  "./mock/Mocks": {
143
145
  "types": "./dist/mock/Mocks.d.ts",
144
- "import": "./dist/mock/Mocks.mjs"
146
+ "default": "./dist/mock/Mocks.js"
145
147
  },
146
148
  "./mock/index": {
147
149
  "types": "./dist/mock/index.d.ts",
148
- "import": "./dist/mock/index.mjs"
150
+ "default": "./dist/mock/index.js"
149
151
  },
150
152
  "./utils/Eq": {
151
153
  "types": "./dist/utils/Eq.d.ts",
152
- "import": "./dist/utils/Eq.mjs"
154
+ "default": "./dist/utils/Eq.js"
153
155
  },
154
156
  "./utils/Req": {
155
157
  "types": "./dist/utils/Req.d.ts",
156
- "import": "./dist/utils/Req.mjs"
158
+ "default": "./dist/utils/Req.js"
157
159
  },
158
160
  "./utils/Response": {
159
161
  "types": "./dist/utils/Response.d.ts",
160
- "import": "./dist/utils/Response.mjs"
162
+ "default": "./dist/utils/Response.js"
161
163
  },
162
164
  "./utils/Types": {
163
165
  "types": "./dist/utils/Types.d.ts",
164
- "import": "./dist/utils/Types.mjs"
166
+ "default": "./dist/utils/Types.js"
165
167
  },
166
168
  "./utils/Utils": {
167
169
  "types": "./dist/utils/Utils.d.ts",
168
- "import": "./dist/utils/Utils.mjs"
170
+ "default": "./dist/utils/Utils.js"
169
171
  },
170
172
  "./src/*": "./src/*",
171
173
  "./dist/*": "./dist/*",
@@ -1,12 +0,0 @@
1
- import {
2
- asString,
3
- isFunction
4
- } from "./chunk-O475TEG2.mjs";
5
-
6
- // src/utils/Types.ts
7
- var toMessage = (g, ...params) => asString(isFunction(g) ? g(...params) : g);
8
-
9
- export {
10
- toMessage
11
- };
12
- //# sourceMappingURL=chunk-6EKWTLNQ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/Types.ts"],"sourcesContent":["import { asString, isFunction } from './Utils';\n\nexport type OneOrMore<T> = T | Array<T>;\n\nexport type ArrayLike<T> = OneOrMore<T>[];\n\nexport type Constructor<T> = { new (...args: any[]): T };\n\nexport type Message<P> = Text | ((...params: P[]) => Text);\n\nexport const toMessage = <P>(g: Message<P>, ...params: P[]): string => asString(isFunction(g) ? g(...params) : g);\n\nexport type Validatable = { isValid: boolean };\n\nexport type Result = { domain?: string; location?: string; message: string };\n\nexport type Results = Validatable & { results: Result[] };\n\nexport type Uri = Text;\n\nexport type Id = string | number;\n\nexport type JsonValue = string | number | boolean | null | Json | JsonValue[];\n\nexport type Json = { [key: string]: JsonValue };\n\nexport type Exception = { id: Id; reason?: string };\n\nexport type Text = { toString: () => string };\n\nexport type Query = Text;\n\nexport type UseCase = { app: { id: Text }; id: Text };\n\nexport type Tester = { url: string };\n\nexport type CreateMutable<T> = { -readonly [P in keyof T]: T[P] };\n"],"mappings":";;;;;;AAUO,IAAM,YAAY,CAAI,MAAkB,WAAwB,SAAS,WAAW,CAAC,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC;","names":[]}
@@ -1,17 +0,0 @@
1
- import {
2
- match
3
- } from "./chunk-LN24S2PC.mjs";
4
- import {
5
- isA
6
- } from "./chunk-O475TEG2.mjs";
7
-
8
- // src/matchers/toBeValid.ts
9
- var 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`);
10
- expect.extend({
11
- toBeValid
12
- });
13
-
14
- export {
15
- toBeValid
16
- };
17
- //# sourceMappingURL=chunk-6FEQASGO.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"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":";;;;;;;;AAIO,IAAM,YAAY,CAAC,MACxB,MAAmB,CAAgB,EAChC,UAAU,OAAK,GAAG,uBAAuB,EACzC,IAAI,OAAK,IAAiB,GAAG,SAAS,GAAG,6BAA6B,EACtE,IAAI,OAAK,EAAE,SAAS,uBAAuB,EAC3C,KAAK,kBAAkB;AAE5B,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
@@ -1,25 +0,0 @@
1
- import {
2
- match
3
- } from "./chunk-LN24S2PC.mjs";
4
-
5
- // src/matchers/toBeAt.ts
6
- var toBeAt = (tester, uc, id) => {
7
- return match(tester).undefined((t) => t, "Tester is undefined").undefined((t) => t.url, "Tester does not contain a URL").undefined(() => uc, "Use case is undefined").not(
8
- (t) => t.url.includes(`/${uc?.app.id}`),
9
- (t) => `We expected the tester to be at app '${uc?.app.id}', but it is at '${t?.url}' instead.`
10
- ).not(
11
- (t) => t.url.includes(`/${uc?.id}`),
12
- (t) => `We expected the tester to be at use case '${uc?.id}', but it is at '${t?.url}' instead.`
13
- ).not(
14
- (t) => t.url.includes(id ? `/${id}` : ""),
15
- (t) => `We expected the path to contain '/42', but it is '${t?.url}' instead.`
16
- ).else((t) => `The tester is at '${t?.url}'`);
17
- };
18
- expect.extend({
19
- toBeAt
20
- });
21
-
22
- export {
23
- toBeAt
24
- };
25
- //# sourceMappingURL=chunk-ART72TJA.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/matchers/toBeAt.ts"],"sourcesContent":["import { Id, Tester, UseCase } from '../utils/Types';\nimport { match } from './Match';\n\nexport const toBeAt = (tester?: Tester, uc?: UseCase, id?: Id): jest.CustomMatcherResult => {\n return match<Tester>(tester as Tester)\n .undefined(t => t, 'Tester is undefined')\n .undefined(t => t.url, 'Tester does not contain a URL')\n .undefined(() => uc, 'Use case is undefined')\n .not(\n t => t.url.includes(`/${uc?.app.id}`),\n t => `We expected the tester to be at app '${uc?.app.id}', but it is at '${t?.url}' instead.`\n )\n .not(\n t => t.url.includes(`/${uc?.id}`),\n t => `We expected the tester to be at use case '${uc?.id}', but it is at '${t?.url}' instead.`\n )\n .not(\n t => t.url.includes(id ? `/${id}` : ''),\n t => `We expected the path to contain '/42', but it is '${t?.url}' instead.`\n )\n .else(t => `The tester is at '${t?.url}'`);\n};\n\nexpect.extend({\n toBeAt,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeAt(uc?: UseCase, id?: Id): R;\n }\n }\n}\n"],"mappings":";;;;;AAGO,IAAM,SAAS,CAAC,QAAiB,IAAc,OAAsC;AAC1F,SAAO,MAAc,MAAgB,EAClC,UAAU,OAAK,GAAG,qBAAqB,EACvC,UAAU,OAAK,EAAE,KAAK,+BAA+B,EACrD,UAAU,MAAM,IAAI,uBAAuB,EAC3C;AAAA,IACC,OAAK,EAAE,IAAI,SAAS,IAAI,IAAI,IAAI,EAAE,EAAE;AAAA,IACpC,OAAK,wCAAwC,IAAI,IAAI,EAAE,oBAAoB,GAAG,GAAG;AAAA,EACnF,EACC;AAAA,IACC,OAAK,EAAE,IAAI,SAAS,IAAI,IAAI,EAAE,EAAE;AAAA,IAChC,OAAK,6CAA6C,IAAI,EAAE,oBAAoB,GAAG,GAAG;AAAA,EACpF,EACC;AAAA,IACC,OAAK,EAAE,IAAI,SAAS,KAAK,IAAI,EAAE,KAAK,EAAE;AAAA,IACtC,OAAK,qDAAqD,GAAG,GAAG;AAAA,EAClE,EACC,KAAK,OAAK,qBAAqB,GAAG,GAAG,GAAG;AAC7C;AAEA,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
@@ -1,24 +0,0 @@
1
- import {
2
- eq
3
- } from "./chunk-QE3TR4BY.mjs";
4
- import {
5
- match
6
- } from "./chunk-LN24S2PC.mjs";
7
-
8
- // src/matchers/toMatchExactJson.ts
9
- var MatchesExactJson = {
10
- SubjectUndefined: "Subject is undefined.",
11
- SubsetUndefined: "Object to match with is undefined.",
12
- DoesNotMatch: "Object does not exactly match subject.",
13
- Yes: "Object matches subject exactly"
14
- };
15
- var 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);
16
- expect.extend({
17
- toMatchExactJson
18
- });
19
-
20
- export {
21
- MatchesExactJson,
22
- toMatchExactJson
23
- };
24
- //# sourceMappingURL=chunk-BN2IG45X.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"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":";;;;;;;;AAGO,IAAM,mBAAmB;AAAA,EAC9B,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,KAAK;AACP;AAEO,IAAM,mBAAmB,CAAC,OAAiB,SAChD,MAAe,KAAK,EACjB,UAAU,OAAK,GAAG,iBAAiB,gBAAgB,EACnD,UAAU,MAAM,MAAM,iBAAiB,eAAe,EACtD,IAAI,OAAK,GAAG,MAAM,GAAG,IAAI,GAAG,iBAAiB,YAAY,EACzD,KAAK,MAAM,iBAAiB,GAAG;AAEpC,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}
@@ -1,26 +0,0 @@
1
- import {
2
- match
3
- } from "./chunk-LN24S2PC.mjs";
4
- import {
5
- isDefined
6
- } from "./chunk-O475TEG2.mjs";
7
-
8
- // src/matchers/toBeExactlyAt.ts
9
- var toUrl = (uc, id) => {
10
- const i = isDefined(id) ? `/${id}` : "";
11
- return `/${uc.app.id}/${uc.id}${i}`;
12
- };
13
- var toBeExactlyAt = (tester, uc, id) => {
14
- return match(tester).undefined((t) => t, "Tester is undefined").undefined((t) => t.url, "Tester does not contain a URL").undefined(() => uc, "Use case is undefined").not(
15
- (t) => t.url.includes(toUrl(uc, id)),
16
- (t) => `We expected the tester to be at: '${toUrl(uc, id)}', but it is at: '${t?.url}' instead.`
17
- ).else((t) => `The tester is at '${t?.url}'`);
18
- };
19
- expect.extend({
20
- toBeExactlyAt
21
- });
22
-
23
- export {
24
- toBeExactlyAt
25
- };
26
- //# sourceMappingURL=chunk-BZXBZCMZ.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/matchers/toBeExactlyAt.ts"],"sourcesContent":["import { Id, Tester, UseCase } from '../utils/Types';\nimport { isDefined } from '../utils/Utils';\nimport { match } from './Match';\n\nconst toUrl = (uc: UseCase, id?: Id): string => {\n const i = isDefined(id) ? `/${id}` : '';\n return `/${uc.app.id}/${uc.id}${i}`;\n};\n\nexport const toBeExactlyAt = (tester?: Tester, uc?: UseCase, id?: Id): jest.CustomMatcherResult => {\n return match<Tester>(tester as Tester)\n .undefined(t => t, 'Tester is undefined')\n .undefined(t => t.url, 'Tester does not contain a URL')\n .undefined(() => uc, 'Use case is undefined')\n .not(\n t => t.url.includes(toUrl(uc as UseCase, id)),\n t => `We expected the tester to be at: '${toUrl(uc as UseCase, id)}', but it is at: '${t?.url}' instead.`\n )\n .else(t => `The tester is at '${t?.url}'`);\n};\n\nexpect.extend({\n toBeExactlyAt,\n});\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n interface Matchers<R, T> {\n toBeExactlyAt(uc?: UseCase, id?: Id): R;\n }\n }\n}\n"],"mappings":";;;;;;;;AAIA,IAAM,QAAQ,CAAC,IAAa,OAAoB;AAC9C,QAAM,IAAI,UAAU,EAAE,IAAI,IAAI,EAAE,KAAK;AACrC,SAAO,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,EAAE,GAAG,CAAC;AACnC;AAEO,IAAM,gBAAgB,CAAC,QAAiB,IAAc,OAAsC;AACjG,SAAO,MAAc,MAAgB,EAClC,UAAU,OAAK,GAAG,qBAAqB,EACvC,UAAU,OAAK,EAAE,KAAK,+BAA+B,EACrD,UAAU,MAAM,IAAI,uBAAuB,EAC3C;AAAA,IACC,OAAK,EAAE,IAAI,SAAS,MAAM,IAAe,EAAE,CAAC;AAAA,IAC5C,OAAK,qCAAqC,MAAM,IAAe,EAAE,CAAC,qBAAqB,GAAG,GAAG;AAAA,EAC/F,EACC,KAAK,OAAK,qBAAqB,GAAG,GAAG,GAAG;AAC7C;AAEA,OAAO,OAAO;AAAA,EACZ;AACF,CAAC;","names":[]}