|
@@ -71,42 +71,21 @@ describe('Single File Component parser', () => {
|
|
|
const padLine = parseComponent(content.trim(), { pad: 'line' })
|
|
const padLine = parseComponent(content.trim(), { pad: 'line' })
|
|
|
const padSpace = parseComponent(content.trim(), { pad: 'space' })
|
|
const padSpace = parseComponent(content.trim(), { pad: 'space' })
|
|
|
|
|
|
|
|
- expect(padDefault.template.content).toBe(Array(1).join('\n') + `
|
|
|
|
|
- <div></div>
|
|
|
|
|
- `)
|
|
|
|
|
- expect(padDefault.script.content).toBe(Array(3 + 1).join('//\n') + `
|
|
|
|
|
- export default {}
|
|
|
|
|
- `)
|
|
|
|
|
- expect(padDefault.styles[0].content).toBe(Array(6 + 1).join('\n') + `
|
|
|
|
|
- h1 { color: red }
|
|
|
|
|
- `)
|
|
|
|
|
- expect(padLine.template.content).toBe(Array(1).join('\n') + `
|
|
|
|
|
- <div></div>
|
|
|
|
|
- `)
|
|
|
|
|
- expect(padLine.script.content).toBe(Array(3 + 1).join('//\n') + `
|
|
|
|
|
- export default {}
|
|
|
|
|
- `)
|
|
|
|
|
- expect(padLine.styles[0].content).toBe(Array(6 + 1).join('\n') + `
|
|
|
|
|
- h1 { color: red }
|
|
|
|
|
- `)
|
|
|
|
|
- expect(padSpace.template.content).toBe(`<template>`.replace(/./g, ' ') + `
|
|
|
|
|
- <div></div>
|
|
|
|
|
- `)
|
|
|
|
|
|
|
+ expect(padDefault.script.content).toBe(Array(3 + 1).join('//\n') + '\nexport default {}\n')
|
|
|
|
|
+ expect(padDefault.styles[0].content).toBe(Array(6 + 1).join('\n') + '\nh1 { color: red }\n')
|
|
|
|
|
+ expect(padLine.script.content).toBe(Array(3 + 1).join('//\n') + '\nexport default {}\n')
|
|
|
|
|
+ expect(padLine.styles[0].content).toBe(Array(6 + 1).join('\n') + '\nh1 { color: red }\n')
|
|
|
expect(padSpace.script.content).toBe(`<template>
|
|
expect(padSpace.script.content).toBe(`<template>
|
|
|
<div></div>
|
|
<div></div>
|
|
|
</template>
|
|
</template>
|
|
|
- <script>`.replace(/./g, ' ') + `
|
|
|
|
|
- export default {}
|
|
|
|
|
- `)
|
|
|
|
|
|
|
+ <script>`.replace(/./g, ' ') + '\nexport default {}\n')
|
|
|
expect(padSpace.styles[0].content).toBe(`<template>
|
|
expect(padSpace.styles[0].content).toBe(`<template>
|
|
|
<div></div>
|
|
<div></div>
|
|
|
</template>
|
|
</template>
|
|
|
<script>
|
|
<script>
|
|
|
export default {}
|
|
export default {}
|
|
|
</script>
|
|
</script>
|
|
|
- <style>`.replace(/./g, ' ') + `
|
|
|
|
|
- h1 { color: red }
|
|
|
|
|
- `)
|
|
|
|
|
|
|
+ <style>`.replace(/./g, ' ') + '\nh1 { color: red }\n')
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should handle template blocks with lang as special text', () => {
|
|
it('should handle template blocks with lang as special text', () => {
|