assertron 9.1.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,10 @@
1
- <!-- markdownlint-disable MD024 -->
2
-
3
1
  # assertron
4
2
 
5
3
  [![NPM version][npm-image]][npm-url]
6
4
  [![NPM downloads][downloads-image]][downloads-url]
7
5
 
8
- [![Github NodeJS][github-nodejs]][github-action-url]
6
+ [![GitHub NodeJS][github-nodejs]][github-action-url]
9
7
  [![Codecov][codecov-image]][codecov-url]
10
- [![Coverage Status][coveralls-image]][coveralls-url]
11
8
 
12
9
  [![Semantic Release][semantic-release-image]][semantic-release-url]
13
10
 
@@ -15,41 +12,37 @@
15
12
 
16
13
  A supplementary assertion library that runs on both NodeJS and browser.
17
14
 
18
- ## assertron
19
-
20
- `assertron` provides a collection of assertion methods.
21
-
22
- ### assertron.false(value)
23
-
24
- Asserts the provided value is false.
25
-
26
- ### assertron.falsy(value)
15
+ ## Install
27
16
 
28
- Asserts the provided value is falsy.
29
-
30
- ### assertron.pathEqual(actual, expected)
31
-
32
- Asserts the two paths are equal regardless of operating system differences.
33
-
34
- ### assertron.rejects(promise)
35
-
36
- Asserts the promise rejects.
17
+ ```sh
18
+ # npm
19
+ npm install assertron
37
20
 
38
- ### assertron.repeat(fn, times)
21
+ # yarn
22
+ yarn add assertron
39
23
 
40
- Repeat the specified function n times and return the last result.
41
- If the result is a promise, it will run the function sequentially.
24
+ # pnpm
25
+ pnpm install assertron
42
26
 
43
- ### assertron.resolves(promise)
27
+ #rush
28
+ rush add -p assertron
29
+ ```
44
30
 
45
- Asserts the promise resolves.
31
+ ## Usage
46
32
 
47
- ### assertron.satisfies(actual, expected)
33
+ `assertron` provides a collection of assertion methods:
48
34
 
