@@ -9,6 +9,10 @@ import { createTestFixture, cleanupFixture, loadGloblin, type GloblinModule } fr
99let fixtureDir : string
1010let globlin : GloblinModule
1111
12+ // Normalize paths for cross-platform comparison (replace backslashes with forward slashes)
13+ const normalize = ( paths : string [ ] ) : string [ ] => paths . map ( p => p . replace ( / \\ / g, '/' ) )
14+ const normalizeStr = ( path : string ) : string => path . replace ( / \\ / g, '/' )
15+
1216// Fixture with dotfiles
1317const DOT_FILE_FIXTURE = {
1418 files : [
@@ -75,13 +79,17 @@ describe('Dot file handling', () => {
7579 const globResults = await glob ( 'nested/**/*' , { cwd : fixtureDir } )
7680 const globlinResults = await globlin . glob ( 'nested/**/*' , { cwd : fixtureDir } )
7781
82+ // Normalize paths for cross-platform comparison
83+ const normalizedGlob = normalize ( globResults )
84+ const normalizedGloblin = normalize ( globlinResults )
85+
7886 // Should include visible files
79- expect ( globResults ) . toContain ( 'nested/visible' )
80- expect ( globResults ) . toContain ( 'nested/visible/file.txt' )
87+ expect ( normalizedGlob ) . toContain ( 'nested/visible' )
88+ expect ( normalizedGlob ) . toContain ( 'nested/visible/file.txt' )
8189
8290 // Globlin should match
83- expect ( globlinResults ) . toContain ( 'nested/visible' )
84- expect ( globlinResults ) . toContain ( 'nested/visible/file.txt' )
91+ expect ( normalizedGloblin ) . toContain ( 'nested/visible' )
92+ expect ( normalizedGloblin ) . toContain ( 'nested/visible/file.txt' )
8593 } )
8694 } )
8795
@@ -104,29 +112,37 @@ describe('Dot file handling', () => {
104112 const globResults = await glob ( '**/*' , { cwd : fixtureDir , dot : true } )
105113 const globlinResults = await globlin . glob ( '**/*' , { cwd : fixtureDir , dot : true } )
106114
107- // Should include dotfiles
108- expect ( globResults ) . toContain ( '.hidden' )
109- expect ( globResults ) . toContain ( '.git/config' )
110- expect ( globResults ) . toContain ( 'src/.env' )
111- expect ( globResults ) . toContain ( 'nested/.config' )
115+ // Normalize paths for cross-platform comparison
116+ const normalizedGlob = normalize ( globResults )
117+ const normalizedGloblin = normalize ( globlinResults )
112118
113- expect ( globlinResults ) . toContain ( '.hidden' )
114- expect ( globlinResults ) . toContain ( '.git/config' )
115- expect ( globlinResults ) . toContain ( 'src/.env' )
116- expect ( globlinResults ) . toContain ( 'nested/.config' )
119+ // Should include dotfiles
120+ expect ( normalizedGlob ) . toContain ( '.hidden' )
121+ expect ( normalizedGlob ) . toContain ( '.git/config' )
122+ expect ( normalizedGlob ) . toContain ( 'src/.env' )
123+ expect ( normalizedGlob ) . toContain ( 'nested/.config' )
124+
125+ expect ( normalizedGloblin ) . toContain ( '.hidden' )
126+ expect ( normalizedGloblin ) . toContain ( '.git/config' )
127+ expect ( normalizedGloblin ) . toContain ( 'src/.env' )
128+ expect ( normalizedGloblin ) . toContain ( 'nested/.config' )
117129 } )
118130
119131 it ( 'should include files inside dotdirs with **/*' , async ( ) => {
120132 const globResults = await glob ( '**/*' , { cwd : fixtureDir , dot : true } )
121133 const globlinResults = await globlin . glob ( '**/*' , { cwd : fixtureDir , dot : true } )
122134
123- expect ( globResults ) . toContain ( '.git/config' )
124- expect ( globResults ) . toContain ( '.git/HEAD' )
125- expect ( globResults ) . toContain ( 'nested/.config/settings.json' )
135+ // Normalize paths for cross-platform comparison
136+ const normalizedGlob = normalize ( globResults )
137+ const normalizedGloblin = normalize ( globlinResults )
138+
139+ expect ( normalizedGlob ) . toContain ( '.git/config' )
140+ expect ( normalizedGlob ) . toContain ( '.git/HEAD' )
141+ expect ( normalizedGlob ) . toContain ( 'nested/.config/settings.json' )
126142
127- expect ( globlinResults ) . toContain ( '.git/config' )
128- expect ( globlinResults ) . toContain ( '.git/HEAD' )
129- expect ( globlinResults ) . toContain ( 'nested/.config/settings.json' )
143+ expect ( normalizedGloblin ) . toContain ( '.git/config' )
144+ expect ( normalizedGloblin ) . toContain ( '.git/HEAD' )
145+ expect ( normalizedGloblin ) . toContain ( 'nested/.config/settings.json' )
130146 } )
131147 } )
132148
@@ -143,24 +159,27 @@ describe('Dot file handling', () => {
143159 const globResults = await glob ( '.git/*' , { cwd : fixtureDir } )
144160 const globlinResults = await globlin . glob ( '.git/*' , { cwd : fixtureDir } )
145161
146- expect ( globResults . sort ( ) ) . toEqual ( [ '.git/HEAD' , '.git/config' ] . sort ( ) )
147- expect ( globlinResults . sort ( ) ) . toEqual ( [ '.git/HEAD' , '.git/config' ] . sort ( ) )
162+ // Normalize paths for cross-platform comparison
163+ expect ( normalize ( globResults ) . sort ( ) ) . toEqual ( [ '.git/HEAD' , '.git/config' ] . sort ( ) )
164+ expect ( normalize ( globlinResults ) . sort ( ) ) . toEqual ( [ '.git/HEAD' , '.git/config' ] . sort ( ) )
148165 } )
149166
150167 it ( 'should match **/.env without dot option' , async ( ) => {
151168 const globResults = await glob ( '**/.env' , { cwd : fixtureDir } )
152169 const globlinResults = await globlin . glob ( '**/.env' , { cwd : fixtureDir } )
153170
154- expect ( globResults ) . toContain ( 'src/.env' )
155- expect ( globlinResults ) . toContain ( 'src/.env' )
171+ // Normalize paths for cross-platform comparison
172+ expect ( normalize ( globResults ) ) . toContain ( 'src/.env' )
173+ expect ( normalize ( globlinResults ) ) . toContain ( 'src/.env' )
156174 } )
157175
158176 it ( 'should match nested dotdir pattern without dot option' , async ( ) => {
159177 const globResults = await glob ( 'nested/.config/*' , { cwd : fixtureDir } )
160178 const globlinResults = await globlin . glob ( 'nested/.config/*' , { cwd : fixtureDir } )
161179
162- expect ( globResults ) . toContain ( 'nested/.config/settings.json' )
163- expect ( globlinResults ) . toContain ( 'nested/.config/settings.json' )
180+ // Normalize paths for cross-platform comparison
181+ expect ( normalize ( globResults ) ) . toContain ( 'nested/.config/settings.json' )
182+ expect ( normalize ( globlinResults ) ) . toContain ( 'nested/.config/settings.json' )
164183 } )
165184 } )
166185
0 commit comments