@wmfs/asl-choice-processor 1.22.0 → 1.24.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/CHANGELOG.md +66 -0
- package/lib/operators/index.js +3 -0
- package/lib/operators/is-boolean.js +11 -0
- package/lib/operators/is-null.js +6 -6
- package/lib/operators/is-present.js +6 -0
- package/lib/operators/is-string.js +13 -0
- package/lib/operators/is-undefined.js +8 -10
- package/package.json +8 -8
- package/renovate.json +26 -0
- package/test/data-test-expr-tests.js +42 -1
- package/test/is-present-expr-tests.js +162 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
+
# [1.24.0](https://github.com/wmfs/asl-choice-processor/compare/v1.23.0...v1.24.0) (2022-09-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### ✨ Features
|
|
5
|
+
|
|
6
|
+
* IsBoolean operator ([b2ef9da](https://github.com/wmfs/asl-choice-processor/commit/b2ef9da9440fd8fd97f6ca413e6ac1947b31f546))
|
|
7
|
+
* IsString operator ([52fcedd](https://github.com/wmfs/asl-choice-processor/commit/52fcedd2df00c03027369882986f7d63c541a87c))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### 📦 Code Refactoring
|
|
11
|
+
|
|
12
|
+
* tidy up IsNull and extend tests ([f5efe84](https://github.com/wmfs/asl-choice-processor/commit/f5efe84d1590c6d47dede3faeaa366c5012fbd0f))
|
|
13
|
+
* tidy up IsUndefined and extend tests ([00dea40](https://github.com/wmfs/asl-choice-processor/commit/00dea40f86d7bf5932841807d05ec6c73264941e))
|
|
14
|
+
|
|
15
|
+
# [1.23.0](https://github.com/wmfs/asl-choice-processor/compare/v1.22.0...v1.23.0) (2022-08-12)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### ✨ Features
|
|
19
|
+
|
|
20
|
+
* added IsPresent support ([a4329d9](https://github.com/wmfs/asl-choice-processor/commit/a4329d9d073a978164ecf9af60c0e61c404e6360))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### 🛠 Builds
|
|
24
|
+
|
|
25
|
+
* **deps-dev:** bump codecov from 3.8.2 to 3.8.3 ([712bddd](https://github.com/wmfs/asl-choice-processor/commit/712bddd2ba73ce27d34a1c51efff23c1ee74fe9a))
|
|
26
|
+
* **deps-dev:** bump mocha from 8.4.0 to 9.0.0 ([64aa3d0](https://github.com/wmfs/asl-choice-processor/commit/64aa3d08cfb596ef4a41e4387a9fb1124231945a))
|
|
27
|
+
* **deps-dev:** bump mocha from 9.0.0 to 9.0.1 ([050993c](https://github.com/wmfs/asl-choice-processor/commit/050993c781b17c04ff1d69f3a12e442ac3cbfed2))
|
|
28
|
+
* **deps-dev:** bump mocha from 9.0.1 to 9.0.2 ([a40efde](https://github.com/wmfs/asl-choice-processor/commit/a40efde5d8b8337819ff24e04eb9ddeba3454a73))
|
|
29
|
+
* **deps-dev:** bump mocha from 9.0.2 to 9.0.3 ([e6a16c0](https://github.com/wmfs/asl-choice-processor/commit/e6a16c0d192f0ea5fab80d4f74af606b09fbb8a1))
|
|
30
|
+
* **deps-dev:** bump semantic-release from 17.4.2 to 17.4.3 ([5c714e4](https://github.com/wmfs/asl-choice-processor/commit/5c714e436c8a6a2654cdc0a4ea3cc4b4c4f200ed))
|
|
31
|
+
* **deps-dev:** bump semantic-release from 17.4.3 to 17.4.4 ([afc6af8](https://github.com/wmfs/asl-choice-processor/commit/afc6af89d2d1a1c0b20afee7f36a0fa38ab32a68))
|
|
32
|
+
* **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/changelog to v6 ([a2f795f](https://github.com/wmfs/asl-choice-processor/commit/a2f795f42a99e1cc120acce816733b7da5100cf2))
|
|
33
|
+
* **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/git to v10 ([d986753](https://github.com/wmfs/asl-choice-processor/commit/d986753b02758935c5dc42c39b581e9e0057a687))
|
|
34
|
+
* **deps-dev:** update dependency [@semantic-release](https://github.com/semantic-release)/git to v9.0.1 ([16b753d](https://github.com/wmfs/asl-choice-processor/commit/16b753d1ab1cebed3ba839213f1336ed23397127))
|
|
35
|
+
* **deps-dev:** update dependency chai to v4.3.5 ([2f3103c](https://github.com/wmfs/asl-choice-processor/commit/2f3103cc87e410ce47bd7fa27817ff3cb0fa7a7a))
|
|
36
|
+
* **deps-dev:** update dependency chai to v4.3.6 ([2ad7add](https://github.com/wmfs/asl-choice-processor/commit/2ad7add962a0b60b483f3b81357bd5b367702e9f))
|
|
37
|
+
* **deps-dev:** update dependency mocha to v10 ([2233142](https://github.com/wmfs/asl-choice-processor/commit/2233142a3925884e4826a79cdebf6e59b3486177))
|
|
38
|
+
* **deps-dev:** update dependency mocha to v9.1.0 ([fc4b92f](https://github.com/wmfs/asl-choice-processor/commit/fc4b92f4ba0d78f36db2bd1f880ca77b2c29ed5b))
|
|
39
|
+
* **deps-dev:** update dependency mocha to v9.1.1 ([0ad11d8](https://github.com/wmfs/asl-choice-processor/commit/0ad11d8c5ce49fbf681fd2a9b2a97a074ed91bdf))
|
|
40
|
+
* **deps-dev:** update dependency mocha to v9.1.2 ([932f4f4](https://github.com/wmfs/asl-choice-processor/commit/932f4f4583a107e700474acb533b8ec8df7afe8e))
|
|
41
|
+
* **deps-dev:** update dependency mocha to v9.1.3 ([47ce905](https://github.com/wmfs/asl-choice-processor/commit/47ce90568f29cfb435144cec6fa0ad6dbe42b001))
|
|
42
|
+
* **deps-dev:** update dependency mocha to v9.1.4 ([0402f9a](https://github.com/wmfs/asl-choice-processor/commit/0402f9aa14fcbdf4f2ff5e7c7bb22ca224609bf0))
|
|
43
|
+
* **deps-dev:** update dependency mocha to v9.2.0 ([1566cb7](https://github.com/wmfs/asl-choice-processor/commit/1566cb75fffa6f2a37a6ca2c08ab79b5795d0365))
|
|
44
|
+
* **deps-dev:** update dependency mocha to v9.2.1 ([764cec8](https://github.com/wmfs/asl-choice-processor/commit/764cec85cb4dbcadd3c0b1c65624e0b4c0ec6ac1))
|
|
45
|
+
* **deps-dev:** update dependency mocha to v9.2.2 ([49f264e](https://github.com/wmfs/asl-choice-processor/commit/49f264e9a9e4d588ff649d42793027c7785f13b2))
|
|
46
|
+
* **deps-dev:** update dependency semantic-release to v17.4.5 ([d5847a0](https://github.com/wmfs/asl-choice-processor/commit/d5847a0ae6fe34f87157271645d09219980bf33d))
|
|
47
|
+
* **deps-dev:** update dependency semantic-release to v17.4.6 ([9e1eae6](https://github.com/wmfs/asl-choice-processor/commit/9e1eae62e7b59526d68054069a757c4a486dcc49))
|
|
48
|
+
* **deps-dev:** update dependency semantic-release to v17.4.7 ([3cc6787](https://github.com/wmfs/asl-choice-processor/commit/3cc6787c40a2410c6e7d979ae1b99528fe99f63d))
|
|
49
|
+
* **deps-dev:** update dependency semantic-release to v18 ([a2637ad](https://github.com/wmfs/asl-choice-processor/commit/a2637ad438cf3562130918cedefc67bb20994c26))
|
|
50
|
+
* **deps-dev:** update dependency semantic-release to v18.0.1 ([4fba981](https://github.com/wmfs/asl-choice-processor/commit/4fba9817255c605ffcdee3f39704bb5932aa2693))
|
|
51
|
+
* **deps-dev:** update dependency semantic-release to v19 ([5c5442f](https://github.com/wmfs/asl-choice-processor/commit/5c5442f7421dcaeab81c2de3d8aee113b02639ef))
|
|
52
|
+
* **deps-dev:** update dependency semantic-release to v19.0.3 ([a6747df](https://github.com/wmfs/asl-choice-processor/commit/a6747dfdc80b51e34b9b52427c52a4e09bf87f8f))
|
|
53
|
+
* **deps-dev:** update dependency standard to v16.0.4 ([d760224](https://github.com/wmfs/asl-choice-processor/commit/d760224bb33f2a964ed173a33c51fa290f60a9b8))
|
|
54
|
+
* **deps-dev:** update dependency standard to v17 ([56d5e3f](https://github.com/wmfs/asl-choice-processor/commit/56d5e3f059839530235ba16b657b7272e91b988b))
|
|
55
|
+
* **deps-dev:** update semantic-release monorepo ([bc62bcd](https://github.com/wmfs/asl-choice-processor/commit/bc62bcd1f225747199d6510f39a8cf46bfb238e6))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### ♻️ Chores
|
|
59
|
+
|
|
60
|
+
* add renovate config [ch6600] ([9de7776](https://github.com/wmfs/asl-choice-processor/commit/9de77760c6fa816550069d4f496d3cf68e23b086))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### 💎 Styles
|
|
64
|
+
|
|
65
|
+
* standard ([86c9d94](https://github.com/wmfs/asl-choice-processor/commit/86c9d9421b88b6463e91682d52497eb1e82a5e8a))
|
|
66
|
+
|
|
1
67
|
# [1.22.0](https://github.com/wmfs/asl-choice-processor/compare/v1.21.0...v1.22.0) (2021-05-11)
|
|
2
68
|
|
|
3
69
|
|
package/lib/operators/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
BooleanEquals: require('./boolean-equals'),
|
|
3
3
|
Includes: require('./includes'),
|
|
4
|
+
IsBoolean: require('./is-boolean'),
|
|
4
5
|
IsUndefined: require('./is-undefined'),
|
|
5
6
|
IsNull: require('./is-null'),
|
|
7
|
+
IsPresent: require('./is-present'),
|
|
8
|
+
IsString: require('./is-string'),
|
|
6
9
|
NumericEquals: require('./numeric-equals'),
|
|
7
10
|
NumericGreaterThan: require('./numeric-greater-than'),
|
|
8
11
|
NumericGreaterThanEquals: require('./numeric-greater-than-equals'),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module.exports = function isBooleanOperator (inputValue, comparisonValue, candidateStateName, cache) {
|
|
2
|
+
const isBoolean = typeof inputValue === 'boolean'
|
|
3
|
+
|
|
4
|
+
if (isBoolean && comparisonValue === true) {
|
|
5
|
+
return candidateStateName
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (!isBoolean && comparisonValue !== true) {
|
|
9
|
+
return candidateStateName
|
|
10
|
+
}
|
|
11
|
+
}
|
package/lib/operators/is-null.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = function isNullOperator (inputValue, comparisonValue, candidateStateName, cache) {
|
|
4
|
-
|
|
4
|
+
const isNull = inputValue === null
|
|
5
5
|
|
|
6
|
-
if (
|
|
7
|
-
|
|
8
|
-
} else if (!comparisonValue && inputValue !== null) {
|
|
9
|
-
nextState = candidateStateName
|
|
6
|
+
if (isNull && comparisonValue === true) {
|
|
7
|
+
return candidateStateName
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
if (!isNull && comparisonValue !== true) {
|
|
11
|
+
return candidateStateName
|
|
12
|
+
}
|
|
13
13
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = function isStringOperator (inputValue, comparisonValue, candidateStateName, cache) {
|
|
4
|
+
const isString = typeof inputValue === 'string'
|
|
5
|
+
|
|
6
|
+
if (isString && comparisonValue === true) {
|
|
7
|
+
return candidateStateName
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (!isString && comparisonValue !== true) {
|
|
11
|
+
return candidateStateName
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = function isUndefinedOperator (inputValue, comparisonValue, candidateStateName, cache) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
4
|
+
const isUndefined = inputValue === undefined
|
|
5
|
+
|
|
6
|
+
if (isUndefined && comparisonValue === true) {
|
|
7
|
+
return candidateStateName
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (!isUndefined && comparisonValue !== true) {
|
|
11
|
+
return candidateStateName
|
|
13
12
|
}
|
|
14
|
-
return nextState
|
|
15
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wmfs/asl-choice-processor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "For determining the next state given an Amazon States Language 'Choices' definition and a set of values.",
|
|
5
5
|
"author": "West Midlands Fire Service",
|
|
6
6
|
"homepage": "https://github.com/wmfs/asl-choice-processor#readme",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"lodash": "4.17.21"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"chai": "4.3.
|
|
27
|
-
"codecov": "3.8.
|
|
26
|
+
"chai": "4.3.6",
|
|
27
|
+
"codecov": "3.8.3",
|
|
28
28
|
"conventional-changelog-metahub": "4.0.1",
|
|
29
29
|
"cz-conventional-changelog": "3.3.0",
|
|
30
|
-
"mocha": "
|
|
30
|
+
"mocha": "10.0.0",
|
|
31
31
|
"nyc": "15.1.0",
|
|
32
|
-
"semantic-release": "
|
|
33
|
-
"standard": "
|
|
34
|
-
"@semantic-release/changelog": "
|
|
35
|
-
"@semantic-release/git": "
|
|
32
|
+
"semantic-release": "19.0.3",
|
|
33
|
+
"standard": "17.0.0",
|
|
34
|
+
"@semantic-release/changelog": "6.0.1",
|
|
35
|
+
"@semantic-release/git": "10.0.1"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"lint": "standard",
|
package/renovate.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"config:base"
|
|
4
|
+
],
|
|
5
|
+
"dependencyDashboard": true,
|
|
6
|
+
"enabledManagers": ["npm"],
|
|
7
|
+
"packageRules": [
|
|
8
|
+
{
|
|
9
|
+
"matchDepTypes": ["devDependencies"],
|
|
10
|
+
"automerge": true,
|
|
11
|
+
"semanticCommitType": "build",
|
|
12
|
+
"semanticCommitScope": "deps-dev",
|
|
13
|
+
"labels": ["devDependencies"]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"matchDepTypes": ["dependencies"],
|
|
17
|
+
"semanticCommitType": "build",
|
|
18
|
+
"semanticCommitScope": "deps",
|
|
19
|
+
"labels": ["dependencies"],
|
|
20
|
+
"reviewers": ["team:tymly-reviewers"]
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"vulnerabilityAlerts": {
|
|
24
|
+
"labels": ["security"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -67,9 +67,50 @@ const tests = {
|
|
|
67
67
|
IsNull: [
|
|
68
68
|
[null, true, 'NextState'],
|
|
69
69
|
['HELLO_WORLD', false, 'NextState'],
|
|
70
|
+
[undefined, false, 'NextState'],
|
|
71
|
+
[0, false, 'NextState'],
|
|
72
|
+
[false, false, 'NextState'],
|
|
70
73
|
|
|
71
74
|
[null, false, 'DefaultState'],
|
|
72
|
-
['HELLO_WORLD', true, 'DefaultState']
|
|
75
|
+
['HELLO_WORLD', true, 'DefaultState'],
|
|
76
|
+
[undefined, true, 'DefaultState'],
|
|
77
|
+
[0, true, 'DefaultState'],
|
|
78
|
+
[false, true, 'DefaultState']
|
|
79
|
+
],
|
|
80
|
+
IsUndefined: [
|
|
81
|
+
[undefined, true, 'NextState'],
|
|
82
|
+
['HELLO_WORLD', false, 'NextState'],
|
|
83
|
+
[null, false, 'NextState'],
|
|
84
|
+
[0, false, 'NextState'],
|
|
85
|
+
[false, false, 'NextState'],
|
|
86
|
+
|
|
87
|
+
[undefined, false, 'DefaultState'],
|
|
88
|
+
['HELLO_WORLD', true, 'DefaultState'],
|
|
89
|
+
[null, true, 'DefaultState'],
|
|
90
|
+
[0, true, 'DefaultState'],
|
|
91
|
+
[false, true, 'DefaultState']
|
|
92
|
+
],
|
|
93
|
+
IsBoolean: [
|
|
94
|
+
['nope', false, 'NextState'],
|
|
95
|
+
[true, true, 'NextState'],
|
|
96
|
+
[false, true, 'NextState'],
|
|
97
|
+
|
|
98
|
+
['nope', true, 'DefaultState'],
|
|
99
|
+
[true, false, 'DefaultState'],
|
|
100
|
+
[false, false, 'DefaultState']
|
|
101
|
+
],
|
|
102
|
+
IsString: [
|
|
103
|
+
['yep', true, 'NextState'],
|
|
104
|
+
[0, false, 'NextState'],
|
|
105
|
+
[true, false, 'NextState'],
|
|
106
|
+
[undefined, false, 'NextState'],
|
|
107
|
+
[null, false, 'NextState'],
|
|
108
|
+
|
|
109
|
+
['yep', false, 'DefaultState'],
|
|
110
|
+
[0, true, 'DefaultState'],
|
|
111
|
+
[true, true, 'DefaultState'],
|
|
112
|
+
[undefined, true, 'DefaultState'],
|
|
113
|
+
[null, true, 'DefaultState']
|
|
73
114
|
]
|
|
74
115
|
}
|
|
75
116
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
|
|
3
|
+
'use strict'
|
|
4
|
+
|
|
5
|
+
const chai = require('chai')
|
|
6
|
+
const expect = chai.expect
|
|
7
|
+
|
|
8
|
+
const choiceProcessor = require('./../lib')
|
|
9
|
+
|
|
10
|
+
const tests = {
|
|
11
|
+
Not: [
|
|
12
|
+
{
|
|
13
|
+
choices: {
|
|
14
|
+
Choices: [
|
|
15
|
+
{
|
|
16
|
+
Not: {
|
|
17
|
+
Variable: '$.notPresent',
|
|
18
|
+
IsPresent: true
|
|
19
|
+
},
|
|
20
|
+
Next: 'NextState'
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
Default: 'DefaultState'
|
|
24
|
+
},
|
|
25
|
+
input: { type: 'Public' },
|
|
26
|
+
expected: 'NextState'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
choices: {
|
|
30
|
+
Choices: [
|
|
31
|
+
{
|
|
32
|
+
Not: {
|
|
33
|
+
Variable: '$.type',
|
|
34
|
+
IsPresent: false
|
|
35
|
+
},
|
|
36
|
+
Next: 'NextState'
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
Default: 'DefaultState'
|
|
40
|
+
},
|
|
41
|
+
input: { type: 'Public' },
|
|
42
|
+
expected: 'NextState'
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
And: [
|
|
46
|
+
{
|
|
47
|
+
choices: {
|
|
48
|
+
Choices: [
|
|
49
|
+
{
|
|
50
|
+
And: [
|
|
51
|
+
{
|
|
52
|
+
Variable: '$.value',
|
|
53
|
+
IsPresent: true
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
Variable: '$.name',
|
|
57
|
+
IsPresent: true
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
Next: 'NextState'
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
Default: 'DefaultState'
|
|
64
|
+
},
|
|
65
|
+
input: { value: 21, name: 'age' },
|
|
66
|
+
expected: 'NextState'
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
Or: [
|
|
70
|
+
{
|
|
71
|
+
choices: {
|
|
72
|
+
Choices: [
|
|
73
|
+
{
|
|
74
|
+
Or: [
|
|
75
|
+
{
|
|
76
|
+
Variable: '$.value',
|
|
77
|
+
IsPresent: true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
Variable: '$.name',
|
|
81
|
+
IsPresent: true
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
Next: 'NextState'
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
Default: 'DefaultState'
|
|
88
|
+
},
|
|
89
|
+
input: { value: 22 },
|
|
90
|
+
expected: 'NextState'
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
choices: {
|
|
94
|
+
Choices: [
|
|
95
|
+
{
|
|
96
|
+
Or: [
|
|
97
|
+
{
|
|
98
|
+
Variable: '$.value',
|
|
99
|
+
NumericGreaterThan: 22
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
Variable: '$.value',
|
|
103
|
+
NumericLessThan: 25
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
Next: 'NextState'
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
Default: 'DefaultState'
|
|
110
|
+
},
|
|
111
|
+
input: { value: 25 },
|
|
112
|
+
expected: 'NextState'
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
Mixed: [
|
|
116
|
+
{
|
|
117
|
+
choices: {
|
|
118
|
+
Choices: [
|
|
119
|
+
{
|
|
120
|
+
Not: {
|
|
121
|
+
Variable: '$.type',
|
|
122
|
+
StringEquals: 'Private'
|
|
123
|
+
},
|
|
124
|
+
Next: 'Public'
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
And: [
|
|
128
|
+
{
|
|
129
|
+
Variable: '$.value',
|
|
130
|
+
IsPresent: true
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
Variable: '$.type',
|
|
134
|
+
IsPresent: true
|
|
135
|
+
}
|
|
136
|
+
],
|
|
137
|
+
Next: 'ValueInTwenties'
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
Default: 'RecordEvent'
|
|
141
|
+
},
|
|
142
|
+
input: { type: 'Private', value: 22 },
|
|
143
|
+
expected: 'ValueInTwenties'
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
describe('IsPresent expression', () => {
|
|
149
|
+
for (const [operator, t] of Object.entries(tests)) {
|
|
150
|
+
describe(operator, () => {
|
|
151
|
+
let i = 0
|
|
152
|
+
for (const { choices, input, expected } of t) {
|
|
153
|
+
i++
|
|
154
|
+
it(`${i}`, () => {
|
|
155
|
+
const calculateNextState = choiceProcessor(choices)
|
|
156
|
+
const result = calculateNextState(input)
|
|
157
|
+
expect(result).to.eql(expected)
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
}
|
|
162
|
+
})
|