Skip to content

Commit be13105

Browse files
committed
feat(compiler-sfc): add test for export { default } from '...'
1 parent 615fd1b commit be13105

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

Diff for: packages/compiler-sfc/__tests__/rewriteDefault.spec.ts

+86
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ describe('compiler sfc: rewriteDefault', () => {
2525
export { a as b, a as c}
2626
const script = a"
2727
`)
28+
29+
expect(
30+
rewriteDefault(
31+
`const a = 1 \n export { a as b, a as default , a as c}`,
32+
'script'
33+
)
34+
).toMatchInlineSnapshot(`
35+
"const a = 1
36+
export { a as b, a as c}
37+
const script = a"
38+
`)
2839
})
2940

3041
test('w/ comments', async () => {
@@ -63,6 +74,81 @@ describe('compiler sfc: rewriteDefault', () => {
6374
// export { myFunction as default }
6475
const script = a"
6576
`)
77+
78+
expect(
79+
rewriteDefault(
80+
`const a = 1 \n export {\n a as b,\n a as default ,\n a as c}\n` +
81+
`// export { myFunction as default }`,
82+
'script'
83+
)
84+
).toMatchInlineSnapshot(`
85+
"const a = 1
86+
export {
87+
a as b,
88+
89+
a as c}
90+
// export { myFunction as default }
91+
const script = a"
92+
`)
93+
})
94+
95+
test(`export { default } from '...'`, async () => {
96+
expect(
97+
rewriteDefault(`export { default, foo } from './index.js'`, 'script')
98+
).toMatchInlineSnapshot(`
99+
"import { default as __VUE_DEFAULT__ } from './index.js'
100+
export { foo } from './index.js'
101+
const script = __VUE_DEFAULT__"
102+
`)
103+
104+
expect(
105+
rewriteDefault(`export { default , foo } from './index.js'`, 'script')
106+
).toMatchInlineSnapshot(`
107+
"import { default as __VUE_DEFAULT__ } from './index.js'
108+
export { foo } from './index.js'
109+
const script = __VUE_DEFAULT__"
110+
`)
111+
112+
expect(
113+
rewriteDefault(`export { foo, default } from './index.js'`, 'script')
114+
).toMatchInlineSnapshot(`
115+
"import { default as __VUE_DEFAULT__ } from './index.js'
116+
export { foo, } from './index.js'
117+
const script = __VUE_DEFAULT__"
118+
`)
119+
120+
expect(
121+
rewriteDefault(
122+
`export { foo as default, bar } from './index.js'`,
123+
'script'
124+
)
125+
).toMatchInlineSnapshot(`
126+
"import { foo } from './index.js'
127+
export { bar } from './index.js'
128+
const script = foo"
129+
`)
130+
131+
expect(
132+
rewriteDefault(
133+
`export { foo as default , bar } from './index.js'`,
134+
'script'
135+
)
136+
).toMatchInlineSnapshot(`
137+
"import { foo } from './index.js'
138+
export { bar } from './index.js'
139+
const script = foo"
140+
`)
141+
142+
expect(
143+
rewriteDefault(
144+
`export { bar, foo as default } from './index.js'`,
145+
'script'
146+
)
147+
).toMatchInlineSnapshot(`
148+
"import { foo } from './index.js'
149+
export { bar, } from './index.js'
150+
const script = foo"
151+
`)
66152
})
67153

68154
test('export default class', async () => {

0 commit comments

Comments
 (0)