@@ -10,6 +10,12 @@ const {
10
10
style : styleProcessor ,
11
11
} = getAutoPreprocess ( ) ;
12
12
13
+ const REMOTE_JS = [
14
+ 'https://www.example.com/some/externally/delivered/content.js' ,
15
+ 'http://www.example.com/some/externally/delivered/content.js' ,
16
+ '//www.example.com/some/externally/delivered/content.js' ,
17
+ ] ;
18
+
13
19
describe ( 'external files' , ( ) => {
14
20
let markup : Processed ;
15
21
let script : Processed ;
@@ -48,15 +54,7 @@ describe('external files', () => {
48
54
expect ( style . dependencies ) . toContain ( getFixturePath ( 'style.css' ) ) ;
49
55
} ) ;
50
56
51
- const EXTERNALJS = [
52
- 'https://www.example.com/some/externally/delivered/content.js' ,
53
- 'http://www.example.com/some/externally/delivered/content.js' ,
54
- '//www.example.com/some/externally/delivered/content.js' ,
55
- 'some-file.js' ,
56
- './some-not-local-file.js' ,
57
- ] ;
58
-
59
- EXTERNALJS . forEach ( ( url ) => {
57
+ REMOTE_JS . forEach ( ( url ) => {
60
58
it ( `should not attempt to locally resolve ${ url } ` , async ( ) => {
61
59
const input = `<div></div><script src="${ url } "></script>` ;
62
60
@@ -66,4 +64,15 @@ describe('external files', () => {
66
64
expect ( preprocessed . dependencies ) . toHaveLength ( 0 ) ;
67
65
} ) ;
68
66
} ) ;
67
+
68
+ it ( "should throw if local file don't exist" , async ( ) => {
69
+ const spy = jest . spyOn ( console , 'warn' ) ;
70
+ const input = `<style src="./missing-potato"></style>` ;
71
+
72
+ await preprocess ( input , getAutoPreprocess ( ) ) ;
73
+
74
+ expect ( spy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'was not found' ) ) ;
75
+
76
+ spy . mockRestore ( ) ;
77
+ } ) ;
69
78
} ) ;
0 commit comments