/
jyson.example.spec.js
49 lines (45 loc) · 1.26 KB
/
jyson.example.spec.js
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
const jyson = require('./../../../lib/jyson');
describe('jyson.example.spec: an example', () => {
beforeEach(() => {
this.productTemplateFunction = jyson.buildTemplateFunction({
name: 'name',
tags: ['meta.tags.$'],
other: {
dogRating: 'meta.rating',
exampleMissingValue: 'notFound',
dateRan: ({ templateOpts }) => templateOpts.dateRan
},
});
});
it('must output example "json"', () => {
const input = {
name: 'Bacon Peanut Butter “Ice Cream” for Dogs',
meta: {
rating: 10,
tags: [
'lactobacillus bulgaricus',
'enterocococcus thermophilus',
'lactobacillus acidophilus',
'bifidobacterium bifidum',
'lactobacillus casei'
]
}
};
const json = this.productTemplateFunction(input, { dateRan: 1496351371149 });
expect(json).toEqual({
name: 'Bacon Peanut Butter “Ice Cream” for Dogs',
tags:[
'lactobacillus bulgaricus',
'enterocococcus thermophilus',
'lactobacillus acidophilus',
'bifidobacterium bifidum',
'lactobacillus casei'
],
other: {
dogRating: 10,
exampleMissingValue: null,
dateRan: 1496351371149
}
});
});
});