render-script 0.0.1 → 0.0.2
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/package.json +6 -4
- package/test/.eslintrc +5 -0
- package/test/index.spec.mjs +302 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "render-script",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"main": "./lib/index.cjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint . --ext .cjs --ext .mjs",
|
|
18
18
|
"lint:fix": "npm run lint -- --fix",
|
|
19
|
+
"test": "cross-env NODE_ENV=test mocha test --recursive --verbose --color",
|
|
19
20
|
"clean": "rimraf lib",
|
|
20
21
|
"build": "npm run babel",
|
|
21
22
|
"babel": "babel src -d lib --out-file-extension .cjs",
|
|
@@ -32,19 +33,20 @@
|
|
|
32
33
|
"@babel/eslint-parser": "^7.15.8",
|
|
33
34
|
"@babel/preset-env": "^7.15.8",
|
|
34
35
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
36
|
+
"chai": "^4.3.4",
|
|
35
37
|
"core-js": "^3.18.3",
|
|
38
|
+
"cross-env": "^7.0.3",
|
|
36
39
|
"eslint": "7.12.1",
|
|
37
40
|
"eslint-config-standard": "^16.0.3",
|
|
38
41
|
"eslint-import-resolver-babel-module": "^5.3.1",
|
|
39
42
|
"eslint-plugin-import": "^2.25.2",
|
|
43
|
+
"eslint-plugin-mocha": "^9.0.0",
|
|
40
44
|
"eslint-plugin-node": "^11.1.0",
|
|
41
45
|
"eslint-plugin-promise": "^5.1.0",
|
|
42
46
|
"husky": "^7.0.2",
|
|
47
|
+
"mocha": "^9.1.3",
|
|
43
48
|
"rimraf": "^3.0.2"
|
|
44
49
|
},
|
|
45
|
-
"imports": {
|
|
46
|
-
"#~": "./src/index.mjs"
|
|
47
|
-
},
|
|
48
50
|
"exports": {
|
|
49
51
|
"import": "./src/index.mjs",
|
|
50
52
|
"require": "./lib/index.cjs"
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import {
|
|
2
|
+
expect
|
|
3
|
+
} from 'chai'
|
|
4
|
+
|
|
5
|
+
import evaluate, {
|
|
6
|
+
evaluateRuleForConfiguration,
|
|
7
|
+
getRuleMap,
|
|
8
|
+
getConfigurationMap,
|
|
9
|
+
getEvaluation
|
|
10
|
+
} from 'render-script'
|
|
11
|
+
|
|
12
|
+
describe('~', () => {
|
|
13
|
+
describe('`evaluate`', () => {
|
|
14
|
+
it('is a function', () => {
|
|
15
|
+
return expect(evaluate)
|
|
16
|
+
.to.be.a('function')
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
describe('`evaluateRuleForConfiguration`', () => {
|
|
21
|
+
it('is a function', () => {
|
|
22
|
+
return expect(evaluateRuleForConfiguration)
|
|
23
|
+
.to.be.a('function')
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
describe('`getRuleMap`', () => {
|
|
28
|
+
it('is a function', () => {
|
|
29
|
+
return expect(getRuleMap)
|
|
30
|
+
.to.be.a('function')
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
describe('`getConfigurationMap`', () => {
|
|
35
|
+
it('is a function', () => {
|
|
36
|
+
return expect(getConfigurationMap)
|
|
37
|
+
.to.be.a('function')
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('`getEvaluation`', () => {
|
|
42
|
+
it('is a function', () => {
|
|
43
|
+
return expect(getEvaluation)
|
|
44
|
+
.to.be.a('function')
|
|
45
|
+
})
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
describe('`evaluate()`', () => {
|
|
49
|
+
describe('`rule` has rules', () => {
|
|
50
|
+
describe('`configuration` has configuration', () => {
|
|
51
|
+
describe('`configuration` has a match', () => {
|
|
52
|
+
it('returns true', () => {
|
|
53
|
+
return expect(evaluate('+A', '+A'))
|
|
54
|
+
.to.be.true
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
describe('`configuration` does not have a match', () => {
|
|
59
|
+
it('returns false', () => {
|
|
60
|
+
return expect(evaluate('+B', '+A'))
|
|
61
|
+
.to.be.false
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('Every rule must be true', () => {
|
|
66
|
+
describe('`configuration` has a combination match', () => {
|
|
67
|
+
it('returns true', () => {
|
|
68
|
+
return expect(evaluate('+1/2/3+A+4/5/6+B', '+1+6+A+B'))
|
|
69
|
+
.to.be.true
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
describe('`configuration` does not have a combination match', () => {
|
|
74
|
+
it('returns false', () => {
|
|
75
|
+
return expect(evaluate('+1/2/3+A+4/5/6+B', '+6+A'))
|
|
76
|
+
.to.be.false
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
describe('`configuration` has a negation match', () => {
|
|
81
|
+
it('returns false', () => {
|
|
82
|
+
return expect(evaluate('+1/2/3+A+4/5/6+!B', '+1+6+A+B'))
|
|
83
|
+
.to.be.false
|
|
84
|
+
})
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
describe('`configuration` does not have a negation match', () => {
|
|
88
|
+
it('returns true', () => {
|
|
89
|
+
return expect(evaluate('+1/2/3+A+4/5/6+!C', '+1+6+A+B'))
|
|
90
|
+
.to.be.true
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
describe('At least one rule must be true', () => {
|
|
96
|
+
describe('`configuration` has a combination match', () => {
|
|
97
|
+
it('returns true', () => {
|
|
98
|
+
return expect(evaluate('+1/2/3+A;+4/5/6+B', '+6+B'))
|
|
99
|
+
.to.be.true
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
describe('`configuration` does not have a combination match', () => {
|
|
104
|
+
it('returns false', () => {
|
|
105
|
+
return expect(evaluate('+1/2/3+A;+4/5/6+B', '+6+A'))
|
|
106
|
+
.to.be.false
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
describe('`configuration` has a negation match', () => {
|
|
111
|
+
it('returns false', () => {
|
|
112
|
+
return expect(evaluate('+!A;+!B', '+1+6+A+B'))
|
|
113
|
+
.to.be.false
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
describe('`configuration` does not have a negation match', () => {
|
|
118
|
+
it('returns true', () => {
|
|
119
|
+
return expect(evaluate('+1/2/3+A;!B', '+1+6+A+B'))
|
|
120
|
+
.to.be.true
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
describe('`configuration` has a negation match in combination', () => {
|
|
125
|
+
it('returns false', () => {
|
|
126
|
+
return expect(evaluate('+1/2/3+A;+4/5/6+B;+7/8/9+C;+!A+!B+!C', '+C'))
|
|
127
|
+
.to.be.false
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
describe('`configuration` does not have a negation match in combination', () => {
|
|
132
|
+
it('returns true', () => {
|
|
133
|
+
return expect(evaluate('+1/2/3+A;+4/5/6+B;+7/8/9+C;+!A+!B+!C;', '+9+C'))
|
|
134
|
+
.to.be.true
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
describe('`configuration` does not have configuration', () => {
|
|
141
|
+
it('returns false', () => {
|
|
142
|
+
return expect(evaluate('+A'))
|
|
143
|
+
.to.be.false
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
describe('`rule` does not have rules', () => {
|
|
149
|
+
describe('`configuration` has configuration', () => {
|
|
150
|
+
it('returns false', () => {
|
|
151
|
+
return expect(evaluate('', '+A'))
|
|
152
|
+
.to.be.false
|
|
153
|
+
})
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
describe('`configuration` does not have configuration', () => {
|
|
157
|
+
it('returns false', () => {
|
|
158
|
+
return expect(evaluate())
|
|
159
|
+
.to.be.false
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
describe('`getRuleMap()`', () => {
|
|
166
|
+
it('is a `Map`', () => {
|
|
167
|
+
return expect(getRuleMap())
|
|
168
|
+
.to.be.an.instanceof(Map)
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
describe('`getConfigurationMap`', () => {
|
|
173
|
+
it('is a `Map`', () => {
|
|
174
|
+
return expect(getConfigurationMap())
|
|
175
|
+
.to.be.an.instanceof(Map)
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
describe('`getEvaluation`', () => {
|
|
180
|
+
it('returns false', () => {
|
|
181
|
+
return expect(getEvaluation())
|
|
182
|
+
.to.be.false
|
|
183
|
+
})
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
describe('`evaluateRuleForConfiguration()`', () => {
|
|
187
|
+
describe('`rule` has rules', () => {
|
|
188
|
+
describe('`configuration` has configuration', () => {
|
|
189
|
+
describe('`configuration` has a match', () => {
|
|
190
|
+
it('returns true', () => {
|
|
191
|
+
return expect(evaluateRuleForConfiguration('+A', '+A'))
|
|
192
|
+
.to.be.true
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
describe('`configuration` does not have a match', () => {
|
|
197
|
+
it('returns false', () => {
|
|
198
|
+
return expect(evaluateRuleForConfiguration('+B', '+A'))
|
|
199
|
+
.to.be.false
|
|
200
|
+
})
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
describe('Every rule must be true', () => {
|
|
204
|
+
describe('`configuration` has a combination match', () => {
|
|
205
|
+
it('returns true', () => {
|
|
206
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A+4/5/6+B', '+1+6+A+B'))
|
|
207
|
+
.to.be.true
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
describe('`configuration` does not have a combination match', () => {
|
|
212
|
+
it('returns false', () => {
|
|
213
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A+4/5/6+B', '+6+A'))
|
|
214
|
+
.to.be.false
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
describe('`configuration` has a negation match', () => {
|
|
219
|
+
it('returns false', () => {
|
|
220
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A+4/5/6+!B', '+1+6+A+B'))
|
|
221
|
+
.to.be.false
|
|
222
|
+
})
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
describe('`configuration` does not have a negation match', () => {
|
|
226
|
+
it('returns true', () => {
|
|
227
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A+4/5/6+!C', '+1+6+A+B'))
|
|
228
|
+
.to.be.true
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
describe('At least one rule must be true', () => {
|
|
234
|
+
describe('`configuration` has a combination match', () => {
|
|
235
|
+
it('returns true', () => {
|
|
236
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A;+4/5/6+B', '+6+B'))
|
|
237
|
+
.to.be.true
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
describe('`configuration` does not have a combination match', () => {
|
|
242
|
+
it('returns false', () => {
|
|
243
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A;+4/5/6+B', '+6+A'))
|
|
244
|
+
.to.be.false
|
|
245
|
+
})
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
describe('`configuration` has a negation match', () => {
|
|
249
|
+
it('returns false', () => {
|
|
250
|
+
return expect(evaluateRuleForConfiguration('+!A;+!B', '+1+6+A+B'))
|
|
251
|
+
.to.be.false
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
describe('`configuration` does not have a negation match', () => {
|
|
256
|
+
it('returns true', () => {
|
|
257
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A;!B', '+1+6+A+B'))
|
|
258
|
+
.to.be.true
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
describe('`configuration` has a negation match in combination', () => {
|
|
263
|
+
it('returns false', () => {
|
|
264
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A;+4/5/6+B;+7/8/9+C;+!A+!B+!C', '+C'))
|
|
265
|
+
.to.be.false
|
|
266
|
+
})
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
describe('`configuration` does not have a negation match in combination', () => {
|
|
270
|
+
it('returns true', () => {
|
|
271
|
+
return expect(evaluateRuleForConfiguration('+1/2/3+A;+4/5/6+B;+7/8/9+C;+!A+!B+!C;', '+9+C'))
|
|
272
|
+
.to.be.true
|
|
273
|
+
})
|
|
274
|
+
})
|
|
275
|
+
})
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
describe('`configuration` does not have configuration', () => {
|
|
279
|
+
it('returns false', () => {
|
|
280
|
+
return expect(evaluateRuleForConfiguration('+A'))
|
|
281
|
+
.to.be.false
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
describe('`rule` does not have rules', () => {
|
|
287
|
+
describe('`configuration` has configuration', () => {
|
|
288
|
+
it('returns false', () => {
|
|
289
|
+
return expect(evaluateRuleForConfiguration('', '+A'))
|
|
290
|
+
.to.be.false
|
|
291
|
+
})
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
describe('`configuration` does not have configuration', () => {
|
|
295
|
+
it('returns false', () => {
|
|
296
|
+
return expect(evaluateRuleForConfiguration())
|
|
297
|
+
.to.be.false
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
})
|