|
1
|
|
|
import test from 'ava'; |
|
2
|
|
|
import join from '../../src/uri/join'; |
|
3
|
|
|
|
|
4
|
|
|
test('empty path', t => { |
|
5
|
|
|
|
|
6
|
|
|
t.is( |
|
7
|
|
|
join(), |
|
8
|
|
|
'/' |
|
9
|
|
|
); |
|
10
|
|
|
}); |
|
11
|
|
|
|
|
12
|
|
|
test('path with null', t => { |
|
13
|
|
|
t.is( |
|
14
|
|
|
join('path', 'with', null), |
|
15
|
|
|
'path/with' |
|
16
|
|
|
); |
|
17
|
|
|
}); |
|
18
|
|
|
|
|
19
|
|
|
test('path with boolean', t => { |
|
20
|
|
|
t.is( |
|
21
|
|
|
join('path', 'with', false), |
|
22
|
|
|
'path/with', |
|
23
|
|
|
'false' |
|
24
|
|
|
); |
|
25
|
|
|
|
|
26
|
|
|
t.is( |
|
27
|
|
|
join('path', 'with', true), |
|
28
|
|
|
'path/with/true', |
|
29
|
|
|
'true' |
|
30
|
|
|
); |
|
31
|
|
|
}); |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
test('path with numbers', t => { |
|
35
|
|
|
t.is( |
|
36
|
|
|
join('path', 'with', 1), |
|
37
|
|
|
'path/with/1', |
|
38
|
|
|
'1' |
|
39
|
|
|
); |
|
40
|
|
|
|
|
41
|
|
|
t.is( |
|
42
|
|
|
join('path', 'with', 0), |
|
43
|
|
|
'path/with/0', |
|
44
|
|
|
'0' |
|
45
|
|
|
); |
|
46
|
|
|
|
|
47
|
|
|
t.is( |
|
48
|
|
|
join('path', 'with', Infinity), |
|
49
|
|
|
'path/with/Infinity', |
|
50
|
|
|
'Infinity' |
|
51
|
|
|
); |
|
52
|
|
|
|
|
53
|
|
|
t.is( |
|
54
|
|
|
join('path', 'with', NaN), |
|
55
|
|
|
'path/with', |
|
56
|
|
|
'NaN' |
|
57
|
|
|
); |
|
58
|
|
|
}); |
|
59
|
|
|
|
|
60
|
|
|
test('path with undefined', t => { |
|
61
|
|
|
t.is( |
|
62
|
|
|
join('path', 'with', undefined), |
|
63
|
|
|
'path/with' |
|
64
|
|
|
); |
|
65
|
|
|
}); |
|
66
|
|
|
|
|
67
|
|
|
test('path with slashes', t => { |
|
68
|
|
|
t.is( |
|
69
|
|
|
join('/path//', '//with/', '///slashes'), |
|
70
|
|
|
'/path/with/slashes', |
|
71
|
|
|
'slashes' |
|
72
|
|
|
); |
|
73
|
|
|
|
|
74
|
|
|
t.is( |
|
75
|
|
|
join('/path//', '//with/', '///more///slashes///'), |
|
76
|
|
|
'/path/with/more/slashes/', |
|
77
|
|
|
'more slashes' |
|
78
|
|
|
); |
|
79
|
|
|
}); |
|
80
|
|
|
|
|
81
|
|
|
test('path with array', t => { |
|
82
|
|
|
t.is( |
|
83
|
|
|
join('path', 'with', []), |
|
84
|
|
|
'path/with', |
|
85
|
|
|
'empty array' |
|
86
|
|
|
); |
|
87
|
|
|
|
|
88
|
|
|
t.is( |
|
89
|
|
|
join('path', 'with', ['t', 'e', 's', 't']), |
|
90
|
|
|
'path/with/t,e,s,t', |
|
91
|
|
|
'regular array' |
|
92
|
|
|
); |
|
93
|
|
|
}); |
|
94
|
|
|
|
|
95
|
|
|
test('path with object', t => { |
|
96
|
|
|
t.is( |
|
97
|
|
|
join('path', 'with', {}), |
|
98
|
|
|
'path/with/[object Object]' |
|
99
|
|
|
); |
|
100
|
|
|
}); |
|
101
|
|
|
|
|
102
|
|
|
test('path with regexp', t => { |
|
103
|
|
|
t.is( |
|
104
|
|
|
join('path', 'with', /^$/), |
|
105
|
|
|
'path/with/^$/' |
|
106
|
|
|
); |
|
107
|
|
|
}); |