hein 1.3.5 → 1.3.6

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 (228) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/DIFFERENCES_WITH_CHAI.md +49 -0
  3. package/dist/utils/fail.d.ts +1 -1
  4. package/dist/utils/fail.d.ts.map +1 -1
  5. package/dist/utils/fail.js +2 -2
  6. package/dist/utils/fail.js.map +1 -1
  7. package/package.json +5 -8
  8. package/dist/.tsbuildinfo +0 -1
  9. package/dist/assert/deep-equal.test.d.ts +0 -2
  10. package/dist/assert/deep-equal.test.d.ts.map +0 -1
  11. package/dist/assert/deep-equal.test.js +0 -128
  12. package/dist/assert/deep-equal.test.js.map +0 -1
  13. package/dist/assert/deep-has-property.test.d.ts +0 -2
  14. package/dist/assert/deep-has-property.test.d.ts.map +0 -1
  15. package/dist/assert/deep-has-property.test.js +0 -40
  16. package/dist/assert/deep-has-property.test.js.map +0 -1
  17. package/dist/assert/ends-with.test.d.ts +0 -2
  18. package/dist/assert/ends-with.test.d.ts.map +0 -1
  19. package/dist/assert/ends-with.test.js +0 -24
  20. package/dist/assert/ends-with.test.js.map +0 -1
  21. package/dist/assert/equal.test.d.ts +0 -2
  22. package/dist/assert/equal.test.d.ts.map +0 -1
  23. package/dist/assert/equal.test.js +0 -57
  24. package/dist/assert/equal.test.js.map +0 -1
  25. package/dist/assert/greater-than-equal.test.d.ts +0 -2
  26. package/dist/assert/greater-than-equal.test.d.ts.map +0 -1
  27. package/dist/assert/greater-than-equal.test.js +0 -17
  28. package/dist/assert/greater-than-equal.test.js.map +0 -1
  29. package/dist/assert/greater-than.test.d.ts +0 -2
  30. package/dist/assert/greater-than.test.d.ts.map +0 -1
  31. package/dist/assert/greater-than.test.js +0 -31
  32. package/dist/assert/greater-than.test.js.map +0 -1
  33. package/dist/assert/has-members.test.d.ts +0 -2
  34. package/dist/assert/has-members.test.d.ts.map +0 -1
  35. package/dist/assert/has-members.test.js +0 -85
  36. package/dist/assert/has-members.test.js.map +0 -1
  37. package/dist/assert/has-property.test.d.ts +0 -2
  38. package/dist/assert/has-property.test.d.ts.map +0 -1
  39. package/dist/assert/has-property.test.js +0 -40
  40. package/dist/assert/has-property.test.js.map +0 -1
  41. package/dist/assert/has-size.test.d.ts +0 -2
  42. package/dist/assert/has-size.test.d.ts.map +0 -1
  43. package/dist/assert/has-size.test.js +0 -171
  44. package/dist/assert/has-size.test.js.map +0 -1
  45. package/dist/assert/in-ballpark.test.d.ts +0 -2
  46. package/dist/assert/in-ballpark.test.d.ts.map +0 -1
  47. package/dist/assert/in-ballpark.test.js +0 -36
  48. package/dist/assert/in-ballpark.test.js.map +0 -1
  49. package/dist/assert/includes.test.d.ts +0 -2
  50. package/dist/assert/includes.test.d.ts.map +0 -1
  51. package/dist/assert/includes.test.js +0 -45
  52. package/dist/assert/includes.test.js.map +0 -1
  53. package/dist/assert/instance-of.test.d.ts +0 -2
  54. package/dist/assert/instance-of.test.d.ts.map +0 -1
  55. package/dist/assert/instance-of.test.js +0 -24
  56. package/dist/assert/instance-of.test.js.map +0 -1
  57. package/dist/assert/is-after.test.d.ts +0 -2
  58. package/dist/assert/is-after.test.d.ts.map +0 -1
  59. package/dist/assert/is-after.test.js +0 -32
  60. package/dist/assert/is-after.test.js.map +0 -1
  61. package/dist/assert/is-before.test.d.ts +0 -2
  62. package/dist/assert/is-before.test.d.ts.map +0 -1
  63. package/dist/assert/is-before.test.js +0 -32
  64. package/dist/assert/is-before.test.js.map +0 -1
  65. package/dist/assert/is-between.test.d.ts +0 -2
  66. package/dist/assert/is-between.test.d.ts.map +0 -1
  67. package/dist/assert/is-between.test.js +0 -47
  68. package/dist/assert/is-between.test.js.map +0 -1
  69. package/dist/assert/is-empty.test.d.ts +0 -2
  70. package/dist/assert/is-empty.test.d.ts.map +0 -1
  71. package/dist/assert/is-empty.test.js +0 -80
  72. package/dist/assert/is-empty.test.js.map +0 -1
  73. package/dist/assert/is-type.test.d.ts +0 -2
  74. package/dist/assert/is-type.test.d.ts.map +0 -1
  75. package/dist/assert/is-type.test.js +0 -36
  76. package/dist/assert/is-type.test.js.map +0 -1
  77. package/dist/assert/less-than-equal.test.d.ts +0 -2
  78. package/dist/assert/less-than-equal.test.d.ts.map +0 -1
  79. package/dist/assert/less-than-equal.test.js +0 -51
  80. package/dist/assert/less-than-equal.test.js.map +0 -1
  81. package/dist/assert/less-than.test.d.ts +0 -2
  82. package/dist/assert/less-than.test.d.ts.map +0 -1
  83. package/dist/assert/less-than.test.js +0 -28
  84. package/dist/assert/less-than.test.js.map +0 -1
  85. package/dist/assert/match.test.d.ts +0 -2
  86. package/dist/assert/match.test.d.ts.map +0 -1
  87. package/dist/assert/match.test.js +0 -24
  88. package/dist/assert/match.test.js.map +0 -1
  89. package/dist/assert/rejects.test.d.ts +0 -2
  90. package/dist/assert/rejects.test.d.ts.map +0 -1
  91. package/dist/assert/rejects.test.js +0 -101
  92. package/dist/assert/rejects.test.js.map +0 -1
  93. package/dist/assert/round-to.test.d.ts +0 -2
  94. package/dist/assert/round-to.test.d.ts.map +0 -1
  95. package/dist/assert/round-to.test.js +0 -33
  96. package/dist/assert/round-to.test.js.map +0 -1
  97. package/dist/assert/starts-with.test.d.ts +0 -2
  98. package/dist/assert/starts-with.test.d.ts.map +0 -1
  99. package/dist/assert/starts-with.test.js +0 -24
  100. package/dist/assert/starts-with.test.js.map +0 -1
  101. package/dist/assert/throws.test.d.ts +0 -2
  102. package/dist/assert/throws.test.d.ts.map +0 -1
  103. package/dist/assert/throws.test.js +0 -174
  104. package/dist/assert/throws.test.js.map +0 -1
  105. package/dist/expect/after.test.d.ts +0 -2
  106. package/dist/expect/after.test.d.ts.map +0 -1
  107. package/dist/expect/after.test.js +0 -26
  108. package/dist/expect/after.test.js.map +0 -1
  109. package/dist/expect/ballpark.test.d.ts +0 -2
  110. package/dist/expect/ballpark.test.d.ts.map +0 -1
  111. package/dist/expect/ballpark.test.js +0 -26
  112. package/dist/expect/ballpark.test.js.map +0 -1
  113. package/dist/expect/before.test.d.ts +0 -2
  114. package/dist/expect/before.test.d.ts.map +0 -1
  115. package/dist/expect/before.test.js +0 -26
  116. package/dist/expect/before.test.js.map +0 -1
  117. package/dist/expect/between.test.d.ts +0 -2
  118. package/dist/expect/between.test.d.ts.map +0 -1
  119. package/dist/expect/between.test.js +0 -34
  120. package/dist/expect/between.test.js.map +0 -1
  121. package/dist/expect/empty.test.d.ts +0 -2
  122. package/dist/expect/empty.test.d.ts.map +0 -1
  123. package/dist/expect/empty.test.js +0 -24
  124. package/dist/expect/empty.test.js.map +0 -1
  125. package/dist/expect/end-with.test.d.ts +0 -2
  126. package/dist/expect/end-with.test.d.ts.map +0 -1
  127. package/dist/expect/end-with.test.js +0 -15
  128. package/dist/expect/end-with.test.js.map +0 -1
  129. package/dist/expect/eql.test.d.ts +0 -2
  130. package/dist/expect/eql.test.d.ts.map +0 -1
  131. package/dist/expect/eql.test.js +0 -42
  132. package/dist/expect/eql.test.js.map +0 -1
  133. package/dist/expect/equal-shorthand.test.d.ts +0 -2
  134. package/dist/expect/equal-shorthand.test.d.ts.map +0 -1
  135. package/dist/expect/equal-shorthand.test.js +0 -34
  136. package/dist/expect/equal-shorthand.test.js.map +0 -1
  137. package/dist/expect/equal.test.d.ts +0 -2
  138. package/dist/expect/equal.test.d.ts.map +0 -1
  139. package/dist/expect/equal.test.js +0 -30
  140. package/dist/expect/equal.test.js.map +0 -1
  141. package/dist/expect/excluding.test.d.ts +0 -2
  142. package/dist/expect/excluding.test.d.ts.map +0 -1
  143. package/dist/expect/excluding.test.js +0 -12
  144. package/dist/expect/excluding.test.js.map +0 -1
  145. package/dist/expect/greater-than-equal.test.d.ts +0 -2
  146. package/dist/expect/greater-than-equal.test.d.ts.map +0 -1
  147. package/dist/expect/greater-than-equal.test.js +0 -24
  148. package/dist/expect/greater-than-equal.test.js.map +0 -1
  149. package/dist/expect/greater-than.test.d.ts +0 -2
  150. package/dist/expect/greater-than.test.d.ts.map +0 -1
  151. package/dist/expect/greater-than.test.js +0 -24
  152. package/dist/expect/greater-than.test.js.map +0 -1
  153. package/dist/expect/has-property.test.d.ts +0 -2
  154. package/dist/expect/has-property.test.d.ts.map +0 -1
  155. package/dist/expect/has-property.test.js +0 -39
  156. package/dist/expect/has-property.test.js.map +0 -1
  157. package/dist/expect/include.test.d.ts +0 -2
  158. package/dist/expect/include.test.d.ts.map +0 -1
  159. package/dist/expect/include.test.js +0 -33
  160. package/dist/expect/include.test.js.map +0 -1
  161. package/dist/expect/instance-of-shorthand.test.d.ts +0 -2
  162. package/dist/expect/instance-of-shorthand.test.d.ts.map +0 -1
  163. package/dist/expect/instance-of-shorthand.test.js +0 -42
  164. package/dist/expect/instance-of-shorthand.test.js.map +0 -1
  165. package/dist/expect/instance-of.test.d.ts +0 -2
  166. package/dist/expect/instance-of.test.d.ts.map +0 -1
  167. package/dist/expect/instance-of.test.js +0 -24
  168. package/dist/expect/instance-of.test.js.map +0 -1
  169. package/dist/expect/length.test.d.ts +0 -2
  170. package/dist/expect/length.test.d.ts.map +0 -1
  171. package/dist/expect/length.test.js +0 -24
  172. package/dist/expect/length.test.js.map +0 -1
  173. package/dist/expect/less-than-equal.test.d.ts +0 -2
  174. package/dist/expect/less-than-equal.test.d.ts.map +0 -1
  175. package/dist/expect/less-than-equal.test.js +0 -26
  176. package/dist/expect/less-than-equal.test.js.map +0 -1
  177. package/dist/expect/less-than.test.d.ts +0 -2
  178. package/dist/expect/less-than.test.d.ts.map +0 -1
  179. package/dist/expect/less-than.test.js +0 -26
  180. package/dist/expect/less-than.test.js.map +0 -1
  181. package/dist/expect/match.test.d.ts +0 -2
  182. package/dist/expect/match.test.d.ts.map +0 -1
  183. package/dist/expect/match.test.js +0 -24
  184. package/dist/expect/match.test.js.map +0 -1
  185. package/dist/expect/members.test.d.ts +0 -2
  186. package/dist/expect/members.test.d.ts.map +0 -1
  187. package/dist/expect/members.test.js +0 -59
  188. package/dist/expect/members.test.js.map +0 -1
  189. package/dist/expect/reject.test.d.ts +0 -2
  190. package/dist/expect/reject.test.d.ts.map +0 -1
  191. package/dist/expect/reject.test.js +0 -26
  192. package/dist/expect/reject.test.js.map +0 -1
  193. package/dist/expect/round-to.test.d.ts +0 -2
  194. package/dist/expect/round-to.test.d.ts.map +0 -1
  195. package/dist/expect/round-to.test.js +0 -20
  196. package/dist/expect/round-to.test.js.map +0 -1
  197. package/dist/expect/start-with.test.d.ts +0 -2
  198. package/dist/expect/start-with.test.d.ts.map +0 -1
  199. package/dist/expect/start-with.test.js +0 -15
  200. package/dist/expect/start-with.test.js.map +0 -1
  201. package/dist/expect/throw.test.d.ts +0 -2
  202. package/dist/expect/throw.test.d.ts.map +0 -1
  203. package/dist/expect/throw.test.js +0 -33
  204. package/dist/expect/throw.test.js.map +0 -1
  205. package/dist/expect/type-shorthand.test.d.ts +0 -2
  206. package/dist/expect/type-shorthand.test.d.ts.map +0 -1
  207. package/dist/expect/type-shorthand.test.js +0 -55
  208. package/dist/expect/type-shorthand.test.js.map +0 -1
  209. package/dist/expect/type.test.d.ts +0 -2
  210. package/dist/expect/type.test.d.ts.map +0 -1
  211. package/dist/expect/type.test.js +0 -24
  212. package/dist/expect/type.test.js.map +0 -1
  213. package/dist/expect.test.d.ts +0 -2
  214. package/dist/expect.test.d.ts.map +0 -1
  215. package/dist/expect.test.js +0 -22
  216. package/dist/expect.test.js.map +0 -1
  217. package/dist/utils/fail.test.d.ts +0 -2
  218. package/dist/utils/fail.test.d.ts.map +0 -1
  219. package/dist/utils/fail.test.js +0 -12
  220. package/dist/utils/fail.test.js.map +0 -1
  221. package/dist/utils/get-size.test.d.ts +0 -2
  222. package/dist/utils/get-size.test.d.ts.map +0 -1
  223. package/dist/utils/get-size.test.js +0 -28
  224. package/dist/utils/get-size.test.js.map +0 -1
  225. package/dist/utils/match.test.d.ts +0 -2
  226. package/dist/utils/match.test.d.ts.map +0 -1
  227. package/dist/utils/match.test.js +0 -333
  228. package/dist/utils/match.test.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-with.test.d.ts","sourceRoot":"","sources":["../../src/expect/start-with.test.ts"],"names":[],"mappings":""}
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const expect_1 = require("../expect");
4
- describe('expect/startWith', () => {
5
- it('should not throw if string starts with value', () => {
6
- (0, expect_1.expect)('abc').to.startWith('ab');
7
- });
8
- it('should throw if string does not start with substring', () => {
9
- (0, expect_1.expect)(() => (0, expect_1.expect)('abc').to.startWith('ba')).to.throw(/Expected 'abc' to start with 'ba'/);
10
- });
11
- it('should throw when inversed and string starts with substring', () => {
12
- (0, expect_1.expect)(() => (0, expect_1.expect)('abc').to.not.startWith('ab')).to.throw(/Expected 'abc' to not start with 'ab'/);
13
- });
14
- });
15
- //# sourceMappingURL=start-with.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start-with.test.js","sourceRoot":"","sources":["../../src/expect/start-with.test.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AAEnC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACpD,IAAA,eAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC5D,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,IAAA,eAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;IACjG,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACnE,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,IAAA,eAAM,EAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IACzG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=throw.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"throw.test.d.ts","sourceRoot":"","sources":["../../src/expect/throw.test.ts"],"names":[],"mappings":""}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const assert_1 = require("../assert");
4
- const expect_1 = require("../expect");
5
- describe('expect/throw', () => {
6
- it(`should throw if the callback doesn't throw`, () => {
7
- (0, assert_1.throws)(() => (0, expect_1.expect)(() => { }).to.throw());
8
- });
9
- it('should not throw if callback throws', () => {
10
- (0, expect_1.expect)(() => {
11
- throw new Error('Things are bad');
12
- }).to.throw();
13
- });
14
- it('should accept arguments', () => {
15
- class CustomError extends Error {
16
- }
17
- const callback = () => {
18
- throw new Error();
19
- };
20
- (0, assert_1.throws)(() => (0, expect_1.expect)(callback).to.throw(CustomError), /Expected function to throw CustomError/);
21
- });
22
- describe('not', () => {
23
- it(`should not throw if callback doesn't throw and it's inverted`, () => {
24
- (0, expect_1.expect)(() => (0, expect_1.expect)(() => { }).not.to.throw()).not.to.throw();
25
- });
26
- it(`should throw if callback throws and it's inverted`, () => {
27
- (0, assert_1.throws)(() => (0, expect_1.expect)(() => {
28
- throw new Error('Things are bad');
29
- }).not.to.throw());
30
- });
31
- });
32
- });
33
- //# sourceMappingURL=throw.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"throw.test.js","sourceRoot":"","sources":["../../src/expect/throw.test.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AACnC,sCAAmC;AAEnC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QAClD,IAAA,eAAM,EAAC,GAAG,EAA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CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=type-shorthand.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-shorthand.test.d.ts","sourceRoot":"","sources":["../../src/expect/type-shorthand.test.ts"],"names":[],"mappings":""}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable mocha/no-setup-in-describe */
4
- /* eslint-disable @typescript-eslint/no-unused-expressions */
5
- const expect_1 = require("../expect");
6
- const types = {
7
- NaN: Number.NaN,
8
- array: [],
9
- bigint: BigInt(5),
10
- boolean: true,
11
- function: () => { },
12
- null: null,
13
- number: 5,
14
- object: {},
15
- string: 'test',
16
- symbol: Symbol(),
17
- undefined: undefined
18
- };
19
- describe('expect/type shorthands', () => {
20
- for (const [method, value] of Object.entries(types)) {
21
- describe(method, () => {
22
- const incorrectValue = method === 'string' ? types.object : types.string;
23
- it(`should not throw if value is a(n) ${method}`, () => {
24
- (0, expect_1.expect)(value).to.be.a[method]();
25
- });
26
- it(`should throw if value is not a(n) ${method}`, () => {
27
- const incorrectType = method === 'string' ? 'object' : 'string';
28
- const validator = new RegExp(`Expected ${incorrectType} to be a\\(n\\) ${method}`);
29
- (0, expect_1.expect)(() => (0, expect_1.expect)(incorrectValue).to.be.a[method]()).to.throw(validator);
30
- });
31
- describe('not', () => {
32
- it(`should not throw if value is not a(n) ${method}`, () => {
33
- (0, expect_1.expect)(incorrectValue).to.not.be.a[method]();
34
- });
35
- it(`should throw if value is a(n) ${method}`, () => {
36
- const validator = new RegExp(`Expected ${method} to not be a\\(n\\) ${method}`);
37
- (0, expect_1.expect)(() => (0, expect_1.expect)(value).to.not.be.a[method]()).to.throw(validator);
38
- });
39
- });
40
- });
41
- }
42
- // Type checks
43
- (0, expect_1.expect)(Number.NaN).to.be.a.NaN;
44
- (0, expect_1.expect)([]).to.be.an.array;
45
- (0, expect_1.expect)(BigInt(5)).to.be.a.bigint;
46
- (0, expect_1.expect)(true).to.be.a.boolean;
47
- (0, expect_1.expect)(() => { }).to.be.a.function;
48
- (0, expect_1.expect)(null).to.be.a.null;
49
- (0, expect_1.expect)(5).to.be.a.number;
50
- (0, expect_1.expect)({}).to.be.an.object;
51
- (0, expect_1.expect)('test').to.be.a.string;
52
- (0, expect_1.expect)(Symbol()).to.be.a.symbol;
53
- (0, expect_1.expect)(void 0).to.be.an.undefined;
54
- });
55
- //# sourceMappingURL=type-shorthand.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type-shorthand.test.js","sourceRoot":"","sources":["../../src/expect/type-shorthand.test.ts"],"names":[],"mappings":";;AAAA,+CAA+C;AAC/C,6DAA6D;AAC7D,sCAAmC;AAGnC,MAAM,KAAK,GAA2B;IAClC,GAAG,EAAE,MAAM,CAAC,GAAG;IACf,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjB,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;IAClB,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM,EAAE;IAChB,SAAS,EAAE,SAAS;CACvB,CAAC;AAEF,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACpC,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACjD,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;YAClB,MAAM,cAAc,GAAG,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;YACzE,EAAE,CAAC,qCAAsC,MAAO,EAAE,EAAE,GAAG,EAAE;gBACrD,IAAA,eAAM,EAAC,KAAK,CAAC,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24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const expect_1 = require("../expect");
4
- describe('expect/type', () => {
5
- it('should not throw for number, number', () => {
6
- (0, expect_1.expect)(1).to.have.type('number');
7
- });
8
- it('should throw for number, string', () => {
9
- (0, expect_1.expect)(() => {
10
- (0, expect_1.expect)(1).to.have.type('string');
11
- }).to.throw(/Expected number to be a\(n\) string/);
12
- });
13
- describe('not', () => {
14
- it('should throw if is of type', () => {
15
- (0, expect_1.expect)(() => {
16
- (0, expect_1.expect)(1).not.to.have.type('number');
17
- }).to.throw(/Expected number to not be a\(n\) number/);
18
- });
19
- it('should not throw if not of type', () => {
20
- (0, expect_1.expect)(1).not.to.have.type('string');
21
- });
22
- });
23
- });
24
- //# sourceMappingURL=type.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.test.js","sourceRoot":"","sources":["../../src/expect/type.test.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AAEnC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;QAC3C,IAAA,eAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACvC,IAAA,eAAM,EAAC,GAAG,EAAE;YACR,IAAA,eAAM,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;QACjB,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;YAClC,IAAA,eAAM,EAAC,GAAG,EAAE;gBACR,IAAA,eAAM,EAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;YACvC,IAAA,eAAM,EAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=expect.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expect.test.d.ts","sourceRoot":"","sources":["../src/expect.test.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const expect_1 = require("./expect");
4
- describe('expect', () => {
5
- describe('size', () => {
6
- it('should not throw if length is above', () => {
7
- (0, expect_1.expect)([1, 2]).length.to.be.above(1);
8
- });
9
- });
10
- it('should work with of', () => {
11
- (0, expect_1.expect)([1, 2]).to.be.of.type('array');
12
- });
13
- describe('and', () => {
14
- it('should clear state', () => {
15
- (0, expect_1.expect)(true).to.not.be.false().and.be.a.boolean();
16
- (0, expect_1.expect)(() => {
17
- (0, expect_1.expect)(5).to.be.not.be.above(10).and.be.a.string();
18
- }).to.throw(/Expected number to be a\(n\) string/);
19
- });
20
- });
21
- });
22
- //# sourceMappingURL=expect.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"expect.test.js","sourceRoot":"","sources":["../src/expect.test.ts"],"names":[],"mappings":";;AAAA,qCAAkC;AAElC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACpB,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QAClB,EAAE,CAAC,qCAAqC,EAAE,GAAG,EAAE;YAC3C,IAAA,eAAM,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC3B,IAAA,eAAM,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;QACjB,EAAE,CAAC,oBAAoB,EAAE,GAAG,EAAE;YAC1B,IAAA,eAAM,EAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAClD,IAAA,eAAM,EAAC,GAAG,EAAE;gBACR,IAAA,eAAM,EAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;YAC5D,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=fail.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fail.test.d.ts","sourceRoot":"","sources":["../../src/utils/fail.test.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const hein_assertion_utils_1 = require("hein-assertion-utils");
4
- const expect_1 = require("../expect");
5
- const fail_1 = require("./fail");
6
- describe('fail', () => {
7
- it('should throw an AssertionError', () => {
8
- (0, expect_1.expect)(() => (0, fail_1.fail)()).to.throw(hein_assertion_utils_1.AssertionError);
9
- (0, expect_1.expect)(() => expect_1.expect.fail()).to.throw(hein_assertion_utils_1.AssertionError);
10
- });
11
- });
12
- //# sourceMappingURL=fail.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fail.test.js","sourceRoot":"","sources":["../../src/utils/fail.test.ts"],"names":[],"mappings":";;AAAA,+DAAsD;AACtD,sCAAmC;AACnC,iCAA8B;AAE9B,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;IAClB,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;QACtC,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,IAAA,WAAI,GAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAc,CAAC,CAAC;QAC9C,IAAA,eAAM,EAAC,GAAG,EAAE,CAAC,eAAM,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAc,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=get-size.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-size.test.d.ts","sourceRoot":"","sources":["../../src/utils/get-size.test.ts"],"names":[],"mappings":""}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const expect_1 = require("../expect");
4
- const get_size_1 = require("./get-size");
5
- describe('getSize', () => {
6
- it('should get the size of an array', () => {
7
- (0, expect_1.expect)((0, get_size_1.getSize)([1, 2, 3])).to.equal(3);
8
- });
9
- it('should get the key-count of an object', () => {
10
- (0, expect_1.expect)((0, get_size_1.getSize)({ a: 1, b: 2 })).to.equal(2);
11
- });
12
- it('should get the size of a Set', () => {
13
- (0, expect_1.expect)((0, get_size_1.getSize)(new Set([1, 2, 3]))).to.equal(3);
14
- });
15
- it('should get the key count of a Map', () => {
16
- (0, expect_1.expect)((0, get_size_1.getSize)(new Map([
17
- ['a', 1],
18
- ['b', 2]
19
- ]))).to.equal(2);
20
- });
21
- it('should get the length of a string', () => {
22
- (0, expect_1.expect)((0, get_size_1.getSize)('abc')).to.equal(3);
23
- });
24
- it('should return 0 for a non-valid value', () => {
25
- (0, expect_1.expect)((0, get_size_1.getSize)(null)).to.equal(0);
26
- });
27
- });
28
- //# sourceMappingURL=get-size.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-size.test.js","sourceRoot":"","sources":["../../src/utils/get-size.test.ts"],"names":[],"mappings":";;AAAA,sCAAmC;AACnC,yCAAqC;AAErC,QAAQ,CAAC,SAAS,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACvC,IAAA,eAAM,EAAC,IAAA,kBAAO,EAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,IAAA,eAAM,EAAC,IAAA,kBAAO,EAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACpC,IAAA,eAAM,EAAC,IAAA,kBAAO,EAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QACzC,IAAA,eAAM,EACF,IAAA,kBAAO,EACH,IAAI,GAAG,CAAC;YACJ,CAAC,GAAG,EAAE,CAAC,CAAC;YACR,CAAC,GAAG,EAAE,CAAC,CAAC;SACX,CAAC,CACL,CACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QACzC,IAAA,eAAM,EAAC,IAAA,kBAAO,EAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,IAAA,eAAM,EAAC,IAAA,kBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=match.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"match.test.d.ts","sourceRoot":"","sources":["../../src/utils/match.test.ts"],"names":[],"mappings":""}
@@ -1,333 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const assert_1 = require("../assert");
4
- const match_1 = require("./match");
5
- describe('utils/match', () => {
6
- describe('number', () => {
7
- it('should return true if numbers are equal', () => {
8
- (0, assert_1.equal)((0, match_1.match)(1, 1), true);
9
- });
10
- it('should return false if numbers are not equal', () => {
11
- (0, assert_1.equal)((0, match_1.match)(1, 2), false);
12
- });
13
- it('should return true if both values are NaN', () => {
14
- (0, assert_1.equal)((0, match_1.match)(Number.NaN, Number.NaN), true);
15
- });
16
- it('should return false if one value is NaN', () => {
17
- (0, assert_1.equal)((0, match_1.match)(Number.NaN, 1), false);
18
- });
19
- });
20
- describe('string', () => {
21
- it('should return true if strings are equal', () => {
22
- (0, assert_1.equal)((0, match_1.match)('a', 'a'), true);
23
- });
24
- it('should return false if strings are not equal', () => {
25
- (0, assert_1.equal)((0, match_1.match)('a', ''), false);
26
- });
27
- });
28
- describe('boolean', () => {
29
- it('should return true if booleans are equal', () => {
30
- (0, assert_1.equal)((0, match_1.match)(true, true), true);
31
- });
32
- it('should return false if booleans are not equal', () => {
33
- (0, assert_1.equal)((0, match_1.match)(true, false), false);
34
- });
35
- });
36
- describe('null', () => {
37
- it('should return true if both values are null', () => {
38
- (0, assert_1.equal)((0, match_1.match)(null, null), true);
39
- });
40
- it('should return false if one value is undefined', () => {
41
- (0, assert_1.equal)((0, match_1.match)(undefined, null), false);
42
- });
43
- });
44
- describe('undefined', () => {
45
- it('should return true if both values are undefined', () => {
46
- // eslint-disable-next-line unicorn/no-useless-undefined
47
- (0, assert_1.equal)((0, match_1.match)(undefined, undefined), true);
48
- });
49
- it('should return false if one value is undefined', () => {
50
- (0, assert_1.equal)((0, match_1.match)(undefined, null), false);
51
- });
52
- });
53
- describe('Map', () => {
54
- it('should return true if maps are equal', () => {
55
- const key = {};
56
- (0, assert_1.equal)((0, match_1.match)(new Map([[key, 1]]), new Map([[key, 1]])), true);
57
- });
58
- it('should return false if maps are not equal', () => {
59
- (0, assert_1.equal)((0, match_1.match)(new Map([['a', 1]]), new Map([['a', 2]])), false);
60
- });
61
- it('should return false if one map is empty', () => {
62
- (0, assert_1.equal)((0, match_1.match)(new Map(), new Map([['a', 1]])), false);
63
- (0, assert_1.equal)((0, match_1.match)(new Map([['a', 1]]), new Map()), false);
64
- });
65
- it('should return false if keys are different objects', () => {
66
- (0, assert_1.equal)((0, match_1.match)(new Map([[{}, 1]]), new Map([[{}, 2]])), false);
67
- });
68
- it(`should return false if one value matches and the other doesn't`, () => {
69
- const key1 = {};
70
- const key2 = {};
71
- const map = new Map([
72
- [key1, 1],
73
- [key2, 2]
74
- ]);
75
- const map2 = new Map([
76
- [key1, 1],
77
- [key2, 3]
78
- ]);
79
- (0, assert_1.equal)((0, match_1.match)(map, map2), false);
80
- });
81
- });
82
- describe('WeakMap', () => {
83
- it('should return true if both values are the same instance', () => {
84
- const map = new WeakMap();
85
- (0, assert_1.equal)((0, match_1.match)(map, map), true);
86
- });
87
- it('should return false if both values are different instances', () => {
88
- const map = new WeakMap();
89
- const map2 = new WeakMap();
90
- (0, assert_1.equal)((0, match_1.match)(map, map2), false);
91
- });
92
- it('should return false if one value is a WeakMap and the other a plain object', () => {
93
- const map = new WeakMap();
94
- (0, assert_1.equal)((0, match_1.match)(map, {}), false);
95
- (0, assert_1.equal)((0, match_1.match)({}, map), false);
96
- });
97
- });
98
- describe('Set', () => {
99
- it('should return true if both sets are empty', () => {
100
- (0, assert_1.equal)((0, match_1.match)(new Set(), new Set()), true);
101
- });
102
- it('should return false if one set is empty', () => {
103
- (0, assert_1.equal)((0, match_1.match)(new Set(), new Set([1])), false);
104
- (0, assert_1.equal)((0, match_1.match)(new Set([1]), new Set()), false);
105
- });
106
- it('should return true if sets are equal', () => {
107
- (0, assert_1.equal)((0, match_1.match)(new Set([1]), new Set([1])), true);
108
- });
109
- });
110
- describe('WeakSet', () => {
111
- it('should return true if both values are the same instance', () => {
112
- const set = new WeakSet();
113
- (0, assert_1.equal)((0, match_1.match)(set, set), true);
114
- });
115
- it('should return false if both values are different instances', () => {
116
- const set = new WeakSet();
117
- const set2 = new WeakSet();
118
- (0, assert_1.equal)((0, match_1.match)(set, set2), false);
119
- });
120
- });
121
- describe('array', () => {
122
- it('should return false if one value is an array and the other a plain object', () => {
123
- (0, assert_1.equal)((0, match_1.match)([], {}), false);
124
- (0, assert_1.equal)((0, match_1.match)({}, []), false);
125
- });
126
- it('should return false if values have different amounts of memmbers', () => {
127
- (0, assert_1.equal)((0, match_1.match)([1, 2], [1, 2, 3]), false);
128
- (0, assert_1.equal)((0, match_1.match)([1, 2, 3], [1, 2]), false);
129
- });
130
- it('should return true if both arrays have the same values', () => {
131
- (0, assert_1.equal)((0, match_1.match)([1, 2, 3], [1, 2, 3]), true);
132
- });
133
- });
134
- describe('Date', () => {
135
- it('should return true if both values are the same instance', () => {
136
- const date = new Date();
137
- (0, assert_1.equal)((0, match_1.match)(date, date), true);
138
- });
139
- it('should return true if both values refer to the same time', () => {
140
- (0, assert_1.equal)((0, match_1.match)(new Date(0), new Date(0)), true);
141
- });
142
- it('should return false if one value is a Date and the other a plain object', () => {
143
- (0, assert_1.equal)((0, match_1.match)(new Date(), {}), false);
144
- (0, assert_1.equal)((0, match_1.match)({}, new Date()), false);
145
- });
146
- it('should return true if one value is a Date and the other a representation of that date', () => {
147
- (0, assert_1.equal)((0, match_1.match)(new Date(0), new Date(0).getMilliseconds()), true);
148
- });
149
- });
150
- describe('object', () => {
151
- it(`should return false if one object is empty and the other isn't`, () => {
152
- (0, assert_1.equal)((0, match_1.match)({}, { a: 1 }), false);
153
- (0, assert_1.equal)((0, match_1.match)({ a: 1 }, {}), false);
154
- });
155
- it('should return true if both values are the same instance', () => {
156
- const object = {};
157
- (0, assert_1.equal)((0, match_1.match)(object, object), true);
158
- });
159
- it('should return true if both have same keys and values', () => {
160
- (0, assert_1.equal)((0, match_1.match)({ a: 1 }, { a: 1 }), true);
161
- });
162
- it('should return false if values for the same key are different', () => {
163
- (0, assert_1.equal)((0, match_1.match)({ a: 1 }, { a: 2 }), false);
164
- });
165
- it('should return false if one value is an object and the other a number', () => {
166
- (0, assert_1.equal)((0, match_1.match)({}, 1), false);
167
- (0, assert_1.equal)((0, match_1.match)(1, {}), false);
168
- });
169
- });
170
- describe('function', () => {
171
- it('should return true if both functions are the same instance', () => {
172
- const callback = () => { };
173
- (0, assert_1.equal)((0, match_1.match)(callback, callback), true);
174
- });
175
- it('should return false if functions are different', () => {
176
- (0, assert_1.equal)((0, match_1.match)(() => 5, () => 4), false);
177
- });
178
- });
179
- describe('any', () => {
180
- it('should return true if one value is a primitive and the other any', () => {
181
- (0, assert_1.equal)((0, match_1.match)(5, match_1.any), true);
182
- });
183
- it('should mutate expectation if a value is any and mutate is true', () => {
184
- const expect = { a: match_1.any };
185
- (0, assert_1.equal)((0, match_1.match)({ a: 5 }, expect, { mutate: true }), true);
186
- (0, assert_1.equal)(expect.a, 5);
187
- });
188
- it('should not mutate if mutate is set to false', () => {
189
- const anyInstance = match_1.any;
190
- const expect = { a: anyInstance };
191
- (0, assert_1.equal)((0, match_1.match)({ a: 5 }, expect), true);
192
- (0, assert_1.equal)(expect.a, anyInstance);
193
- });
194
- it('should mutate array elements', () => {
195
- const expectation = [match_1.any];
196
- (0, assert_1.equal)((0, match_1.match)([5], expectation, { mutate: true }), true);
197
- (0, assert_1.equal)(expectation[0], 5);
198
- });
199
- it('should mutate map values', () => {
200
- const key = {};
201
- const expectation = new Map([[key, match_1.any]]);
202
- (0, assert_1.equal)((0, match_1.match)(new Map([[key, 5]]), expectation, { mutate: true }), true);
203
- (0, assert_1.equal)(expectation.get(key), 5);
204
- });
205
- it('should traverse the whole object even if something is not a match', () => {
206
- const expected = {
207
- a: [1, match_1.any],
208
- b: [2, match_1.any]
209
- };
210
- const actual = {
211
- a: [3, 5],
212
- b: [4, 6]
213
- };
214
- (0, match_1.match)(actual, expected, { mutate: true });
215
- (0, assert_1.equal)(expected.a[1], 5);
216
- (0, assert_1.equal)(expected.b[1], 6);
217
- });
218
- it(`should mutate the whole array even if arrays aren't equal length`, () => {
219
- const expected = [match_1.any, match_1.any];
220
- const actual = [1, 2, 3];
221
- (0, match_1.match)(actual, expected, { mutate: true });
222
- (0, assert_1.equal)(expected[0], 1);
223
- (0, assert_1.equal)(expected[1], 2);
224
- (0, assert_1.hasSize)(expected, 2);
225
- });
226
- it(`should mutate the whole object even if objects have different amount of keys`, () => {
227
- const expected = {
228
- a: match_1.any,
229
- b: match_1.any
230
- };
231
- const actual = {
232
- a: 1,
233
- b: 2,
234
- c: 3
235
- };
236
- (0, match_1.match)(actual, expected, { mutate: true });
237
- (0, assert_1.equal)(expected.a, 1);
238
- (0, assert_1.equal)(expected.b, 2);
239
- (0, assert_1.hasSize)(expected, 2);
240
- });
241
- it('should mutate the whole Map even if Maps have different amount of keys', () => {
242
- const key = {};
243
- const key2 = {};
244
- const expected = new Map([[key, match_1.any]]);
245
- const actual = new Map([
246
- [key, 2],
247
- [key2, 4]
248
- ]);
249
- (0, match_1.match)(actual, expected, { mutate: true });
250
- (0, assert_1.equal)(expected.get(key), 2);
251
- (0, assert_1.hasSize)(expected, 1);
252
- });
253
- it('should traverse the whole Map even if something is not a match', () => {
254
- const key1 = {};
255
- const key2 = {};
256
- const expected = new Map([
257
- [key1, [1, match_1.any]],
258
- [key2, [2, match_1.any]]
259
- ]);
260
- const actual = new Map([
261
- [key1, [3, 5]],
262
- [key2, [4, 6]]
263
- ]);
264
- (0, match_1.match)(actual, expected, { mutate: true });
265
- (0, assert_1.equal)(expected.get(key1)[1], 5);
266
- (0, assert_1.equal)(expected.get(key2)[1], 6);
267
- });
268
- });
269
- describe('partial', () => {
270
- it('should match partial objects', () => {
271
- (0, assert_1.equal)((0, match_1.match)({ a: 1, b: 2 }, { a: 1 }, { partial: true }), true);
272
- });
273
- it('should match partial arrays', () => {
274
- (0, assert_1.equal)((0, match_1.match)([1, 2], [1], { partial: true }), true);
275
- });
276
- it('should match partial Maps', () => {
277
- const object = [{}, {}];
278
- const map1 = new Map([
279
- [object[0], 1],
280
- [object[1], 2]
281
- ]);
282
- const map2 = new Map([[object[0], 1]]);
283
- (0, assert_1.equal)((0, match_1.match)(map1, map2, { partial: true }), true);
284
- });
285
- it('should return false for partial Maps if expected has more keys', () => {
286
- const key1 = {};
287
- const key2 = {};
288
- const map = new Map([[key1, 1]]);
289
- const map2 = new Map([
290
- [key1, 1],
291
- [key2, 3]
292
- ]);
293
- (0, assert_1.equal)((0, match_1.match)(map, map2, { partial: true }), false);
294
- });
295
- it('should match partial Sets', () => {
296
- const set1 = new Set([1, 2]);
297
- const set2 = new Set([1]);
298
- (0, assert_1.equal)((0, match_1.match)(set1, set2, { partial: true }), true);
299
- });
300
- });
301
- describe('evaluation', () => {
302
- // eslint-disable-next-line mocha/no-setup-in-describe
303
- const trueEvaluation = (0, match_1.createEvaluation)(() => true);
304
- // eslint-disable-next-line mocha/no-setup-in-describe
305
- const falseEvaluation = (0, match_1.createEvaluation)(() => false);
306
- it('should evaluate evaluation', () => {
307
- (0, assert_1.equal)((0, match_1.match)(1, trueEvaluation), true);
308
- (0, assert_1.equal)((0, match_1.match)(1, falseEvaluation), false);
309
- });
310
- it('should test properties', () => {
311
- (0, assert_1.equal)((0, match_1.match)({ a: 1 }, { a: trueEvaluation }), true);
312
- (0, assert_1.equal)((0, match_1.match)({ a: 1 }, { a: falseEvaluation }), false);
313
- });
314
- it('should mutate expected properties', () => {
315
- const expect = { a: trueEvaluation };
316
- (0, assert_1.equal)((0, match_1.match)({ a: 1 }, expect, { mutate: true }), true);
317
- (0, assert_1.equal)(expect.a, 1);
318
- });
319
- it('should mutate arrays', () => {
320
- const expect = [trueEvaluation];
321
- (0, assert_1.equal)((0, match_1.match)([1], expect, { mutate: true }), true);
322
- (0, assert_1.equal)(expect[0], 1);
323
- });
324
- it('should mutate Maps', () => {
325
- const key = {};
326
- const actual = new Map([[key, 1]]);
327
- const expect = new Map([[key, trueEvaluation]]);
328
- (0, assert_1.equal)((0, match_1.match)(actual, expect, { mutate: true }), true);
329
- (0, assert_1.equal)(expect.get(key), 1);
330
- });
331
- });
332
- });
333
- //# sourceMappingURL=match.test.js.map