wip: parser support for script setup

This commit is contained in:
Evan You
2020-07-03 15:08:41 -04:00
parent 23b0d5adc0
commit 1ad3f975ed
2 changed files with 39 additions and 10 deletions

View File

@@ -146,15 +146,33 @@ h1 { color: red }
test('should only allow single template element', () => {
parse(`<template><div/></template><template><div/></template>`)
expect(
`Single file component can contain only one template element`
`Single file component can contain only one <template> element`
).toHaveBeenWarned()
})
test('should only allow single script element', () => {
parse(`<script>console.log(1)</script><script>console.log(1)</script>`)
expect(
`Single file component can contain only one script element`
`Single file component can contain only one <script> element`
).toHaveBeenWarned()
})
test('should only allow single script setup element', () => {
parse(
`<script setup>console.log(1)</script><script setup>console.log(1)</script>`
)
expect(
`Single file component can contain only one <script setup> element`
).toHaveBeenWarned()
})
test('should not warn script & script setup', () => {
parse(
`<script setup>console.log(1)</script><script>console.log(1)</script>`
)
expect(
`Single file component can contain only one`
).not.toHaveBeenWarned()
})
})
})