@@ -68,23 +68,40 @@ describe('external files', () => {
68
68
expect ( markup . code ) . toContain ( getFixtureContent ( 'template.html' ) ) ;
69
69
} ) ;
70
70
71
+ it ( "warns if local file don't exist" , async ( ) => {
72
+ const input = `<style src="./missing-potato"></style>` ;
73
+
74
+ await preprocess ( input , sveltePreprocess ( ) ) ;
75
+
76
+ expect ( warnSpy ) . toHaveBeenCalledWith (
77
+ expect . stringContaining ( 'was not found' ) ,
78
+ ) ;
79
+ } ) ;
80
+
71
81
REMOTE_JS . forEach ( ( url ) => {
72
- it ( `should not attempt to locally resolve ${ url } ` , async ( ) => {
82
+ it ( `ignores remote path " ${ url } " ` , async ( ) => {
73
83
const input = `<div></div><script src="${ url } "></script>` ;
74
84
75
85
const preprocessed = await preprocess ( input , sveltePreprocess ( ) ) ;
76
86
77
87
expect ( preprocessed . toString ?.( ) ) . toContain ( input ) ;
78
88
expect ( preprocessed . dependencies ) . toHaveLength ( 0 ) ;
89
+ expect ( warnSpy ) . not . toHaveBeenCalledWith (
90
+ expect . stringContaining ( 'was not found' ) ,
91
+ ) ;
79
92
} ) ;
80
93
} ) ;
81
94
82
- it ( "should warn if local file don't exist" , async ( ) => {
83
- const input = `<style src="./missing -potato"></style>` ;
95
+ it ( 'ignores external source if path is not relative' , async ( ) => {
96
+ const input = `<style src="/root -potato"></style>` ;
84
97
85
98
await preprocess ( input , sveltePreprocess ( ) ) ;
86
99
87
- expect ( warnSpy ) . toHaveBeenCalledWith (
100
+ const preprocessed = await preprocess ( input , sveltePreprocess ( ) ) ;
101
+
102
+ expect ( preprocessed . toString ?.( ) ) . toContain ( input ) ;
103
+ expect ( preprocessed . dependencies ) . toHaveLength ( 0 ) ;
104
+ expect ( warnSpy ) . not . toHaveBeenCalledWith (
88
105
expect . stringContaining ( 'was not found' ) ,
89
106
) ;
90
107
} ) ;
0 commit comments