import { parse } from '../src' import { mockWarn } from '@vue/runtime-test' import { baseParse, baseCompile } from '@vue/compiler-core' describe('compiler:sfc', () => { mockWarn() describe('source map', () => { test('style block', () => { const style = parse(`\n`) .descriptor.styles[0] // TODO need to actually test this with SourceMapConsumer expect(style.map).not.toBeUndefined() }) test('script block', () => { const script = parse(`\n`) .descriptor.script // TODO need to actually test this with SourceMapConsumer expect(script!.map).not.toBeUndefined() }) }) test('pad content', () => { const content = ` ` const padFalse = parse(content.trim(), { pad: false }).descriptor expect(padFalse.template!.content).toBe('\n
\n') expect(padFalse.script!.content).toBe('\nexport default {}\n') expect(padFalse.styles[0].content).toBe('\nh1 { color: red }\n') const padTrue = parse(content.trim(), { pad: true }).descriptor expect(padTrue.script!.content).toBe( Array(3 + 1).join('//\n') + '\nexport default {}\n' ) expect(padTrue.styles[0].content).toBe( Array(6 + 1).join('\n') + '\nh1 { color: red }\n' ) const padLine = parse(content.trim(), { pad: 'line' }).descriptor 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' ) const padSpace = parse(content.trim(), { pad: 'space' }).descriptor expect(padSpace.script!.content).toBe( `\n\n\n\n