feat(compiler-sfc): warn duplicate block (#451)

This commit is contained in:
likui
2019-11-15 00:50:13 +08:00
committed by Evan You
parent 8688acc36f
commit 7f6abda6dd
2 changed files with 42 additions and 2 deletions

View File

@@ -0,0 +1,21 @@
import { parse } from '../src'
import { mockWarn } from '@vue/runtime-test'
describe('compiler:sfc', () => {
mockWarn()
describe('error', () => {
test('should only allow single template element', () => {
parse(`<template><div/></template><template><div/></template>`)
expect(
`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`
).toHaveBeenWarned()
})
})
})