Skip to content

Commit adcadba

Browse files
committed
test: add
1 parent d98aec7 commit adcadba

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
@@ -58,6 +58,24 @@ return { n, get x() { return x } }
5858
}"
5959
`;
6060

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

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,22 @@ defineExpose({ foo: 123 })
296296
assertCode(content)
297297
})
298298
})
299+
300+
test('export call expression as default', () => {
301+
const { content } = compile(`
302+
<script>
303+
function fn() {
304+
return "hello, world";
305+
}
306+
export default fn();
307+
</script>
308+
309+
<script setup>
310+
console.log('foo')
311+
</script>
312+
`)
313+
assertCode(content)
314+
})
299315
})
300316

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

0 commit comments

Comments
 (0)