@@ -3,7 +3,8 @@ import { parseComponent } from '../src/parseComponent'
3
3
4
4
describe ( 'Single File Component parser' , ( ) => {
5
5
it ( 'should parse' , ( ) => {
6
- const res = parseComponent ( `
6
+ const res = parseComponent (
7
+ `
7
8
<template>
8
9
<div>hi</div>
9
10
</template>
@@ -24,7 +25,9 @@ describe('Single File Component parser', () => {
24
25
<div>
25
26
<style>nested should be ignored</style>
26
27
</div>
27
- ` )
28
+ ` ,
29
+ { deindent : true }
30
+ )
28
31
expect ( res . template ! . content . trim ( ) ) . toBe ( '<div>hi</div>' )
29
32
expect ( res . styles . length ) . toBe ( 4 )
30
33
expect ( res . styles [ 0 ] . src ) . toBe ( './test.css' )
@@ -72,7 +75,10 @@ describe('Single File Component parser', () => {
72
75
h1 { color: red }
73
76
</style>
74
77
`
75
- const deindentDefault = parseComponent ( content . trim ( ) , { pad : false } )
78
+ const deindentDefault = parseComponent ( content . trim ( ) , {
79
+ pad : false ,
80
+ deindent : true
81
+ } )
76
82
const deindentEnabled = parseComponent ( content . trim ( ) , {
77
83
pad : false ,
78
84
deindent : true
@@ -111,9 +117,18 @@ describe('Single File Component parser', () => {
111
117
h1 { color: red }
112
118
</style>
113
119
`
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
+ } )
117
132
118
133
expect ( padDefault . script ! . content ) . toBe (
119
134
Array ( 3 + 1 ) . join ( '//\n' ) + '\nexport default {}\n'
@@ -145,12 +160,15 @@ describe('Single File Component parser', () => {
145
160
} )
146
161
147
162
it ( 'should handle template blocks with lang as special text' , ( ) => {
148
- const res = parseComponent ( `
163
+ const res = parseComponent (
164
+ `
149
165
<template lang="pug">
150
166
div
151
167
h1(v-if='1 < 2') hello
152
168
</template>
153
- ` )
169
+ ` ,
170
+ { deindent : true }
171
+ )
154
172
expect ( res . template ! . content . trim ( ) ) . toBe ( `div\n h1(v-if='1 < 2') hello` )
155
173
} )
156
174
@@ -164,7 +182,8 @@ describe('Single File Component parser', () => {
164
182
} )
165
183
166
184
it ( 'should handle custom blocks without parsing them' , ( ) => {
167
- const res = parseComponent ( `
185
+ const res = parseComponent (
186
+ `
168
187
<template>
169
188
<div></div>
170
189
</template>
@@ -183,7 +202,9 @@ describe('Single File Component parser', () => {
183
202
}))
184
203
}
185
204
</test>
186
- ` )
205
+ ` ,
206
+ { deindent : true }
207
+ )
187
208
expect ( res . customBlocks . length ) . toBe ( 3 )
188
209
189
210
const simpleExample = res . customBlocks [ 0 ]
0 commit comments