1
1
import { resolve } from 'path' ;
2
2
3
3
import sveltePreprocess from '../../src' ;
4
- import { Processed } from '../../src/types' ;
5
4
import {
6
5
preprocess ,
7
6
getFixtureContent ,
@@ -24,12 +23,8 @@ const REMOTE_JS = [
24
23
] ;
25
24
26
25
describe ( 'external files' , ( ) => {
27
- let markup : Processed ;
28
- let script : Processed ;
29
- let style : Processed ;
30
-
31
- beforeAll ( async ( ) => {
32
- [ markup , script , style ] = [
26
+ it ( 'should insert external file content and add as deps' , async ( ) => {
27
+ const [ markup , script , style ] = [
33
28
await markupProcessor ( {
34
29
content : `<template src="./fixtures/template.html"></template>
35
30
<style src="./fixtures/style.css"></style>
@@ -47,20 +42,24 @@ describe('external files', () => {
47
42
attributes : { src : `./fixtures/style.css` } ,
48
43
} ) ,
49
44
] ;
50
- } ) ;
51
45
52
- it ( 'should insert external file content' , async ( ) => {
53
46
expect ( markup . code ) . toContain ( getFixtureContent ( 'template.html' ) ) ;
54
47
expect ( script . code ) . toContain ( getFixtureContent ( 'script.js' ) ) ;
55
48
expect ( style . code ) . toContain ( getFixtureContent ( 'style.css' ) ) ;
56
- } ) ;
57
-
58
- it ( 'should add a external file as a dependency' , async ( ) => {
59
49
expect ( markup . dependencies ) . toContain ( getFixturePath ( 'template.html' ) ) ;
60
50
expect ( script . dependencies ) . toContain ( getFixturePath ( 'script.js' ) ) ;
61
51
expect ( style . dependencies ) . toContain ( getFixturePath ( 'style.css' ) ) ;
62
52
} ) ;
63
53
54
+ it ( 'should support self-closing tags' , async ( ) => {
55
+ const markup = await markupProcessor ( {
56
+ content : `<template src="./fixtures/template.html"/>` ,
57
+ filename : resolve ( __dirname , '..' , 'App.svelte' ) ,
58
+ } ) ;
59
+
60
+ expect ( markup . code ) . toContain ( getFixtureContent ( 'template.html' ) ) ;
61
+ } ) ;
62
+
64
63
REMOTE_JS . forEach ( ( url ) => {
65
64
it ( `should not attempt to locally resolve ${ url } ` , async ( ) => {
66
65
const input = `<div></div><script src="${ url } "></script>` ;
0 commit comments