-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
68 lines (63 loc) · 1.51 KB
/
test.js
File metadata and controls
68 lines (63 loc) · 1.51 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import c from './index'
describe('Constant-Factory', () => {
it('returns a object', () => {
expect(c()).to.be.a('object')
})
describe('Simple mode', () => {
it('returns a object with generated constant with one item', () => {
expect(c('TODO', ['ITEM'])).to.deep.equal({
ITEM: 'TODO_ITEM'
})
})
it('returns a object with generated constant with multiple items', () => {
expect(c('TODO', ['ITEM', 'POST', 'HELLO'])).to.deep.equal({
ITEM: 'TODO_ITEM',
POST: 'TODO_POST',
HELLO: 'TODO_HELLO'
})
})
})
describe('Advanced mode', () => {
it('returns a deep object with assigned constants and constant-entries', () => {
expect(c({
FOO: ['BAR'],
HELLO: ['WORLD'],
THIS: ['IS', 'A', 'DEEP', 'TEST']
})).to.deep.equal({
FOO: {
BAR: 'FOO_BAR'
},
HELLO: {
WORLD: 'HELLO_WORLD'
},
THIS: {
IS: 'THIS_IS',
A: 'THIS_A',
DEEP: 'THIS_DEEP',
TEST: 'THIS_TEST'
}
})
})
})
describe('Expert mode', () => {
it('returns a deeper object with arrays with sub-arrays', () => {
expect(c({
SINGLE: 'ITEM',
FOO: [
'BAR',
{'HELLO': [
'WORLD'
]}
]
})).to.deep.equal({
SINGLE: 'SINGLE_ITEM',
FOO: {
BAR: 'FOO_BAR',
HELLO: {
WORLD: 'FOO_HELLO_WORLD'
}
}
})
})
})
})