1
|
|
|
import { assert } from 'chai'; |
2
|
|
|
import { snippetTester } from 'tests/utils'; |
3
|
|
|
|
4
|
|
|
suite('InclusiveFilter'); |
5
|
|
|
|
6
|
|
|
test('Positive: no intersections @example', async function () { |
7
|
|
|
await snippetTester.test(({ InclusiveFilter }) => { |
8
|
|
|
const filter = new InclusiveFilter({ |
9
|
|
|
include : [ 1, 2, 3 ], |
10
|
|
|
exclude : [ 4, 5 ] |
11
|
|
|
}); |
12
|
|
|
|
13
|
|
|
assert.isTrue(filter.run(2)); |
14
|
|
|
assert.isFalse(filter.run(4)); |
15
|
|
|
}); |
16
|
|
|
}); |
17
|
|
|
|
18
|
|
|
test('Positive: conflicts @example', async function () { |
19
|
|
|
await snippetTester.test(({ InclusiveFilter }) => { |
20
|
|
|
const filter = new InclusiveFilter({ |
21
|
|
|
include : [ 1, 2, 3 ], |
22
|
|
|
exclude : [ 3, 4 ], |
23
|
|
|
conflict : '$conflict', |
24
|
|
|
neither : '$neither' |
25
|
|
|
}); |
26
|
|
|
|
27
|
|
|
assert.equal(filter.run(3), '$conflict'); |
28
|
|
|
assert.equal(filter.run(6), '$neither'); |
29
|
|
|
}); |
30
|
|
|
}); |
31
|
|
|
|
32
|
|
|
test('Positive: empty filter @example', async function () { |
33
|
|
|
await snippetTester.test(({ InclusiveFilter }) => { |
34
|
|
|
const filter = new InclusiveFilter({ |
35
|
|
|
pass : '$pass' |
36
|
|
|
}); |
37
|
|
|
|
38
|
|
|
assert.equal(filter.run(1), '$pass'); |
39
|
|
|
}); |
40
|
|
|
}); |
41
|
|
|
|
42
|
|
|
test('Positive: explicit include @example', async function () { |
43
|
|
|
await snippetTester.test(({ InclusiveFilter }) => { |
44
|
|
|
const filter = new InclusiveFilter({ |
45
|
|
|
include : [ 1, 2, 3 ] |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
assert.isTrue(filter.run(1)); |
49
|
|
|
assert.isFalse(filter.run(4)); |
50
|
|
|
}); |
51
|
|
|
}); |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
test('Positive: explicit exlude @example', async function () { |
55
|
|
|
await snippetTester.test(({ InclusiveFilter }) => { |
56
|
|
|
const filter = new InclusiveFilter({ |
57
|
|
|
exclude : [ 1, 2, 3 ] |
58
|
|
|
}); |
59
|
|
|
|
60
|
|
|
assert.isFalse(filter.run(1)); |
61
|
|
|
assert.isTrue(filter.run(4)); |
62
|
|
|
}); |
63
|
|
|
}); |
64
|
|
|
|