hein 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/.eslintrc +167 -0
  2. package/.mocharc.json +4 -0
  3. package/.nycrc +16 -0
  4. package/DIFFERENCES_WITH_CHAI.md +49 -0
  5. package/LICENSE +21 -0
  6. package/README.md +293 -0
  7. package/dist/assert/eql.d.ts +2 -0
  8. package/dist/assert/eql.d.ts.map +1 -0
  9. package/dist/assert/eql.js +24 -0
  10. package/dist/assert/eql.js.map +1 -0
  11. package/dist/assert/equal.d.ts +9 -0
  12. package/dist/assert/equal.d.ts.map +1 -0
  13. package/dist/assert/equal.js +21 -0
  14. package/dist/assert/equal.js.map +1 -0
  15. package/dist/assert/greater-than-equal.d.ts +9 -0
  16. package/dist/assert/greater-than-equal.d.ts.map +1 -0
  17. package/dist/assert/greater-than-equal.js +20 -0
  18. package/dist/assert/greater-than-equal.js.map +1 -0
  19. package/dist/assert/greater-than.d.ts +9 -0
  20. package/dist/assert/greater-than.d.ts.map +1 -0
  21. package/dist/assert/greater-than.js +20 -0
  22. package/dist/assert/greater-than.js.map +1 -0
  23. package/dist/assert/has-size.d.ts +2 -0
  24. package/dist/assert/has-size.d.ts.map +1 -0
  25. package/dist/assert/has-size.js +53 -0
  26. package/dist/assert/has-size.js.map +1 -0
  27. package/dist/assert/instance-of.d.ts +11 -0
  28. package/dist/assert/instance-of.d.ts.map +1 -0
  29. package/dist/assert/instance-of.js +23 -0
  30. package/dist/assert/instance-of.js.map +1 -0
  31. package/dist/assert/is-empty.d.ts +2 -0
  32. package/dist/assert/is-empty.d.ts.map +1 -0
  33. package/dist/assert/is-empty.js +45 -0
  34. package/dist/assert/is-empty.js.map +1 -0
  35. package/dist/assert/is-type.d.ts +3 -0
  36. package/dist/assert/is-type.d.ts.map +1 -0
  37. package/dist/assert/is-type.js +20 -0
  38. package/dist/assert/is-type.js.map +1 -0
  39. package/dist/assert/less-than-equal.d.ts +9 -0
  40. package/dist/assert/less-than-equal.d.ts.map +1 -0
  41. package/dist/assert/less-than-equal.js +20 -0
  42. package/dist/assert/less-than-equal.js.map +1 -0
  43. package/dist/assert/less-than.d.ts +9 -0
  44. package/dist/assert/less-than.d.ts.map +1 -0
  45. package/dist/assert/less-than.js +20 -0
  46. package/dist/assert/less-than.js.map +1 -0
  47. package/dist/assert/rejects.d.ts +2 -0
  48. package/dist/assert/rejects.d.ts.map +1 -0
  49. package/dist/assert/rejects.js +34 -0
  50. package/dist/assert/rejects.js.map +1 -0
  51. package/dist/assert/throws.d.ts +9 -0
  52. package/dist/assert/throws.d.ts.map +1 -0
  53. package/dist/assert/throws.js +35 -0
  54. package/dist/assert/throws.js.map +1 -0
  55. package/dist/assert.d.ts +14 -0
  56. package/dist/assert.d.ts.map +1 -0
  57. package/dist/assert.js +44 -0
  58. package/dist/assert.js.map +1 -0
  59. package/dist/expect/empty.d.ts +10 -0
  60. package/dist/expect/empty.d.ts.map +1 -0
  61. package/dist/expect/empty.js +18 -0
  62. package/dist/expect/empty.js.map +1 -0
  63. package/dist/expect/eql.d.ts +10 -0
  64. package/dist/expect/eql.d.ts.map +1 -0
  65. package/dist/expect/eql.js +18 -0
  66. package/dist/expect/eql.js.map +1 -0
  67. package/dist/expect/equal-shorthand.d.ts +14 -0
  68. package/dist/expect/equal-shorthand.d.ts.map +1 -0
  69. package/dist/expect/equal-shorthand.js +31 -0
  70. package/dist/expect/equal-shorthand.js.map +1 -0
  71. package/dist/expect/equal.d.ts +14 -0
  72. package/dist/expect/equal.d.ts.map +1 -0
  73. package/dist/expect/equal.js +19 -0
  74. package/dist/expect/equal.js.map +1 -0
  75. package/dist/expect/greater-than-equal.d.ts +32 -0
  76. package/dist/expect/greater-than-equal.d.ts.map +1 -0
  77. package/dist/expect/greater-than-equal.js +20 -0
  78. package/dist/expect/greater-than-equal.js.map +1 -0
  79. package/dist/expect/greater-than.d.ts +32 -0
  80. package/dist/expect/greater-than.d.ts.map +1 -0
  81. package/dist/expect/greater-than.js +20 -0
  82. package/dist/expect/greater-than.js.map +1 -0
  83. package/dist/expect/instance-of-shorthand.d.ts +28 -0
  84. package/dist/expect/instance-of-shorthand.d.ts.map +1 -0
  85. package/dist/expect/instance-of-shorthand.js +25 -0
  86. package/dist/expect/instance-of-shorthand.js.map +1 -0
  87. package/dist/expect/instance-of.d.ts +2 -0
  88. package/dist/expect/instance-of.d.ts.map +1 -0
  89. package/dist/expect/instance-of.js +18 -0
  90. package/dist/expect/instance-of.js.map +1 -0
  91. package/dist/expect/length.d.ts +22 -0
  92. package/dist/expect/length.d.ts.map +1 -0
  93. package/dist/expect/length.js +19 -0
  94. package/dist/expect/length.js.map +1 -0
  95. package/dist/expect/less-than-equal.d.ts +32 -0
  96. package/dist/expect/less-than-equal.d.ts.map +1 -0
  97. package/dist/expect/less-than-equal.js +20 -0
  98. package/dist/expect/less-than-equal.js.map +1 -0
  99. package/dist/expect/less-than.d.ts +32 -0
  100. package/dist/expect/less-than.d.ts.map +1 -0
  101. package/dist/expect/less-than.js +20 -0
  102. package/dist/expect/less-than.js.map +1 -0
  103. package/dist/expect/reject.d.ts +8 -0
  104. package/dist/expect/reject.d.ts.map +1 -0
  105. package/dist/expect/reject.js +13 -0
  106. package/dist/expect/reject.js.map +1 -0
  107. package/dist/expect/throw.d.ts +8 -0
  108. package/dist/expect/throw.d.ts.map +1 -0
  109. package/dist/expect/throw.js +13 -0
  110. package/dist/expect/throw.js.map +1 -0
  111. package/dist/expect/type-shorthand.d.ts +66 -0
  112. package/dist/expect/type-shorthand.d.ts.map +1 -0
  113. package/dist/expect/type-shorthand.js +31 -0
  114. package/dist/expect/type-shorthand.js.map +1 -0
  115. package/dist/expect/type.d.ts +10 -0
  116. package/dist/expect/type.d.ts.map +1 -0
  117. package/dist/expect/type.js +18 -0
  118. package/dist/expect/type.js.map +1 -0
  119. package/dist/expect.d.ts +18 -0
  120. package/dist/expect.d.ts.map +1 -0
  121. package/dist/expect.js +62 -0
  122. package/dist/expect.js.map +1 -0
  123. package/dist/expect.types.d.ts +55 -0
  124. package/dist/expect.types.d.ts.map +1 -0
  125. package/dist/expect.types.js +4 -0
  126. package/dist/expect.types.js.map +1 -0
  127. package/dist/index.d.ts +3 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +20 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/mixins.d.ts +22 -0
  132. package/dist/mixins.d.ts.map +1 -0
  133. package/dist/mixins.js +9 -0
  134. package/dist/mixins.js.map +1 -0
  135. package/dist/utils/assertion.d.ts +25 -0
  136. package/dist/utils/assertion.d.ts.map +1 -0
  137. package/dist/utils/assertion.js +45 -0
  138. package/dist/utils/assertion.js.map +1 -0
  139. package/dist/utils/chain.d.ts +3 -0
  140. package/dist/utils/chain.d.ts.map +1 -0
  141. package/dist/utils/chain.js +21 -0
  142. package/dist/utils/chain.js.map +1 -0
  143. package/dist/utils/get-size.d.ts +2 -0
  144. package/dist/utils/get-size.d.ts.map +1 -0
  145. package/dist/utils/get-size.js +24 -0
  146. package/dist/utils/get-size.js.map +1 -0
  147. package/dist/utils/get-type.d.ts +3 -0
  148. package/dist/utils/get-type.d.ts.map +1 -0
  149. package/dist/utils/get-type.js +17 -0
  150. package/dist/utils/get-type.js.map +1 -0
  151. package/dist/utils/match.d.ts +15 -0
  152. package/dist/utils/match.d.ts.map +1 -0
  153. package/dist/utils/match.js +164 -0
  154. package/dist/utils/match.js.map +1 -0
  155. package/dist/utils/process-error.d.ts +11 -0
  156. package/dist/utils/process-error.d.ts.map +1 -0
  157. package/dist/utils/process-error.js +44 -0
  158. package/dist/utils/process-error.js.map +1 -0
  159. package/dist/utils/stringify.d.ts +2 -0
  160. package/dist/utils/stringify.d.ts.map +1 -0
  161. package/dist/utils/stringify.js +18 -0
  162. package/dist/utils/stringify.js.map +1 -0
  163. package/dist/utils/validate-numeric-and-dates.d.ts +2 -0
  164. package/dist/utils/validate-numeric-and-dates.d.ts.map +1 -0
  165. package/dist/utils/validate-numeric-and-dates.js +15 -0
  166. package/dist/utils/validate-numeric-and-dates.js.map +1 -0
  167. package/dist/utils/xor.d.ts +2 -0
  168. package/dist/utils/xor.d.ts.map +1 -0
  169. package/dist/utils/xor.js +8 -0
  170. package/dist/utils/xor.js.map +1 -0
  171. package/package.json +55 -0
  172. package/tsconfig.json +19 -0
