@@ -2,6 +2,9 @@ import t from 'tap'
2
2
import glob from '../'
3
3
4
4
import { resolve } from 'path'
5
+ import { sep } from 'path'
6
+ const alphasort = ( a :string , b :string ) => a . localeCompare ( b , 'en' )
7
+ const j = ( a : string [ ] ) => a . map ( s => s . split ( '/' ) . join ( sep ) ) . sort ( alphasort )
5
8
6
9
const fixtureDir = resolve ( __dirname , 'fixtures' )
7
10
@@ -12,18 +15,14 @@ if (process.platform !== 'win32') {
12
15
expect . push ( 'a/symlink/a' , 'a/symlink/a/b/c/a' )
13
16
}
14
17
15
- const alphasort = ( a : string , b : string ) => a . localeCompare ( b , 'en' )
16
-
17
- expect . sort ( alphasort )
18
-
19
18
t . test ( 'chdir' , async t => {
20
19
const origCwd = process . cwd ( )
21
20
process . chdir ( fixtureDir )
22
21
t . teardown ( ( ) => process . chdir ( origCwd ) )
23
- t . same ( glob . sync ( pattern , { matchBase : true } ) . sort ( alphasort ) , expect )
22
+ t . same ( glob . sync ( pattern , { matchBase : true } ) . sort ( alphasort ) , j ( expect ) )
24
23
t . same (
25
24
( await glob ( pattern , { matchBase : true } ) ) . sort ( alphasort ) ,
26
- expect
25
+ j ( expect )
27
26
)
28
27
} )
29
28
@@ -32,13 +31,13 @@ t.test('cwd', async t => {
32
31
glob
33
32
. sync ( pattern , { matchBase : true , cwd : fixtureDir } )
34
33
. sort ( alphasort ) ,
35
- expect
34
+ j ( expect )
36
35
)
37
36
t . same (
38
37
( await glob ( pattern , { matchBase : true , cwd : fixtureDir } ) ) . sort (
39
38
alphasort
40
39
) ,
41
- expect
40
+ j ( expect )
42
41
)
43
42
} )
44
43
@@ -55,13 +54,13 @@ t.test('pattern includes /', async t => {
55
54
glob
56
55
. sync ( pattern , { matchBase : true , cwd : fixtureDir } )
57
56
. sort ( alphasort ) ,
58
- expect
57
+ j ( expect )
59
58
)
60
59
t . same (
61
60
( await glob ( pattern , { matchBase : true , cwd : fixtureDir } ) ) . sort (
62
61
alphasort
63
62
) ,
64
- expect
63
+ j ( expect )
65
64
)
66
65
} )
67
66
@@ -72,13 +71,13 @@ t.test('one brace section of pattern includes /', async t => {
72
71
glob
73
72
. sync ( pattern , { matchBase : true , cwd : fixtureDir } )
74
73
. sort ( alphasort ) ,
75
- exp
74
+ j ( exp )
76
75
)
77
76
t . same (
78
77
( await glob ( pattern , { matchBase : true , cwd : fixtureDir } ) ) . sort (
79
78
alphasort
80
79
) ,
81
- exp
80
+ j ( exp )
82
81
)
83
82
} )
84
83
@@ -89,12 +88,12 @@ t.test('one array member of pattern includes /', async t => {
89
88
glob
90
89
. sync ( pattern , { matchBase : true , cwd : fixtureDir } )
91
90
. sort ( alphasort ) ,
92
- exp
91
+ j ( exp )
93
92
)
94
93
t . same (
95
94
( await glob ( pattern , { matchBase : true , cwd : fixtureDir } ) ) . sort (
96
95
alphasort
97
96
) ,
98
- exp
97
+ j ( exp )
99
98
)
100
99
} )
0 commit comments