49
- `assertron.satisfies()` checks if `actual` meets the requirements specified by `expected`.
50
- Each property in `expected` can be a value, a `RegExp`, or a predicate function.
51
- It uses `satisfier` internally to check for validity.
52
- Check out [`satisfier`](https://github.com/unional/satisfier) for more detail.
35
+ - `assertron.false(value)`: asserts the provided value is false.
36
+ - `assertron.falsy(value)`: asserts the provided value is falsy.
37
+ - `assertron.pathEqual(actual, expected)`: asserts the two paths are equal regardless of operating system differences.
38
+ - `assertron.rejects(promise)`: asserts the promise rejects.
39
+ - `assertron.repeat(fn, times)`: repeat the specified function n times and return the last result.\
40
+ If the result is a promise, it will run the function sequentially.
41
+ - `assertron.resolves(promise)`: asserts the promise resolves.
42
+ - `assertron.satisfies(actual, expected)`: checks if `actual` meets the requirements specified by `expected`.\
43
+ Each property in `expected` can be a value, a `RegExp`, or a predicate function.\
44
+ It uses `satisfier` internally to check for validity.\
45
+ Check out [`satisfier`](https://github.com/unional/satisfier) for more detail.
53
46
 
54
47
  ```ts
55
48
  import a from 'assertron' // assertron is also exported as default.
@@ -66,9 +59,7 @@ a.satisfies({ a: 'foo' }, { a: /boo/ })
66
59
  a.satisfies({ a: 1 }, { a: () => false })
67
60
  ```
68
61
 
69
- ### assertron.throws(...)
70
-
71
- Asserts the promise, function, or async function throws (or rejects) an error.
62
+ - `assertron.throws(...)`: asserts the promise, function, or async function throws (or rejects) an error.
72
63
 
73
64
  ```ts
74
65
  import { assertron } from 'assertron'
@@ -82,21 +73,14 @@ const e2 = assertron.throws(() => { throw new SpecificError('foo') }, SpecificEr
82
73
  const e3 = await assertron.throws(() => Promise.reject(new SpecificError('foo')), SpecificError)
83
74
  ```
84
75
 
85
- ### assertron.true(value)
86
-
87
- Asserts the provided value is true.
88
-
89
- ### assertron.truthy(value)
90
-
91
- Asserts the provided value is truthy.
76
+ - `assertron.true(value)`: asserts the provided value is true.
77
+ - `assertron.truthy(value)`: asserts the provided value is truthy.
92
78
 
93
79
  ## AssertOrder
94
80
 
95
81
  Assert the code is executed in the expected order.
96
82
 
97
- ### order.once(step: number)
98
-
99
- Asserts the step `step` executed once.
83
+ - `order.once(step: number)`: asserts the step `step` executed once.
100
84
 
101
85
  ```ts
102
86
  import { AssertOrder } from 'assertron'
@@ -126,9 +110,7 @@ foo()
126
110
  boo()
127
111
  ```
128
112
 
129
- ### order.atLeastOnce(step: number)
130
-
131
- Assert the `step` executed at least once.
113
+ - `order.atLeastOnce(step: number)`: assert the `step` executed at least once.
132
114
 
133
115
  ```ts
134
116
  import { AssertOrder } from 'assertron'
@@ -142,9 +124,7 @@ for (let i = 0; i < 10; i++)
142
124
  o.once(2)
143
125
  ```
144
126
 
145
- ### order.exactly(step: number, times: number)
146
-
147
- Asserts the step `step` executed exactly n times
127
+ - `order.exactly(step: number, times: number)`: asserts the step `step` executed exactly n times
148
128
 
149
129
  ```ts
150
130
  import { AssertOrder } from 'assertron'
@@ -155,9 +135,7 @@ for (let i = 0; i < 4; i++)
155
135
  o.exactly(1, 3) // throws at i === 3
156
136
  ```
157
137
 
158
- ### order.any(steps: number[])
159
-
160
- Asserts any of the steps `steps` executed.
138
+ - `order.any(steps: number[])`: asserts any of the steps `steps` executed.
161
139
 
162
140
  ```ts
163
141
  import { AssertOrder } from 'assertron'
@@ -190,7 +168,7 @@ git push
190
168
  # create PR
191
169
  ```
192
170
 
193
- ## Npm Commands
171
+ ## NPM Commands
194
172
 
195
173
  There are a few useful commands you can use during development.
196
174
 
@@ -211,8 +189,6 @@ yarn verify
211
189
  [github-action-url]: https://github.com/unional/assertron/actions
212
190
  [codecov-image]: https://codecov.io/gh/unional/assertron/branch/master/graph/badge.svg
213
191
  [codecov-url]: https://codecov.io/gh/unional/assertron
214
- [coveralls-image]: https://coveralls.io/repos/github/unional/assertron/badge.svg
215
- [coveralls-url]: https://coveralls.io/github/unional/assertron
216
192
 
217
193
  [semantic-release-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg
218
194
  [semantic-release-url]: https://github.com/semantic-release/semantic-release
@@ -4,7 +4,7 @@ exports.rejects = void 0;
4
4
  var errors_js_1 = require("../errors.js");
5
5
  var index_js_1 = require("../utils/index.js");
6
6
  function rejects(promise) {
7
- return promise.then(function (value) { throw new errors_js_1.AssertionError((0, index_js_1.notRejectedMessage)(value), { ssf: rejects }); }, function () { });
7
+ return promise.then(function (value) { throw new errors_js_1.AssertionError((0, index_js_1.notRejectedMessage)(value), { ssf: rejects }); }, function (err) { return err; });
8
8
  }
9
9
  exports.rejects = rejects;
10
10
  //# sourceMappingURL=rejects.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rejects.js","sourceRoot":"","sources":["../../ts/assertron/rejects.ts"],"names":[],"mappings":";;;AAAA,0CAA6C;AAC7C,8CAAsD;AAEtD,SAAgB,OAAO,CAAC,OAAqB;IAC3C,OAAO,OAAO,CAAC,IAAI,CACjB,UAAA,KAAK,IAAM,MAAM,IAAI,0BAAc,CAAC,IAAA,6BAAkB,EAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA,CAAC,CAAC,EAClF,cAAQ,CAAC,CACV,CAAA;AACH,CAAC;AALD,0BAKC"}
1
+ {"version":3,"file":"rejects.js","sourceRoot":"","sources":["../../ts/assertron/rejects.ts"],"names":[],"mappings":";;;AAAA,0CAA6C;AAC7C,8CAAsD;AAEtD,SAAgB,OAAO,CAAC,OAAqB;IAC3C,OAAO,OAAO,CAAC,IAAI,CACjB,UAAA,KAAK,IAAM,MAAM,IAAI,0BAAc,CAAC,IAAA,6BAAkB,EAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA,CAAC,CAAC,EAClF,UAAA,GAAG,IAAI,OAAA,GAAG,EAAH,CAAG,CACX,CAAA;AACH,CAAC;AALD,0BAKC"}
package/cjs/index.js CHANGED
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.a = void 0;
17
18
  var index_js_1 = require("./assertron/index.js");
19
+ Object.defineProperty(exports, "a", { enumerable: true, get: function () { return index_js_1.assertron; } });
18
20
  __exportStar(require("./assert-order/index.js"), exports);
19
21
  __exportStar(require("./assertron/index.js"), exports);
20
22
  __exportStar(require("./errors.js"), exports);
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAAgD;AAEhD,0DAAuC;AACvC,uDAAoC;AACpC,8CAA2B;AAC3B,kBAAe,oBAAS,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,iDAAgD;AAM1B,kFANb,oBAAS,OAMK;AAJvB,0DAAuC;AACvC,uDAAoC;AACpC,8CAA2B;AAC3B,kBAAe,oBAAS,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { AssertionError } from '../errors.js';
2
2
  import { notRejectedMessage } from '../utils/index.js';
3
3
  export function rejects(promise) {
4
- return promise.then(value => { throw new AssertionError(notRejectedMessage(value), { ssf: rejects }); }, () => { });
4
+ return promise.then(value => { throw new AssertionError(notRejectedMessage(value), { ssf: rejects }); }, err => err);
5
5
  }
6
6
  //# sourceMappingURL=rejects.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rejects.js","sourceRoot":"","sources":["../../ts/assertron/rejects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,MAAM,UAAU,OAAO,CAAC,OAAqB;IAC3C,OAAO,OAAO,CAAC,IAAI,CACjB,KAAK,CAAC,EAAE,GAAG,MAAM,IAAI,cAAc,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA,CAAC,CAAC,EAClF,GAAG,EAAE,GAAG,CAAC,CACV,CAAA;AACH,CAAC"}
1
+ {"version":3,"file":"rejects.js","sourceRoot":"","sources":["../../ts/assertron/rejects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAEtD,MAAM,UAAU,OAAO,CAAC,OAAqB;IAC3C,OAAO,OAAO,CAAC,IAAI,CACjB,KAAK,CAAC,EAAE,GAAG,MAAM,IAAI,cAAc,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAA,CAAC,CAAC,EAClF,GAAG,CAAC,EAAE,CAAC,GAAG,CACX,CAAA;AACH,CAAC"}
package/esm/index.js CHANGED
@@ -3,4 +3,5 @@ export * from './assert-order/index.js';
3
3
  export * from './assertron/index.js';
4
4
  export * from './errors.js';
5
5
  export default assertron;
6
+ export { assertron as a };
6
7
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,IAAI,CAAC,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assertron",
3
- "version": "9.1.0",
3
+ "version": "9.2.0",
4
4
  "description": "A supplementary assertion library",
5
5
  "homepage": "https://github.com/unional/assertron",
6
6
  "bugs": {
@@ -4,6 +4,6 @@ import { notRejectedMessage } from '../utils/index.js'
4
4
  export function rejects(promise: Promise<any>) {
5
5
  return promise.then(
6
6
  value => { throw new AssertionError(notRejectedMessage(value), { ssf: rejects }) },
7
- () => { }
7
+ err => err
8
8
  )
9
9
  }
package/ts/index.ts CHANGED
@@ -4,3 +4,4 @@ export * from './assert-order/index.js'
4
4
  export * from './assertron/index.js'
5
5
  export * from './errors.js'
6
6
  export default assertron
7
+ export { assertron as a }