assertron 9.0.9 → 9.2.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.
- package/README.md +33 -57
- package/cjs/assert-order/AssertOrder.d.ts.map +1 -1
- package/cjs/assert-order/AssertOrder.js +169 -98
- package/cjs/assert-order/AssertOrder.js.map +1 -0
- package/cjs/assert-order/InvalidOrder.d.ts +2 -2
- package/cjs/assert-order/InvalidOrder.d.ts.map +1 -1
- package/cjs/assert-order/InvalidOrder.js +37 -8
- package/cjs/assert-order/InvalidOrder.js.map +1 -0
- package/cjs/assert-order/StateMachine.d.ts +1 -1
- package/cjs/assert-order/StateMachine.d.ts.map +1 -1
- package/cjs/assert-order/StateMachine.js +147 -57
- package/cjs/assert-order/StateMachine.js.map +1 -0
- package/cjs/assert-order/index.d.ts +3 -3
- package/cjs/assert-order/index.d.ts.map +1 -1
- package/cjs/assert-order/index.js +18 -5
- package/cjs/assert-order/index.js.map +1 -0
- package/cjs/assert-order/types.d.ts.map +1 -1
- package/cjs/assert-order/types.js +1 -1
- package/cjs/assert-order/types.js.map +1 -0
- package/cjs/assertron/assertron.d.ts +8 -8
- package/cjs/assertron/assertron.d.ts.map +1 -1
- package/cjs/assertron/assertron.js +21 -21
- package/cjs/assertron/assertron.js.map +1 -0
- package/cjs/assertron/falsy.d.ts.map +1 -1
- package/cjs/assertron/falsy.js +3 -3
- package/cjs/assertron/falsy.js.map +1 -0
- package/cjs/assertron/index.d.ts +1 -1
- package/cjs/assertron/index.d.ts.map +1 -1
- package/cjs/assertron/index.js +16 -3
- package/cjs/assertron/index.js.map +1 -0
- package/cjs/assertron/pathEqual.d.ts.map +1 -1
- package/cjs/assertron/pathEqual.js +4 -4
- package/cjs/assertron/pathEqual.js.map +1 -0
- package/cjs/assertron/rejects.d.ts +1 -1
- package/cjs/assertron/rejects.d.ts.map +1 -1
- package/cjs/assertron/rejects.js +4 -4
- package/cjs/assertron/rejects.js.map +1 -0
- package/cjs/assertron/repeat.d.ts.map +1 -1
- package/cjs/assertron/repeat.js +9 -7
- package/cjs/assertron/repeat.js.map +1 -0
- package/cjs/assertron/resolves.d.ts.map +1 -1
- package/cjs/assertron/resolves.js +4 -4
- package/cjs/assertron/resolves.js.map +1 -0
- package/cjs/assertron/satisfies.d.ts.map +1 -1
- package/cjs/assertron/satisfies.js +4 -4
- package/cjs/assertron/satisfies.js.map +1 -0
- package/cjs/assertron/throws.d.ts +1 -1
- package/cjs/assertron/throws.d.ts.map +1 -1
- package/cjs/assertron/throws.js +13 -11
- package/cjs/assertron/throws.js.map +1 -0
- package/cjs/assertron/truthy.d.ts.map +1 -1
- package/cjs/assertron/truthy.js +3 -3
- package/cjs/assertron/truthy.js.map +1 -0
- package/cjs/errors.d.ts.map +1 -1
- package/cjs/errors.js +32 -8
- package/cjs/errors.js.map +1 -0
- package/cjs/index.d.ts +5 -4
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +22 -7
- package/cjs/index.js.map +1 -0
- package/cjs/types.d.ts.map +1 -1
- package/cjs/types.js +1 -1
- package/cjs/types.js.map +1 -0
- package/cjs/utils/index.d.ts +6 -6
- package/cjs/utils/index.d.ts.map +1 -1
- package/cjs/utils/index.js +21 -8
- package/cjs/utils/index.js.map +1 -0
- package/cjs/utils/isErrorConstructor.d.ts +1 -1
- package/cjs/utils/isErrorConstructor.d.ts.map +1 -1
- package/cjs/utils/isErrorConstructor.js +1 -1
- package/cjs/utils/isErrorConstructor.js.map +1 -0
- package/cjs/utils/notEqualMessage.d.ts.map +1 -1
- package/cjs/utils/notEqualMessage.js +1 -1
- package/cjs/utils/notEqualMessage.js.map +1 -0
- package/cjs/utils/notSatisfiedMessage.d.ts.map +1 -1
- package/cjs/utils/notSatisfiedMessage.js +11 -3
- package/cjs/utils/notSatisfiedMessage.js.map +1 -0
- package/cjs/utils/notThrownMessage.d.ts.map +1 -1
- package/cjs/utils/notThrownMessage.js +1 -1
- package/cjs/utils/notThrownMessage.js.map +1 -0
- package/cjs/utils/promiseMessages.d.ts.map +1 -1
- package/cjs/utils/promiseMessages.js +1 -1
- package/cjs/utils/promiseMessages.js.map +1 -0
- package/cjs/utils/unexpectedErrorMessage.d.ts +1 -1
- package/cjs/utils/unexpectedErrorMessage.d.ts.map +1 -1
- package/cjs/utils/unexpectedErrorMessage.js +3 -3
- package/cjs/utils/unexpectedErrorMessage.js.map +1 -0
- package/esm/assert-order/AssertOrder.d.ts +41 -0
- package/esm/assert-order/AssertOrder.d.ts.map +1 -0
- package/esm/assert-order/AssertOrder.js +9 -3
- package/esm/assert-order/AssertOrder.js.map +1 -0
- package/esm/assert-order/InvalidOrder.d.ts +9 -0
- package/esm/assert-order/InvalidOrder.d.ts.map +1 -0
- package/esm/assert-order/InvalidOrder.js +20 -5
- package/esm/assert-order/InvalidOrder.js.map +1 -0
- package/esm/assert-order/StateMachine.d.ts +22 -0
- package/esm/assert-order/StateMachine.d.ts.map +1 -0
- package/esm/assert-order/StateMachine.js +37 -4
- package/esm/assert-order/StateMachine.js.map +1 -0
- package/esm/assert-order/index.d.ts +4 -0
- package/esm/assert-order/index.d.ts.map +1 -0
- package/esm/assert-order/index.js +4 -4
- package/esm/assert-order/index.js.map +1 -0
- package/esm/assert-order/types.d.ts +8 -0
- package/esm/assert-order/types.d.ts.map +1 -0
- package/esm/assert-order/types.js +1 -1
- package/esm/assert-order/types.js.map +1 -0
- package/esm/assertron/assertron.d.ts +21 -0
- package/esm/assertron/assertron.d.ts.map +1 -0
- package/esm/assertron/assertron.js +11 -11
- package/esm/assertron/assertron.js.map +1 -0
- package/esm/assertron/falsy.d.ts +2 -0
- package/esm/assertron/falsy.d.ts.map +1 -0
- package/esm/assertron/falsy.js +2 -2
- package/esm/assertron/falsy.js.map +1 -0
- package/esm/assertron/index.d.ts +2 -0
- package/esm/assertron/index.d.ts.map +1 -0
- package/esm/assertron/index.js +2 -2
- package/esm/assertron/index.js.map +1 -0
- package/esm/assertron/pathEqual.d.ts +2 -0
- package/esm/assertron/pathEqual.d.ts.map +1 -0
- package/esm/assertron/pathEqual.js +3 -3
- package/esm/assertron/pathEqual.js.map +1 -0
- package/esm/assertron/rejects.d.ts +2 -0
- package/esm/assertron/rejects.d.ts.map +1 -0
- package/esm/assertron/rejects.js +4 -4
- package/esm/assertron/rejects.js.map +1 -0
- package/esm/assertron/repeat.d.ts +6 -0
- package/esm/assertron/repeat.d.ts.map +1 -0
- package/esm/assertron/repeat.js +2 -2
- package/esm/assertron/repeat.js.map +1 -0
- package/esm/assertron/resolves.d.ts +2 -0
- package/esm/assertron/resolves.d.ts.map +1 -0
- package/esm/assertron/resolves.js +3 -3
- package/esm/assertron/resolves.js.map +1 -0
- package/esm/assertron/satisfies.d.ts +10 -0
- package/esm/assertron/satisfies.d.ts.map +1 -0
- package/esm/assertron/satisfies.js +3 -3
- package/esm/assertron/satisfies.js.map +1 -0
- package/esm/assertron/throws.d.ts +6 -0
- package/esm/assertron/throws.d.ts.map +1 -0
- package/esm/assertron/throws.js +3 -3
- package/esm/assertron/throws.js.map +1 -0
- package/esm/assertron/truthy.d.ts +2 -0
- package/esm/assertron/truthy.d.ts.map +1 -0
- package/esm/assertron/truthy.js +2 -2
- package/esm/assertron/truthy.js.map +1 -0
- package/esm/errors.d.ts +17 -0
- package/esm/errors.d.ts.map +1 -0
- package/esm/errors.js +14 -4
- package/esm/errors.js.map +1 -0
- package/esm/index.d.ts +7 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +6 -5
- package/esm/index.js.map +1 -0
- package/esm/types.d.ts +3 -0
- package/esm/types.d.ts.map +1 -0
- package/esm/types.js +1 -1
- package/esm/types.js.map +1 -0
- package/esm/utils/index.d.ts +8 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +7 -7
- package/esm/utils/index.js.map +1 -0
- package/esm/utils/isErrorConstructor.d.ts +3 -0
- package/esm/utils/isErrorConstructor.d.ts.map +1 -0
- package/esm/utils/isErrorConstructor.js +1 -1
- package/esm/utils/isErrorConstructor.js.map +1 -0
- package/esm/utils/notEqualMessage.d.ts +2 -0
- package/esm/utils/notEqualMessage.d.ts.map +1 -0
- package/esm/utils/notEqualMessage.js +1 -1
- package/esm/utils/notEqualMessage.js.map +1 -0
- package/esm/utils/notSatisfiedMessage.d.ts +3 -0
- package/esm/utils/notSatisfiedMessage.d.ts.map +1 -0
- package/esm/utils/notSatisfiedMessage.js +1 -1
- package/esm/utils/notSatisfiedMessage.js.map +1 -0
- package/esm/utils/notThrownMessage.d.ts +2 -0
- package/esm/utils/notThrownMessage.d.ts.map +1 -0
- package/esm/utils/notThrownMessage.js +1 -1
- package/esm/utils/notThrownMessage.js.map +1 -0
- package/esm/utils/promiseMessages.d.ts +3 -0
- package/esm/utils/promiseMessages.d.ts.map +1 -0
- package/esm/utils/promiseMessages.js +1 -1
- package/esm/utils/promiseMessages.js.map +1 -0
- package/esm/utils/unexpectedErrorMessage.d.ts +3 -0
- package/esm/utils/unexpectedErrorMessage.d.ts.map +1 -0
- package/esm/utils/unexpectedErrorMessage.js +2 -2
- package/esm/utils/unexpectedErrorMessage.js.map +1 -0
- package/package.json +48 -46
- package/{src → ts}/assert-order/AssertOrder.ts +2 -2
- package/{src → ts}/assert-order/InvalidOrder.ts +2 -2
- package/{src → ts}/assert-order/StateMachine.ts +1 -1
- package/ts/assert-order/index.ts +4 -0
- package/{src → ts}/assert-order/internalInterfaces.ts +0 -0
- package/{src → ts}/assert-order/types.ts +0 -0
- package/ts/assertron/assertron.ts +29 -0
- package/{src → ts}/assertron/falsy.ts +1 -1
- package/ts/assertron/index.ts +1 -0
- package/{src → ts}/assertron/pathEqual.ts +2 -2
- package/{src → ts}/assertron/rejects.ts +3 -3
- package/{src → ts}/assertron/repeat.ts +2 -2
- package/{src → ts}/assertron/resolves.ts +2 -2
- package/{src → ts}/assertron/satisfies.ts +2 -2
- package/{src → ts}/assertron/throws.ts +5 -5
- package/{src → ts}/assertron/truthy.ts +1 -1
- package/{src → ts}/errors.ts +1 -1
- package/ts/index.ts +7 -0
- package/{src → ts}/testUtils.ts +3 -3
- package/{src → ts}/types.ts +0 -0
- package/ts/utils/index.ts +12 -0
- package/{src → ts}/utils/isErrorConstructor.ts +1 -1
- package/{src → ts}/utils/notEqualMessage.ts +0 -1
- package/{src → ts}/utils/notSatisfiedMessage.ts +2 -2
- package/{src → ts}/utils/notThrownMessage.ts +0 -0
- package/{src → ts}/utils/promiseMessages.ts +0 -0
- package/{src → ts}/utils/unexpectedErrorMessage.ts +3 -3
- package/cjs/tsconfig.cjs.tsbuildinfo +0 -1
- package/esm/tsconfig.esm.tsbuildinfo +0 -1
- package/src/assert-order/AssertOrder.spec.ts +0 -446
- package/src/assert-order/InvalidOrder.spec.ts +0 -60
- package/src/assert-order/index.ts +0 -4
- package/src/assertron/assertron.spec.ts +0 -40
- package/src/assertron/assertron.ts +0 -29
- package/src/assertron/falsy.spec.ts +0 -20
- package/src/assertron/index.ts +0 -1
- package/src/assertron/pathEqual.spec.ts +0 -28
- package/src/assertron/rejects.spec.ts +0 -32
- package/src/assertron/repeat.spec.ts +0 -47
- package/src/assertron/resolves.spec.ts +0 -29
- package/src/assertron/satisfies.spec.ts +0 -159
- package/src/assertron/throws.spec.ts +0 -184
- package/src/assertron/truthy.spec.ts +0 -23
- package/src/index.ts +0 -6
- package/src/utils/index.ts +0 -12
- package/src/utils/notSatisfiedMessage.spec.ts +0 -31
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
|
-
[![
|
|
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
|
-
##
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
21
|
+
# yarn
|
|
22
|
+
yarn add assertron
|
|
39
23
|
|
|
40
|
-
|
|
41
|
-
|
|
24
|
+
# pnpm
|
|
25
|
+
pnpm install assertron
|
|
42
26
|
|
|
43
|
-
|
|
27
|
+
#rush
|
|
28
|
+
rush add -p assertron
|
|
29
|
+
```
|
|
44
30
|
|
|
45
|
-
|
|
31
|
+
## Usage
|
|
46
32
|
|
|
47
|
-
|
|
33
|
+
`assertron` provides a collection of assertion methods:
|
|
48
34
|
|
|
49
|
-
`assertron.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssertOrder.d.ts","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"AssertOrder.d.ts","sourceRoot":"","sources":["../../ts/assert-order/AssertOrder.ts"],"names":[],"mappings":"AAMA,qBAAa,WAAW;IACtB;;OAEG;IACH,IAAI,WAAW,WAEd;IAED,OAAO,CAAC,KAAK,CAAc;gBACf,IAAI,CAAC,EAAE,MAAM;IAIzB;;;OAGG;IACH,EAAE,CAAC,IAAI,EAAE,MAAM;IAIf;;;OAGG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM;IAMhB;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM;IAIjB;;OAEG;IACH,IAAI;IAIJ;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM;IAKjB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI;IAM/C,WAAW,CAAC,IAAI,EAAE,MAAM;IAaxB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE;IAQnB,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IAoBjE,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACrC,GAAG,IAAI,MAAM;IAmBb,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAWnC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAO9C,OAAO,CAAC,MAAM;CAKf"}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AssertOrder = void 0;
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var InvalidOrder_js_1 = require("./InvalidOrder.js");
|
|
5
|
+
var StateMachine_js_1 = require("./StateMachine.js");
|
|
6
6
|
// order.atLeast(step, count) // expected to be executed at least `count` times
|
|
7
7
|
// order.atMost(step, count) // exected to be executed at most `count` times
|
|
8
8
|
var AssertOrder = /** @class */ (function () {
|
|
9
9
|
function AssertOrder(plan) {
|
|
10
|
-
this
|
|
10
|
+
Object.defineProperty(this, "state", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
this.state = new StateMachine_js_1.StateMachine(plan);
|
|
11
17
|
}
|
|
12
18
|
Object.defineProperty(AssertOrder.prototype, "currentStep", {
|
|
13
19
|
/**
|
|
@@ -23,126 +29,191 @@ var AssertOrder = /** @class */ (function () {
|
|
|
23
29
|
* Asserts the current step is `step`.
|
|
24
30
|
* @param step expected step.
|
|
25
31
|
*/
|
|
26
|
-
AssertOrder.prototype
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
Object.defineProperty(AssertOrder.prototype, "is", {
|
|
33
|
+
enumerable: false,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: function (step) {
|
|
37
|
+
this.assert('is', step);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
29
40
|
/**
|
|
30
41
|
* Asserts the current step is not `step`.
|
|
31
42
|
* @param step not expected step.
|
|
32
43
|
*/
|
|
33
|
-
AssertOrder.prototype
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
Object.defineProperty(AssertOrder.prototype, "not", {
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: function (step) {
|
|
49
|
+
if (this.state.isValid(step)) {
|
|
50
|
+
throw new InvalidOrder_js_1.InvalidOrder(this.state.get(), 'not', [step], { ssf: this.not });
|
|
51
|
+
}
|
|
36
52
|
}
|
|
37
|
-
};
|
|
53
|
+
});
|
|
38
54
|
/**
|
|
39
55
|
* Reset to specified step.
|
|
40
56
|
*/
|
|
41
|
-
AssertOrder.prototype
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
Object.defineProperty(AssertOrder.prototype, "jump", {
|
|
58
|
+
enumerable: false,
|
|
59
|
+
configurable: true,
|
|
60
|
+
writable: true,
|
|
61
|
+
value: function (step) {
|
|
62
|
+
this.state.jump(step);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
44
65
|
/**
|
|
45
66
|
* Move to next step.
|
|
46
67
|
*/
|
|
47
|
-
AssertOrder.prototype
|
|
48
|
-
|
|
49
|
-
|
|
68
|
+
Object.defineProperty(AssertOrder.prototype, "move", {
|
|
69
|
+
enumerable: false,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: function () {
|
|
73
|
+
this.state.move();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
50
76
|
/**
|
|
51
77
|
* Asserts the specified step will run once.
|
|
52
78
|
*/
|
|
53
|
-
AssertOrder.prototype
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
assert(step);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
AssertOrder.prototype.atLeastOnce = function (step) {
|
|
63
|
-
var nextStep = step + 1;
|
|
64
|
-
if (this.state.step === step) {
|
|
79
|
+
Object.defineProperty(AssertOrder.prototype, "once", {
|
|
80
|
+
enumerable: false,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: function (step) {
|
|
84
|
+
this.assert('once', step);
|
|
65
85
|
this.state.move();
|
|
66
|
-
return this.state.moveSubStep();
|
|
67
86
|
}
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(AssertOrder.prototype, "on", {
|
|
89
|
+
enumerable: false,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: function (step, assert) {
|
|
93
|
+
this.state.on(step, function () {
|
|
94
|
+
assert(step);
|
|
95
|
+
});
|
|
70
96
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(AssertOrder.prototype, "atLeastOnce", {
|
|
99
|
+
enumerable: false,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: function (step) {
|
|
103
|
+
var nextStep = step + 1;
|
|
104
|
+
if (this.state.step === step) {
|
|
105
|
+
this.state.move();
|
|
106
|
+
return this.state.moveSubStep();
|
|
107
|
+
}
|
|
108
|
+
else if (this.state.step === nextStep && this.state.subStep > 0) {
|
|
109
|
+
return this.state.moveSubStep();
|
|
110
|
+
}
|
|
111
|
+
else
|
|
112
|
+
throw new InvalidOrder_js_1.InvalidOrder(this.state.get(), 'atLeastOnce', [step], { ssf: this.atLeastOnce });
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(AssertOrder.prototype, "any", {
|
|
116
|
+
enumerable: false,
|
|
117
|
+
configurable: true,
|
|
118
|
+
writable: true,
|
|
119
|
+
value: function (steps) {
|
|
120
|
+
var index = steps.indexOf(this.state.step);
|
|
121
|
+
if (index === -1)
|
|
122
|
+
throw new InvalidOrder_js_1.InvalidOrder(this.state.get(), 'any', [steps], { ssf: this.any });
|
|
123
|
+
this.state.move();
|
|
124
|
+
return steps[index];
|
|
86
125
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
126
|
+
});
|
|
127
|
+
Object.defineProperty(AssertOrder.prototype, "onAny", {
|
|
128
|
+
enumerable: false,
|
|
129
|
+
configurable: true,
|
|
130
|
+
writable: true,
|
|
131
|
+
value: function (steps) {
|
|
132
|
+
var _this = this;
|
|
133
|
+
var asserts = [];
|
|
134
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
135
|
+
asserts[_i - 1] = arguments[_i];
|
|
136
|
+
}
|
|
137
|
+
steps.forEach(function (step) {
|
|
138
|
+
_this.state.on(step, function () {
|
|
139
|
+
var firstError;
|
|
140
|
+
var hasPass = false;
|
|
141
|
+
asserts.forEach(function (assert) {
|
|
142
|
+
try {
|
|
143
|
+
assert(step);
|
|
144
|
+
hasPass = true;
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
if (!firstError)
|
|
148
|
+
firstError = err;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
if (!hasPass)
|
|
152
|
+
throw firstError;
|
|
100
153
|
});
|
|
101
|
-
if (!hasPass)
|
|
102
|
-
throw firstError;
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
return;
|
|
106
|
-
};
|
|
107
|
-
AssertOrder.prototype.end = function (timeout) {
|
|
108
|
-
var _this = this;
|
|
109
|
-
if (timeout) {
|
|
110
|
-
return new Promise(function (r) {
|
|
111
|
-
setTimeout(r, timeout);
|
|
112
|
-
}).then(function () {
|
|
113
|
-
return _this.end();
|
|
114
154
|
});
|
|
155
|
+
return;
|
|
115
156
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(AssertOrder.prototype, "end", {
|
|
159
|
+
enumerable: false,
|
|
160
|
+
configurable: true,
|
|
161
|
+
writable: true,
|
|
162
|
+
value: function (timeout) {
|
|
163
|
+
var _this = this;
|
|
164
|
+
if (timeout) {
|
|
165
|
+
return new Promise(function (r) {
|
|
166
|
+
setTimeout(r, timeout);
|
|
167
|
+
}).then(function () {
|
|
168
|
+
return _this.end();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (!this.state.isMaxStepDefined()) {
|
|
172
|
+
this.state.stopAccepting();
|
|
173
|
+
return this.state.getTimeTaken();
|
|
174
|
+
}
|
|
175
|
+
if (this.state.isAccepting()) {
|
|
176
|
+
throw new InvalidOrder_js_1.InvalidOrder(this.state.get(), 'end', [], { ssf: this.end });
|
|
177
|
+
}
|
|
119
178
|
}
|
|
120
|
-
|
|
121
|
-
|
|
179
|
+
});
|
|
180
|
+
Object.defineProperty(AssertOrder.prototype, "exactly", {
|
|
181
|
+
enumerable: false,
|
|
182
|
+
configurable: true,
|
|
183
|
+
writable: true,
|
|
184
|
+
value: function (step, times) {
|
|
185
|
+
if (this.state.isNotValid(step))
|
|
186
|
+
throw new InvalidOrder_js_1.InvalidOrder(this.state.get(), 'exactly', [step, times], { ssf: this.exactly });
|
|
187
|
+
if (this.state.maxSubStep === undefined) {
|
|
188
|
+
this.state.maxSubStep = times;
|
|
189
|
+
this.state.minSubStep = times;
|
|
190
|
+
}
|
|
191
|
+
return this.state.moveSubStep();
|
|
122
192
|
}
|
|
123
|
-
};
|
|
124
|
-
AssertOrder.prototype
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(AssertOrder.prototype, "wait", {
|
|
195
|
+
enumerable: false,
|
|
196
|
+
configurable: true,
|
|
197
|
+
writable: true,
|
|
198
|
+
value: function (step, callback) {
|
|
199
|
+
var _this = this;
|
|
200
|
+
if (callback)
|
|
201
|
+
this.on(step, callback);
|
|
202
|
+
else
|
|
203
|
+
return new Promise(function (a) { _this.on(step, a); });
|
|
130
204
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
AssertOrder.prototype.assert = function (method, step) {
|
|
141
|
-
if (this.state.isNotValid(step)) {
|
|
142
|
-
throw new InvalidOrder_1.InvalidOrder(this.state.get(), method, [step], { ssf: this[method] });
|
|
205
|
+
});
|
|
206
|
+
Object.defineProperty(AssertOrder.prototype, "assert", {
|
|
207
|
+
enumerable: false,
|
|
208
|
+
configurable: true,
|
|
209
|
+
writable: true,
|
|
210
|
+
value: function (method, step) {
|
|
211
|
+
if (this.state.isNotValid(step)) {
|
|
212
|
+
throw new InvalidOrder_js_1.InvalidOrder(this.state.get(), method, [step], { ssf: this[method] });
|
|
213
|
+
}
|
|
143
214
|
}
|
|
144
|
-
};
|
|
215
|
+
});
|
|
145
216
|
return AssertOrder;
|
|
146
217
|
}());
|
|
147
218
|
exports.AssertOrder = AssertOrder;
|
|
148
|
-
//# sourceMappingURL=
|
|
219
|
+
//# sourceMappingURL=AssertOrder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AssertOrder.js","sourceRoot":"","sources":["../../ts/assert-order/AssertOrder.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAChD,qDAAgD;AAEhD,+EAA+E;AAC/E,4EAA4E;AAE5E;IASE,qBAAY,IAAa;QADzB;;;;;WAA2B;QAEzB,IAAI,CAAC,KAAK,GAAG,IAAI,8BAAY,CAAC,IAAI,CAAC,CAAA;IACrC,CAAC;IAPD,sBAAI,oCAAW;QAHf;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;QACxB,CAAC;;;OAAA;IAOD;;;OAGG;;;;;eACH,UAAG,IAAY;YACb,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACzB,CAAC;;IAED;;;OAGG;;;;;eACH,UAAI,IAAY;Y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AAE,QAAQ,CAAC,CAAA;;gBAEvB,OAAO,IAAI,OAAO,CAAM,UAAA,CAAC,IAAM,KAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;QACtD,CAAC;;;;;;eACD,UAAe,MAAc,EAAE,IAAY;YACzC,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBAC/B,MAAM,IAAI,8BAAY,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAG,IAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;aACzF;QACH,CAAC;;IACH,kBAAC;AAAD,CAAC,AAhJD,IAgJC;AAhJY,kCAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidOrder.d.ts","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"InvalidOrder.d.ts","sourceRoot":"","sources":["../../ts/assert-order/InvalidOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAElC,qBAAa,YAAa,SAAQ,cAAc;IAC3B,KAAK,EAAE,KAAK;IAAS,MAAM,EAAE,MAAM;IAAS,IAAI,EAAE,GAAG,EAAE;gBAAvD,KAAK,EAAE,KAAK,EAAS,MAAM,EAAE,MAAM,EAAS,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO;CAG5G"}
|
|
@@ -1,19 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.InvalidOrder = void 0;
|
|
4
|
-
var
|
|
5
|
-
var errors_1 = require("../errors");
|
|
19
|
+
var errors_js_1 = require("../errors.js");
|
|
6
20
|
var InvalidOrder = /** @class */ (function (_super) {
|
|
7
|
-
|
|
21
|
+
__extends(InvalidOrder, _super);
|
|
8
22
|
function InvalidOrder(state, method, args, options) {
|
|
9
23
|
var _this = _super.call(this, method === 'end' ? getEndMessage(state) : getExpectingMessage(state, method, args), options) || this;
|
|
10
|
-
_this
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
Object.defineProperty(_this, "state", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: state
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(_this, "method", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: method
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(_this, "args", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
configurable: true,
|
|
39
|
+
writable: true,
|
|
40
|
+
value: args
|
|
41
|
+
});
|
|
13
42
|
return _this;
|
|
14
43
|
}
|
|
15
44
|
return InvalidOrder;
|
|
16
|
-
}(
|
|
45
|
+
}(errors_js_1.AssertionError));
|
|
17
46
|
exports.InvalidOrder = InvalidOrder;
|
|
18
47
|
function getEndMessage(state) {
|
|
19
48
|
return "Planned for ".concat(state.maxStep, " step but expecting step ").concat(state.step, " when 'end()' is called");
|
|
@@ -36,4 +65,4 @@ function getExpectingCalls(state) {
|
|
|
36
65
|
function getMethodArgs(args) {
|
|
37
66
|
return args.map(function (a) { return Array.isArray(a) ? "[".concat(a.join(', '), "]") : a; }).join(', ');
|
|
38
67
|
}
|
|
39
|
-
//# sourceMappingURL=
|
|
68
|
+
//# sourceMappingURL=InvalidOrder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InvalidOrder.js","sourceRoot":"","sources":["../../ts/assert-order/InvalidOrder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,0CAA6C;AAG7C;IAAkC,gCAAc;IAC9C,sBAAmB,KAAY,EAAS,MAAc,EAAS,IAAW,EAAE,OAA+B;QAA3G,YACE,kBAAM,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,SACnG;;;;;mBAFkB;;;;;;mBAAqB;;;;;;mBAAuB;;;IAE/D,CAAC;IACH,mBAAC;AAAD,CAAC,AAJD,CAAkC,0BAAc,GAI/C;AAJY,oCAAY;AAMzB,SAAS,aAAa,CAAC,KAAY;IACjC,OAAO,sBAAe,KAAK,CAAC,OAAO,sCAA4B,KAAK,CAAC,IAAI,4BAAyB,CAAA;AACpG,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAY,EAAE,MAAc,EAAE,IAAW;IACpE,OAAO,oBAAa,iBAAiB,CAAC,KAAK,CAAC,6BAAmB,MAAM,cAAI,aAAa,CAAC,IAAI,CAAC,OAAI,CAAA;AAClG,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAY;IACrC,IAAI,OAAe,CAAA;IACnB,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,EAAE;QACvB,IAAM,OAAO,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;QACrC,OAAO,GAAG,OAAO,CAAC,GAAG,CACnB,UAAA,CAAC,IAAI,OAAA,WAAI,CAAC,cAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAI,KAAK,CAAC,IAAI,MAAG,OAAI,EAAvE,CAAuE,CAC7E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACb;SACI;QACH,IAAM,OAAO,GAAG,CAAC,SAAS,CAAC,CAAA;QAC3B,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,WAAI,CAAC,cAAI,KAAK,CAAC,IAAI,eAAK,KAAK,CAAC,UAAU,OAAI,EAA5C,CAA4C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;KACpF;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,IAAW;IAChC,OAAO,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAG,CAAC,CAAC,CAAC,CAAC,EAA1C,CAA0C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMachine.d.ts","sourceRoot":"","sources":["../../
|
|
1
|
+
{"version":3,"file":"StateMachine.d.ts","sourceRoot":"","sources":["../../ts/assert-order/StateMachine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AA4ClC,qBAAa,YAAY;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,CAAK;IACjD,IAAI,SAAI;IACR,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB,OAAO,SAAI;IACX,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;gBACP,OAAO,CAAC,EAAE,MAAM;IAI5B,IAAI,CAAC,IAAI,EAAE,MAAM;IAKjB,IAAI;IASJ,WAAW;IAMX,GAAG,IAAI,KAAK;IAUZ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI;IAGrC,UAAU,CAAC,IAAI,EAAE,MAAM;IAGvB,OAAO,CAAC,IAAI,EAAE,MAAM;IAGpB,gBAAgB;IAGhB,aAAa;IAGb,WAAW;IAIX,YAAY;CAGb"}
|