@@ -3,7 +3,8 @@ import { parseComponent } from '../src/parseComponent'
33
44describe ( 'Single File Component parser' , ( ) => {
55 it ( 'should parse' , ( ) => {
6- const res = parseComponent ( `
6+ const res = parseComponent (
7+ `
78 <template>
89 <div>hi</div>
910 </template>
@@ -24,7 +25,9 @@ describe('Single File Component parser', () => {
2425 <div>
2526 <style>nested should be ignored</style>
2627 </div>
27- ` )
28+ ` ,
29+ { deindent : true }
30+ )
2831 expect ( res . template ! . content . trim ( ) ) . toBe ( '<div>hi</div>' )
2932 expect ( res . styles . length ) . toBe ( 4 )
3033 expect ( res . styles [ 0 ] . src ) . toBe ( './test.css' )
@@ -72,7 +75,10 @@ describe('Single File Component parser', () => {
7275 h1 { color: red }
7376 </style>
7477 `
75- const deindentDefault = parseComponent ( content . trim ( ) , { pad : false } )
78+ const deindentDefault = parseComponent ( content . trim ( ) , {
79+ pad : false ,
80+ deindent : true
81+ } )
7682 const deindentEnabled = parseComponent ( content . trim ( ) , {
7783 pad : false ,
7884 deindent : true
@@ -111,9 +117,18 @@ describe('Single File Component parser', () => {
111117 h1 { color: red }
112118 </style>
113119`
114- const padDefault = parseComponent ( content . trim ( ) , { pad : true } )
115- const padLine = parseComponent ( content . trim ( ) , { pad : 'line' } )
116- const padSpace = parseComponent ( content . trim ( ) , { pad : 'space' } )
120+ const padDefault = parseComponent ( content . trim ( ) , {
121+ pad : true ,
122+ deindent : true
123+ } )
124+ const padLine = parseComponent ( content . trim ( ) , {
125+ pad : 'line' ,
126+ deindent : true
127+ } )
128+ const padSpace = parseComponent ( content . trim ( ) , {
129+ pad : 'space' ,
130+ deindent : true
131+ } )
117132
118133 expect ( padDefault . script ! . content ) . toBe (
119134 Array ( 3 + 1 ) . join ( '//\n' ) + '\nexport default {}\n'
@@ -145,12 +160,15 @@ describe('Single File Component parser', () => {
145160 } )
146161
147162 it ( 'should handle template blocks with lang as special text' , ( ) => {
148- const res = parseComponent ( `
163+ const res = parseComponent (
164+ `
149165 <template lang="pug">
150166 div
151167 h1(v-if='1 < 2') hello
152168 </template>
153- ` )
169+ ` ,
170+ { deindent : true }
171+ )
154172 expect ( res . template ! . content . trim ( ) ) . toBe ( `div\n h1(v-if='1 < 2') hello` )
155173 } )
156174
@@ -164,7 +182,8 @@ describe('Single File Component parser', () => {
164182 } )
165183
166184 it ( 'should handle custom blocks without parsing them' , ( ) => {
167- const res = parseComponent ( `
185+ const res = parseComponent (
186+ `
168187 <template>
169188 <div></div>
170189 </template>
@@ -183,7 +202,9 @@ describe('Single File Component parser', () => {
183202 }))
184203 }
185204 </test>
186- ` )
205+ ` ,
206+ { deindent : true }
207+ )
187208 expect ( res . customBlocks . length ) . toBe ( 3 )
188209
189210 const simpleExample = res . customBlocks [ 0 ]
0 commit comments