fix(compiler-sfc): fix rewrite named export default (#1675)

This commit is contained in:
underfin
2020-07-23 09:00:41 +08:00
committed by GitHub
parent ee6828aa1e
commit 452edb73cb
2 changed files with 54 additions and 3 deletions

View File

@@ -0,0 +1,29 @@
import { rewriteDefault } from '../src'
describe('compiler sfc: rewriteDefault', () => {
test('without export default', () => {
expect(rewriteDefault(`export a = {}`, 'script')).toMatchInlineSnapshot(`
"export a = {}
const script = {}"
`)
})
test('rewrite export default', () => {
expect(
rewriteDefault(`export default {}`, 'script')
).toMatchInlineSnapshot(`"const script = {}"`)
})
test('rewrite export named default', () => {
expect(
rewriteDefault(
`const a = 1 \n export { a as b, a as default, a as c}`,
'script'
)
).toMatchInlineSnapshot(`
"const a = 1
export { a as b, a as c}
const script = a"
`)
})
})