vue3-yuanma/packages/compiler-core/__tests__/codegen.spec.ts
2019-09-20 00:12:37 -04:00

21 lines
551 B
TypeScript

import { parse, generate } from '../src'
import { SourceMapConsumer, RawSourceMap } from 'source-map'
describe('compiler: codegen', () => {
test('basic source map support', async () => {
const ast = parse(`hello {{ world }}`)
const { code, map } = generate(ast)
expect(code).toBe(`["hello ", world]`)
const consumer = await new SourceMapConsumer(map as RawSourceMap)
const pos = consumer.originalPositionFor({
line: 1,
column: 11
})
expect(pos).toMatchObject({
line: 1,
column: 6
})
})
})