@@ -24,23 +24,24 @@ describe('css', () => {
24
24
const it_fn = solo ? it . only : skip ? it . skip : it ;
25
25
26
26
it_fn ( dir , async ( ) => {
27
- const config = await try_load_config ( `${ __dirname } /samples/${ dir } /_config.js` ) ;
27
+ const cwd = `${ __dirname } /samples/${ dir } ` ;
28
+ const config = await try_load_config ( `${ cwd } /_config.js` ) ;
28
29
29
30
const input = fs
30
- . readFileSync ( `${ __dirname } /samples/ ${ dir } /input.svelte` , 'utf-8' )
31
+ . readFileSync ( `${ cwd } /input.svelte` , 'utf-8' )
31
32
. replace ( / \s + $ / , '' )
32
33
. replace ( / \r / g, '' ) ;
33
34
34
35
const expected_warnings = ( config . warnings || [ ] ) . map ( normalize_warning ) ;
35
36
36
37
const dom = svelte . compile (
37
38
input ,
38
- Object . assign ( config . compileOptions || { } , { format : 'cjs' } )
39
+ Object . assign ( { } , config . compileOptions || { } , { format : 'cjs' } )
39
40
) ;
40
41
41
42
const ssr = svelte . compile (
42
43
input ,
43
- Object . assign ( config . compileOptions || { } , { format : 'cjs' , generate : 'ssr' } )
44
+ Object . assign ( { } , config . compileOptions || { } , { format : 'cjs' , generate : 'ssr' } )
44
45
) ;
45
46
46
47
assert . equal ( dom . css . code , ssr . css . code ) ;
@@ -51,26 +52,24 @@ describe('css', () => {
51
52
assert . deepEqual ( dom_warnings , ssr_warnings ) ;
52
53
assert . deepEqual ( dom_warnings . map ( normalize_warning ) , expected_warnings ) ;
53
54
54
- fs . writeFileSync ( `${ __dirname } /samples/ ${ dir } /_actual.css` , dom . css . code ) ;
55
+ fs . writeFileSync ( `${ cwd } /_actual.css` , dom . css . code ) ;
55
56
const expected = {
56
- html : read ( `${ __dirname } /samples/ ${ dir } /expected.html` ) ,
57
- css : read ( `${ __dirname } /samples/ ${ dir } /expected.css` )
57
+ html : read ( `${ cwd } /expected.html` ) ,
58
+ css : read ( `${ cwd } /expected.css` )
58
59
} ;
59
60
60
61
const actual_css = replace_css_hash ( dom . css . code ) ;
61
62
try {
62
63
assert . equal ( actual_css , expected . css ) ;
63
64
} catch ( error ) {
64
65
if ( should_update_expected ( ) ) {
65
- fs . writeFileSync ( `${ __dirname } /samples/ ${ dir } /expected.css` , actual_css ) ;
66
+ fs . writeFileSync ( `${ cwd } /expected.css` , actual_css ) ;
66
67
console . log ( `Updated ${ dir } /expected.css.` ) ;
67
68
} else {
68
69
throw error ;
69
70
}
70
71
}
71
72
72
- const cwd = `${ __dirname } /samples/${ dir } ` ;
73
-
74
73
let ClientComponent ;
75
74
let ServerComponent ;
76
75
@@ -102,7 +101,7 @@ describe('css', () => {
102
101
new ClientComponent ( { target, props : config . props } ) ;
103
102
const html = target . innerHTML ;
104
103
105
- fs . writeFileSync ( `${ __dirname } /samples/ ${ dir } /_actual.html` , html ) ;
104
+ fs . writeFileSync ( `${ cwd } /_actual.html` , html ) ;
106
105
107
106
const actual_html = replace_css_hash ( html ) ;
108
107
assert_html_equal ( actual_html , expected . html ) ;
0 commit comments