forked from cubyn/gumgum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
53 lines (41 loc) · 1.42 KB
/
test.js
File metadata and controls
53 lines (41 loc) · 1.42 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
43
44
45
46
47
48
49
50
51
52
53
const { expect } = require('chai');
const g = require('.');
describe('Gumgum', () => {
it('Must work', () => {
const nin = g.must({ hello: 'world' });
expect(nin.compile()).to.deep.equal({ must: { hello: 'world' } });
});
it('must handle results of other gumgum functions', () => {
const nin = g.must(g.should({ hello: 'world' }));
expect(nin.compile()).to.deep.equal({ must: { should: { hello: 'world' } } });
});
it('Multiple params', () => {
const nin = g.must(
g.should({ hello: 'world' }),
g.mustNot({ say: 'hello' })
);
expect(nin.compile()).to.deep.equal({
must: {
should: { hello: 'world' },
must_not: { say: 'hello' },
}
});
});
it('argument of type array', () => {
const obj = [{ hello: 'world' }];
const nin = g.should(obj);
expect(nin.compile()).to.deep.equal({ should: obj });
});
it('argument of type array with a length > 1', () => {
const obj = [{ hello: 'world' }, { salut: 'bonjour' }]
const nin = g.should(obj);
expect(nin.compile()).to.deep.equal({ should: obj });
});
it('chains', () => {
const obj = { hello: 'world' };
const nin = g().should.bool.must(obj);
expect(nin.compile()).to.deep.equal({
should: { bool: { must: obj } }
});
});
});