-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpression-stringifier.js
More file actions
42 lines (38 loc) · 1.24 KB
/
Copy pathexpression-stringifier.js
File metadata and controls
42 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { assert } from 'chai'
import { stringifyExpression } from '../lib/expression-stringifier.js'
import JSONway from '../index.js'
describe('expression-stringifier', () => {
it('stringifyExpression does nothing if not path-array', function () {
const input = '5 > 10'
assert.deepEqual(stringifyExpression(input), input)
})
const expressions = [
'ab.cd != 12',
`ab[0] > 'foo'`,
'ab.cd > 12 && (cd != 10)',
`ab.cd = 12 || (cd.ab != 13) && (ba.dc = 'foo') && (ba.dc != ab.cd)`,
`ab = [1, 'a', 0, b] && (d.b != ['error', false, null, ab.cd])`,
'7 + 10 - 2 > 12',
'7 + 10 - 5 + 1 + (-5 - 3 * 1) + 3',
'ab.cd = 12 && (cd.ab = 13)',
'ab.cd = 12 || (cd.ab != 13)',
`x ~= 'bar'`,
'x = $ || (y = $)',
'15 >= [11, 17, 20]',
`c[].d = 'a2'`,
`'bfoor' ~= ['baz', 'bar', 'foo']`,
'aa ?| bb ?| cc ?| 15',
'?',
'> 15',
`aa.bb.cc = 'xx' && (dd.ee[0].ff = ['gg', 'hh'])`,
]
/* eslint-disable mocha/no-setup-in-describe */
expressions.forEach(expression => {
//
it(expression, function () {
const input = JSONway.parseExpression(this.test.title)
assert.deepEqual(stringifyExpression(input), this.test.title)
})
})
/* eslint-enable mocha/no-setup-in-describe */
})