import { parse } from '../src'
import { mockWarn } from '@vue/runtime-test'
describe('compiler:sfc', () => {
mockWarn()
describe('source map', () => {
test('style block', () => {
const style = parse(`\n`)
.styles[0]
// TODO need to actually test this with SourceMapConsumer
expect(style.map).not.toBeUndefined()
})
test('script block', () => {
const script = parse(`\n`).script
// TODO need to actually test this with SourceMapConsumer
expect(script!.map).not.toBeUndefined()
})
})
test('should ignore nodes with no content', () => {
expect(parse(``).template).toBe(null)
expect(parse(``).script).toBe(null)
expect(parse(``).styles.length).toBe(0)
expect(parse(``).customBlocks.length).toBe(0)
})
describe('error', () => {
test('should only allow single template element', () => {
parse(``)
expect(
`Single file component can contain only one template element`
).toHaveBeenWarned()
})
test('should only allow single script element', () => {
parse(``)
expect(
`Single file component can contain only one script element`
).toHaveBeenWarned()
})
})
})