@@ -14,13 +14,17 @@ describe('ConfigLoader', () => {
1414 } ;
1515 }
1616
17+ function normalizePath ( filePath : string ) : string {
18+ return path . join ( ...filePath . split ( '/' ) ) ;
19+ }
20+
1721 async function assertFindsConfig (
1822 configLoader : ConfigLoader ,
1923 filePath : string ,
2024 configPath : string
2125 ) {
22- filePath = path . join ( ... filePath . split ( '/' ) ) ;
23- configPath = path . join ( ... configPath . split ( '/' ) ) ;
26+ filePath = normalizePath ( filePath ) ;
27+ configPath = normalizePath ( configPath ) ;
2428 assert . deepStrictEqual ( configLoader . getConfig ( filePath ) , configFrom ( configPath ) ) ;
2529 assert . deepStrictEqual ( await configLoader . awaitConfig ( filePath ) , configFrom ( configPath ) ) ;
2630 }
@@ -32,20 +36,24 @@ describe('ConfigLoader', () => {
3236 path ,
3337 ( module : URL ) => Promise . resolve ( { default : { preprocess : module . toString ( ) } } )
3438 ) ;
35- await configLoader . loadConfigs ( '/some/path' ) ;
39+ await configLoader . loadConfigs ( normalizePath ( '/some/path' ) ) ;
3640
37- assertFindsConfig ( configLoader , '/some/path/comp.svelte' , '/some/path/svelte.config.js' ) ;
38- assertFindsConfig (
41+ await assertFindsConfig (
42+ configLoader ,
43+ '/some/path/comp.svelte' ,
44+ '/some/path/svelte.config.js'
45+ ) ;
46+ await assertFindsConfig (
3947 configLoader ,
4048 '/some/path/aside/comp.svelte' ,
4149 '/some/path/svelte.config.js'
4250 ) ;
43- assertFindsConfig (
51+ await assertFindsConfig (
4452 configLoader ,
4553 '/some/path/below/comp.svelte' ,
4654 '/some/path/below/svelte.config.js'
4755 ) ;
48- assertFindsConfig (
56+ await assertFindsConfig (
4957 configLoader ,
5058 '/some/path/below/further/comp.svelte' ,
5159 '/some/path/below/svelte.config.js'
@@ -62,9 +70,9 @@ describe('ConfigLoader', () => {
6270 path ,
6371 ( module : URL ) => Promise . resolve ( { default : { preprocess : module . toString ( ) } } )
6472 ) ;
65- await configLoader . loadConfigs ( '/some/path' ) ;
73+ await configLoader . loadConfigs ( normalizePath ( '/some/path' ) ) ;
6674
67- assertFindsConfig ( configLoader , '/some/path/comp.svelte' , '/some/svelte.config.js' ) ;
75+ await assertFindsConfig ( configLoader , '/some/path/comp.svelte' , '/some/svelte.config.js' ) ;
6876 } ) ;
6977
7078 it ( 'adds fallback if no config found' , async ( ) => {
@@ -74,12 +82,14 @@ describe('ConfigLoader', () => {
7482 path ,
7583 ( module : URL ) => Promise . resolve ( { default : { preprocess : module . toString ( ) } } )
7684 ) ;
77- await configLoader . loadConfigs ( '/some/path' ) ;
85+ await configLoader . loadConfigs ( normalizePath ( '/some/path' ) ) ;
7886
7987 assert . deepStrictEqual (
8088 // Can't do the equal-check directly, instead check if it's the expected object props
8189 // of svelte-preprocess
82- Object . keys ( configLoader . getConfig ( '/some/path/comp.svelte' ) ?. preprocess || { } ) . sort ( ) ,
90+ Object . keys (
91+ configLoader . getConfig ( normalizePath ( '/some/path/comp.svelte' ) ) ?. preprocess || { }
92+ ) . sort ( ) ,
8393 [ 'defaultLanguages' , 'markup' , 'script' , 'style' ] . sort ( )
8494 ) ;
8595 } ) ;
@@ -110,13 +120,17 @@ describe('ConfigLoader', () => {
110120 }
111121 ) ;
112122 await Promise . all ( [
113- configLoader . loadConfigs ( '/some/path' ) ,
114- configLoader . loadConfigs ( '/some/path/sub' ) ,
115- configLoader . awaitConfig ( '/some/path/file.svelte' )
123+ configLoader . loadConfigs ( normalizePath ( '/some/path' ) ) ,
124+ configLoader . loadConfigs ( normalizePath ( '/some/path/sub' ) ) ,
125+ configLoader . awaitConfig ( normalizePath ( '/some/path/file.svelte' ) )
116126 ] ) ;
117127
118- assertFindsConfig ( configLoader , '/some/path/comp.svelte' , '/some/path/svelte.config.js' ) ;
119- assertFindsConfig (
128+ await assertFindsConfig (
129+ configLoader ,
130+ '/some/path/comp.svelte' ,
131+ '/some/path/svelte.config.js'
132+ ) ;
133+ await assertFindsConfig (
120134 configLoader ,
121135 '/some/path/sub/comp.svelte' ,
122136 '/some/path/svelte.config.js'
@@ -131,7 +145,10 @@ describe('ConfigLoader', () => {
131145 path ,
132146 ( ) => Promise . resolve ( 'unimportant' )
133147 ) ;
134- assert . deepStrictEqual ( configLoader . getConfig ( '/some/file.svelte' ) , undefined ) ;
148+ assert . deepStrictEqual (
149+ configLoader . getConfig ( normalizePath ( '/some/file.svelte' ) ) ,
150+ undefined
151+ ) ;
135152 } ) ;
136153
137154 it ( 'should await config' , async ( ) => {
@@ -142,8 +159,8 @@ describe('ConfigLoader', () => {
142159 ( module : URL ) => Promise . resolve ( { default : { preprocess : module . toString ( ) } } )
143160 ) ;
144161 assert . deepStrictEqual (
145- await configLoader . awaitConfig ( path . join ( 'some' , ' file.svelte') ) ,
146- configFrom ( path . join ( 'some' , ' svelte.config.js') )
162+ await configLoader . awaitConfig ( normalizePath ( 'some/ file.svelte' ) ) ,
163+ configFrom ( normalizePath ( 'some/ svelte.config.js' ) )
147164 ) ;
148165 } ) ;
149166} ) ;
0 commit comments