package/.eslintrc ADDED
@@ -0,0 +1,167 @@
1
+ {
2
+ "parser": "@typescript-eslint/parser",
3
+ "extends": [
4
+ "airbnb-typescript/base",
5
+ "plugin:@typescript-eslint/eslint-recommended",
6
+ "plugin:@typescript-eslint/recommended",
7
+ "plugin:mocha/recommended",
8
+ "plugin:unicorn/recommended"
9
+ ],
10
+ "plugins": [
11
+ "import",
12
+ "mocha",
13
+ "unicorn"
14
+ ],
15
+ "parserOptions": {
16
+ "ecmaVersion": 2018,
17
+ "sourceType": "module",
18
+ "project": "./tsconfig.json"
19
+ },
20
+ "rules": {
21
+ "no-multi-spaces": "error",
22
+ "spaced-comment": [
23
+ "error",
24
+ "always",
25
+ {
26
+ "markers": [
27
+ "/"
28
+ ]
29
+ }
30
+ ],
31
+ "template-curly-spacing": [
32
+ "error",
33
+ "always"
34
+ ],
35
+ "no-irregular-whitespace": [
36
+ "error",
37
+ {
38
+ "skipStrings": false
39
+ }
40
+ ],
41
+ "no-trailing-spaces": "error",
42
+ "eol-last": "error",
43
+ "@typescript-eslint/indent": [
44
+ "error",
45
+ 4,
46
+ {
47
+ "ignoredNodes": [
48
+ "TSUnionType",
49
+ "TSTypeLiteral"
50
+ ],
51
+ "SwitchCase": 1
52
+ }
53
+ ],
54
+ "@typescript-eslint/comma-dangle": "off",
55
+ "@typescript-eslint/no-use-before-define": [
56
+ "error",
57
+ {
58
+ "variables": false
59
+ }
60
+ ],
61
+ "@typescript-eslint/no-explicit-any": "off",
62
+ "@typescript-eslint/space-before-function-paren": [
63
+ "error",
64
+ {
65
+ "named": "never"
66
+ }
67
+ ],
68
+ "@typescript-eslint/space-before-blocks": "error",
69
+ "@typescript-eslint/type-annotation-spacing": "error",
70
+ "arrow-spacing": "error",
71
+ "@typescript-eslint/quotes": [
72
+ "error",
73
+ "single",
74
+ {
75
+ "avoidEscape": true,
76
+ "allowTemplateLiterals": true
77
+ }
78
+ ],
79
+ "@typescript-eslint/no-floating-promises": "error",
80
+ "mocha/no-mocha-arrows": "off",
81
+ "unicorn/no-null": "off",
82
+ "unicorn/prevent-abbreviations": [
83
+ "error",
84
+ {
85
+ "replacements": {
86
+ "args": false
87
+ }
88
+ }
89
+ ],
90
+ "unicorn/consistent-function-scoping": "off",
91
+ "unicorn/empty-brace-spaces": "off",
92
+ "unicorn/error-message": "off",
93
+ "@typescript-eslint/no-extra-parens": "error",
94
+ "@typescript-eslint/no-extra-semi": "error",
95
+ "@typescript-eslint/naming-convention": [
96
+ "error",
97
+ {
98
+ "selector": "variable",
99
+ "format": [
100
+ "camelCase",
101
+ "PascalCase"
102
+ ]
103
+ },
104
+ {
105
+ "selector": "function",
106
+ "format": [
107
+ "camelCase",
108
+ "PascalCase"
109
+ ]
110
+ },
111
+ {
112
+ "selector": "typeLike",
113
+ "format": [
114
+ "PascalCase"
115
+ ]
116
+ },
117
+ {
118
+ "selector": "variable",
119
+ "format": [
120
+ "camelCase",
121
+ "PascalCase",
122
+ "UPPER_CASE",
123
+ "snake_case"
124
+ ],
125
+ "modifiers": [
126
+ "destructured"
127
+ ]
128
+ },
129
+ {
130
+ "selector": "variable",
131
+ "format": [
132
+ "camelCase",
133
+ "PascalCase",
134
+ "UPPER_CASE"
135
+ ],
136
+ "modifiers": [
137
+ "const"
138
+ ]
139
+ },
140
+ {
141
+ "selector": "typeParameter",
142
+ "format": [
143
+ "UPPER_CASE"
144
+ ]
145
+ }
146
+ ],
147
+ "curly": [
148
+ "error",
149
+ "all"
150
+ ],
151
+ "@typescript-eslint/semi": "error",
152
+ "comma-dangle": [
153
+ "error",
154
+ "never"
155
+ ]
156
+ },
157
+ "overrides": [
158
+ {
159
+ "files": [
160
+ "./src/test/**/*.ts"
161
+ ],
162
+ "rules": {
163
+ "import/no-extraneous-dependencies": "off"
164
+ }
165
+ }
166
+ ]
167
+ }
package/.mocharc.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "require": "ts-node/register/transpile-only",
3
+ "extension": ["ts"]
4
+ }
package/.nycrc ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "extension": [
3
+ ".ts"
4
+ ],
5
+ "require": [
6
+ "ts-node/register/transpile-only"
7
+ ],
8
+ "reporter": [
9
+ "lcov",
10
+ "text",
11
+ "text-summary",
12
+ "html"
13
+ ],
14
+ "sourceMap": true,
15
+ "instrument": true
16
+ }
@@ -0,0 +1,49 @@
1
+ # Differences with Chai
2
+
3
+ ## TypeScript
4
+
5
+ While Chai does have typescript definitions from DefinitelyTyped, the types it provides are a lot looser than I would like.
6
+
7
+ ### Value typechecking
8
+
9
+ For example, the following is not a typescript violation and the properties of the expectation object are not auto-completed:
10
+
11
+ ```typescript
12
+ // Chai:
13
+ expect({ a: 1 }).to.eql({ b: 1 }); // No typescript error
14
+
15
+ // Hein:
16
+ expect({ a: 1 }).to.eql({ b: 1 });
17
+ /*
18
+ Argument of type '{ b: number; }' is not assignable to parameter of type '{ a: number; }'.
19
+ Object literal may only specify known properties, and 'b' does not exist in type '{ a: number; }'.ts(2345)
20
+ */
21
+ expect<any>({ a: 1 }).to.eql({ b: 1 }); // OK in case you really want to do this
22
+ ```
23
+
24
+ ### Method typechecking
25
+
26
+ ```typescript
27
+ // Chai:
28
+ expect('test').to.be.above(5); // No typescript error
29
+
30
+ // Hein:
31
+ expect('test').to.be.above(5);
32
+ /*
33
+ Property 'above' does not exist on type 'StringExpect<string>'.ts(2339)
34
+ */
35
+ ```
36
+
37
+ ## Always call methods, getters are not assertions
38
+
39
+ With chai there are special properties that act as assertions. In Hein you have to call the method to assert.
40
+
41
+ ```typescript
42
+ // Chai:
43
+ expect(true).to.be.true;
44
+
45
+ // Hein:
46
+ expect(true).to.be.true();
47
+ ```
48
+
49
+ I recommend using [no-unused-expressions eslint rule](https://typescript-eslint.io/rules/no-unused-expressions/) to avoid this.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Kristjan Tammekivi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,293 @@
1
+ # Hein
2
+
3
+ Assertion library with focus on TypeScript
4
+
5
+ ## Features?
6
+
7
+ * Full TypeScript support
8
+ * Fuzzy matching for eql with any()
9
+
10
+ * [Differences between Chai and Hein](DIFFERENCES_WITH_CHAI.md)
11
+
12
+ ## Usage
13
+
14
+ ### Assert
15
+ ```typescript
16
+ import { assert } from 'hein';
17
+ import {equal} from 'hein/assert';
18
+
19
+ equal(1, 1);
20
+ assert.equal(1, 1);
21
+ ```
22
+
23
+ ### Expect
24
+ ```typescript
25
+ import { expect } from 'hein';
26
+ expect(1).to.equal(1);
27
+ ```
28
+
29
+ #### Chainable properties
30
+
31
+ * a
32
+ * an
33
+ * and - used to chain multiple assertions, clears the state (so .not will be reset)
34
+ * be
35
+ * have
36
+ * not - inverts the expectation (ie `expect(5).to.not.equal(5)` will throw)
37
+ * to
38
+
39
+ #### Assertions
40
+
41
+ ##### above
42
+
43
+ Alias for [greaterThan](#greaterThan)
44
+
45
+ ##### array
46
+
47
+ Assert that value is an array
48
+
49
+ ```typescript
50
+ expect([]).to.be.an.array();
51
+ ```
52
+
53
+ ##### atLeast
54
+
55
+ Alias for [greaterThanOrEqual](#greaterThanOrEqual)
56
+
57
+ ##### atMost
58
+
59
+ Alias for [lessThanOrEqual](#lessThanOrEqual)
60
+
61
+ ##### below
62
+
63
+ Alias for [lessThan](#lessThan)
64
+
65
+ ##### bigint
66
+
67
+ Assert that value is a BigInt
68
+
69
+ ```typescript
70
+ expect(BigInt(5)).to.be.a.bigint();
71
+ ```
72
+
73
+ ##### boolean
74
+
75
+ Assert that value is a boolean
76
+
77
+ ```typescript
78
+ expect(true).to.be.a.boolean();
79
+ ```
80
+
81
+ ##### Date
82
+
83
+ Assert that value is an instance of Date
84
+
85
+ ```typescript
86
+ expect(new Date).to.be.a.date();
87
+ ```
88
+
89
+ ##### empty
90
+
91
+ Assert that array / object / Map / Set is empty
92
+ ```typescript
93
+ expect([]).to.be.empty();
94
+ expect({}).to.be.empty();
95
+ expect(new Map()).to.be.empty();
96
+ expect(new Set()).to.be.empty();
97
+ ```
98
+
99
+ ##### eql
100
+
101
+ Assert that value deep equals the expectation
102
+ ```typescript
103
+ expect({ a: 1 }).to.eql({ a: 1 });
104
+ ```
105
+
106
+ ##### eq
107
+
108
+ Alias for [equal](#equal)
109
+
110
+ ##### equal
111
+
112
+ Assert that value strictly equals expectation. NaN is treated as a non-unique value
113
+ ```typescript
114
+ expect('hein').to.equal('hein');
115
+ expect(NaN).to.equal(NaN);
116
+ ```
117
+
118
+ ##### false
119
+
120
+ Assert that value is false
121
+ ```typescript
122
+ expect(false).to.be.false();
123
+ ```
124
+
125
+ ##### function
126
+
127
+ Assert that value is a function
128
+ ```typescript
129
+ expect(() => {}).to.be.a.function();
130
+ ```
131
+
132
+ ##### greaterThan
133
+
134
+ Assert that value is greater than expectation
135
+ ```typescript
136
+ expect(5).to.be.greaterThan(4);
137
+ ```
138
+
139
+ ##### gt
140
+
141
+ Alias for [greaterThan](#greaterThan)
142
+
143
+ ##### greaterThanOrEqual
144
+
145
+ Assert that value is greater than or equal to argument
146
+ ```typescript
147
+ expect(5).to.be.greaterThanOrEqual(5);
148
+ expect(5).to.be.greaterThanOrEqual(4);
149
+ ```
150
+
151
+ ##### gte
152
+
153
+ Alias for [greaterThanOrEqual](#greaterThanOrEqual)
154
+
155
+ ##### instanceOf
156
+
157
+ Assert that value is an instance of provided constructor
158
+ ```typescript
159
+ expect(new Error()).to.be.an.instanceOf(Error);
160
+ ```
161
+
162
+ ##### lengthOf
163
+
164
+ Assert that value has a length equal to argument
165
+ ```typescript
166
+ expect([1]).to.have.a.lengthOf(1);
167
+ expect({ a: 1 }).to.have.a.lengthOf(1);
168
+ expect(new Map([['a', 1]])).to.have.a.lengthOf(1);
169
+ expect(new Set([1])).to.have.a.lengthOf(1);
170
+ expect('hein').to.have.a.lengthOf(4);
171
+ ```
172
+
173
+ ##### lessThan
174
+
175
+ Assert that value is less than expectation
176
+ ```typescript
177
+ expect(5).to.be.lessThan(6);
178
+ ```
179
+ ##### lt
180
+
181
+ Alias for [lessThan](#lessThan)
182
+
183
+ ##### lessThanOrEqual
184
+
185
+ Assert that value is less than or equal to expectation
186
+ ```typescript
187
+ expect(5).to.be.lessThanOrEqual(5);
188
+ expect(4).to.be.lessThanOrEqual(5);
189
+ ```
190
+
191
+ ##### lte
192
+
193
+ Alias for [lessThanOrEqual](#lessThanOrEqual)
194
+
195
+ ##### Map
196
+
197
+ Assert that value is an instance of Map
198
+ ```typescript
199
+ expect(new Map()).to.be.a.Map();
200
+ ```
201
+
202
+ ##### NaN
203
+
204
+ Assert that value is NaN
205
+ ```typescript
206
+ expect(NaN).to.be.NaN();
207
+ ```
208
+
209
+ ##### null
210
+
211
+ Assert that value is null
212
+ ```typescript
213
+ expect(null).to.be.null();
214
+ ```
215
+
216
+ ##### number
217
+
218
+ Assert that value is a number
219
+ ```typescript
220
+ expect(5).to.be.a.number();
221
+ ```
222
+
223
+ ##### object
224
+
225
+ Assert that value is an object. Null and instances of Array don't count
226
+ expect({}).to.be.an.object();
227
+
228
+
229
+ ##### reject
230
+
231
+ Assert that provided Promise rejects. At the moment this is the only assertion that can't be chained, returns a promise
232
+ ```typescript
233
+ await expect(Promise.reject()).to.reject();
234
+ ```
235
+
236
+ ##### Set
237
+
238
+ Assert that value is an instance of Set
239
+ ```typescript
240
+ expect(new Set()).to.be.a.Set();
241
+ ```
242
+ ##### sizeOf
243
+
244
+ Alias of [lengthOf](#lengthOf)
245
+
246
+ ##### string
247
+
248
+ Assert that value is a string
249
+ ```typescript
250
+ expect('hein').to.be.a.string();
251
+ ```
252
+
253
+ ##### symbol
254
+
255
+ Assert that value is a symbol
256
+ ```typescript
257
+ expect(Symbol()).to.be.a.symbol();
258
+ ```
259
+
260
+ ##### throw
261
+
262
+ Assert that provided function throws
263
+ ```typescript
264
+ expect(() => { throw new Error() }).to.throw();
265
+ ```
266
+ ##### true
267
+
268
+ Assert that value is true
269
+ ```typescript
270
+ expect(true).to.be.true;
271
+ ```
272
+
273
+ ##### undefined
274
+
275
+ Assert that value is undefined
276
+ ```typescript
277
+ expect(undefined).to.be.undefined();
278
+ ```
279
+
280
+ ##### WeakMap
281
+
282
+ Assert that value is an instance of WeakMap
283
+ ```typescript
284
+ expect(new WeakMap()).to.be.a.WeakMap();
285
+ ```
286
+
287
+ ##### WeakSet
288
+
289
+ Assert that value is an instance of WeakSet
290
+ ```typescript
291
+ expect(new WeakSet()).to.be.a.WeakSet();
292
+ ```
293
+
@@ -0,0 +1,2 @@
1
+ export declare const eql: <T>(actual: T, expected: T, message?: string) => true | void, notEql: <T>(actual: T, expected: T, message?: string) => true | void;
2
+ //# sourceMappingURL=eql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eql.d.ts","sourceRoot":"","sources":["../../src/assert/eql.ts"],"names":[],"mappings":"AAIA,eAAO,MAAO,GAAG,wCAK2C,MAAM,kBAL/C,MAAM,wCAKmC,MAAM,gBAUhE,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.notEql = exports.eql = void 0;
5
+ const lodash_1 = require("lodash");
6
+ const assertion_1 = require("../utils/assertion");
7
+ const match_1 = require("../utils/match");
8
+ _a = (0, assertion_1.createAssertion)({
9
+ messages: {
10
+ notEql: 'Expected {{actual}} to deep equal {{expected}}',
11
+ not: 'Expected {{actual}} to not deep equal {{expected}}'
12
+ },
13
+ test: (report) => (actual, expected, message) => {
14
+ if (typeof expected !== 'function') {
15
+ // TODO: evaluations
16
+ expected = (0, lodash_1.cloneDeep)(expected);
17
+ }
18
+ if ((0, match_1.match)(actual, expected, { mutate: true })) {
19
+ return report({ message, status: 'ok', expected, actual });
20
+ }
21
+ return report({ message, status: 'notok', messageId: 'notEql', expected, actual });
22
+ }
23
+ }), exports.eql = _a[0], exports.notEql = _a[1];
24
+ //# sourceMappingURL=eql.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eql.js","sourceRoot":"","sources":["../../src/assert/eql.ts"],"names":[],"mappings":";;;;AAAA,mCAAmC;AACnC,kDAAqD;AACrD,0CAAuC;AAE1B,KAAgB,IAAA,2BAAe,EAAC;IACzC,QAAQ,EAAE;QACN,MAAM,EAAE,gDAAgD;QACxD,GAAG,EAAE,oDAAoD;KAC5D;IACD,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAI,MAAS,EAAE,QAAW,EAAE,OAAgB,EAAE,EAAE;QAC9D,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YAChC,oBAAoB;YACpB,QAAQ,GAAG,IAAA,kBAAS,EAAC,QAAQ,CAAC,CAAC;SAClC;QACD,IAAI,IAAA,aAAK,EAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE;YAC3C,OAAO,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;SAC9D;QACD,OAAO,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACvF,CAAC;CACJ,CAAC,EAfY,WAAG,UAAE,cAAM,SAetB"}
@@ -0,0 +1,9 @@
1
+ interface Equal {
2
+ /**
3
+ * check for === equality, NaN is equal to NaN
4
+ */
5
+ <T>(actual: T, expected: T, message?: string): void;
6
+ }
7
+ export declare const equal: Equal, notEqual: Equal;
8
+ export {};
9
+ //# sourceMappingURL=equal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../src/assert/equal.ts"],"names":[],"mappings":"AAEA,UAAU,KAAK;IACX;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvD;AAED,eAAO,MAAO,KAAK,SAAE,QAAQ,OAc3B,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.notEqual = exports.equal = void 0;
5
+ const assertion_1 = require("../utils/assertion");
6
+ _a = (0, assertion_1.createAssertion)({
7
+ messages: {
8
+ equal: 'Expected {{actual}} to equal {{expected}}',
9
+ not: 'Expected {{actual}} to not equal {{expected}}'
10
+ },
11
+ test: (report) => (a, b, message) => {
12
+ if (Number.isNaN(a) && Number.isNaN(b)) {
13
+ return report({ status: 'ok', expected: b, actual: a, message });
14
+ }
15
+ if (a !== b) {
16
+ return report({ status: 'notok', messageId: 'equal', actual: a, expected: b, message });
17
+ }
18
+ return report({ status: 'ok', expected: a, actual: b, message });
19
+ }
20
+ }), exports.equal = _a[0], exports.notEqual = _a[1];
21
+ //# sourceMappingURL=equal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equal.js","sourceRoot":"","sources":["../../src/assert/equal.ts"],"names":[],"mappings":";;;;AAAA,kDAAqD;AASxC,KAAoB,IAAA,2BAAe,EAAC;IAC7C,QAAQ,EAAE;QACN,KAAK,EAAE,2CAA2C;QAClD,GAAG,EAAE,+CAA+C;KACvD;IACD,IAAI,EAAE,CAAC,MAAM,EAAS,EAAE,CAAC,CAAI,CAAI,EAAE,CAAI,EAAE,OAAgB,EAAE,EAAE;QACzD,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACpC,OAAO,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;SACpE;QACD,IAAI,CAAC,KAAK,CAAC,EAAE;YACT,OAAO,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;SAC3F;QACD,OAAO,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IACrE,CAAC;CACJ,CAAC,EAdY,aAAK,UAAE,gBAAQ,SAc1B"}
@@ -0,0 +1,9 @@
1
+ interface GreaterThanEqual {
2
+ /**
3
+ * check for >=
4
+ */
5
+ <T extends number | bigint | Date>(actual: T, expected: T, message?: string): void;
6
+ }
7
+ export declare const greaterThanEqual: GreaterThanEqual, notGreaterThanEqual: GreaterThanEqual;
8
+ export {};
9
+ //# sourceMappingURL=greater-than-equal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"greater-than-equal.d.ts","sourceRoot":"","sources":["../../src/assert/greater-than-equal.ts"],"names":[],"mappings":"AAGA,UAAU,gBAAgB;IACtB;;OAEG;IACH,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtF;AAED,eAAO,MAAO,gBAAgB,oBAAE,mBAAmB,kBAYjD,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.notGreaterThanEqual = exports.greaterThanEqual = void 0;
5
+ const assertion_1 = require("../utils/assertion");
6
+ const validate_numeric_and_dates_1 = require("../utils/validate-numeric-and-dates");
7
+ _a = (0, assertion_1.createAssertion)({
8
+ messages: {
9
+ notGreaterThanEqual: 'Expected {{actual}} to not be greater than or equal to {{expected}}',
10
+ not: 'Expected {{actual}} to not be greater than or equal to {{expected}}'
11
+ },
12
+ test: (report) => (a, b, message) => {
13
+ (0, validate_numeric_and_dates_1.validateNumericsAndDates)(a, b);
14
+ if (a < b) {
15
+ return report({ status: 'notok', messageId: 'notGreaterThanEqual', actual: a, expected: b, message });
16
+ }
17
+ return report({ status: 'ok', expected: a, actual: b });
18
+ }
19
+ }), exports.greaterThanEqual = _a[0], exports.notGreaterThanEqual = _a[1];
20
+ //# sourceMappingURL=greater-than-equal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"greater-than-equal.js","sourceRoot":"","sources":["../../src/assert/greater-than-equal.ts"],"names":[],"mappings":";;;;AAAA,kDAAqD;AACrD,oFAA+E;AASlE,KAA0C,IAAA,2BAAe,EAAC;IACnE,QAAQ,EAAE;QACN,mBAAmB,EAAE,qEAAqE;QAC1F,GAAG,EAAE,qEAAqE;KAC7E;IACD,IAAI,EAAE,CAAC,MAAM,EAAoB,EAAE,CAAC,CAAC,CAAM,EAAE,CAAM,EAAE,OAAgB,EAAE,EAAE;QACrE,IAAA,qDAAwB,EAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,EAAE;YACP,OAAO,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;SACzG;QACD,OAAO,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5D,CAAC;CACJ,CAAC,EAZY,wBAAgB,UAAE,2BAAmB,SAYhD"}
@@ -0,0 +1,9 @@
1
+ interface GreaterThan {
2
+ /**
3
+ * check for >
4
+ */
5
+ <T extends number | bigint | Date>(actual: T, expected: T, message?: string): void;
6
+ }
7
+ export declare const greaterThan: GreaterThan, notGreaterThan: GreaterThan;
8
+ export {};
9
+ //# sourceMappingURL=greater-than.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"greater-than.d.ts","sourceRoot":"","sources":["../../src/assert/greater-than.ts"],"names":[],"mappings":"AAGA,UAAU,WAAW;IACjB;;OAEG;IACH,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtF;AAED,eAAO,MAAO,WAAW,eAAE,cAAc,aAYvC,CAAC"}