Skip to content

Commit 72939fc

Browse files
committed
test: add
1 parent 38212e7 commit 72939fc

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

packages/compiler-sfc/__tests__/__snapshots__/compileScript.spec.ts.snap

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,24 @@ return { n, get x() { return x } }
5959
}"
6060
`;
6161

62+
exports[`SFC compile <script setup> > <script> and <script setup> co-usage > export call expression as default 1`] = `
63+
"function fn() {
64+
return \\"hello, world\\";
65+
}
66+
const __default__ = fn();
67+
68+
export default /*#__PURE__*/Object.assign(__default__, {
69+
setup(__props, { expose }) {
70+
expose();
71+
72+
console.log('foo')
73+
74+
return { fn }
75+
}
76+
77+
})"
78+
`;
79+
6280
exports[`SFC compile <script setup> > <script> and <script setup> co-usage > script first 1`] = `
6381
"import { x } from './x'
6482

packages/compiler-sfc/__tests__/compileScript.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,22 @@ defineExpose({ foo: 123 })
358358
assertCode(content)
359359
})
360360
})
361+
362+
test('export call expression as default', () => {
363+
const { content } = compile(`
364+
<script>
365+
function fn() {
366+
return "hello, world";
367+
}
368+
export default fn();
369+
</script>
370+
371+
<script setup>
372+
console.log('foo')
373+
</script>
374+
`)
375+
assertCode(content)
376+
})
361377
})
362378

363379
describe('imports', () => {

0 commit comments

Comments
 (0)