-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
73 lines (49 loc) · 1.17 KB
/
test.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
const dirz = require( './index' )
test( 'get with default value', () =>
{
expect( dirz.get( 'default value', 'value' ) ).toBe( 'value' )
}
)
test( 'set and get default type', () =>
{
dirz.set( 'default type', 'value' )
expect( dirz.get( 'default type' ) ).toBe( 'value' )
}
)
test( 'set and get string', () =>
{
dirz.set( 'string value', 2, 'string' )
expect( dirz.get( 'string value' ) ).toBe( '2' )
}
)
test( 'set and get invalid string', () =>
{
dirz.set( 'invalid string value', null, 'string' )
expect( dirz.get( 'invalid string value' ) ).toBe( null )
}
)
test( 'set and get int', () =>
{
dirz.set( 'int value', 2.1, 'int' )
expect( dirz.get( 'int value' ) ).toBe( 2 )
}
)
test( 'set and get float', () =>
{
dirz.set( 'float value', '2.1', 'float' )
expect( dirz.get( 'float value' ) ).toBe( 2.1 )
}
)
test( 'set and get bool', () =>
{
dirz.set( 'bool value', 'false', 'bool' )
expect( dirz.get( 'bool value' ) ).toBe( false )
}
)
test( 'remove key', () =>
{
dirz.set( 'remove key', 'value' )
dirz.remove( 'remove key' )
expect( dirz.get( 'remove key' ) ).toBe( null )
}
)