Skip to content

Commit

Permalink
test: add
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Feb 1, 2023
1 parent b30c05b commit 67ad426
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ return { n, get x() { return x } }
}"
`;

exports[`SFC compile <script setup> > <script> and <script setup> co-usage > export call expression as default 1`] = `
"function fn() {
return \\"hello, world\\";
}
const __default__ = fn();

export default /*#__PURE__*/Object.assign(__default__, {
setup(__props, { expose }) {
expose();

console.log('foo')

return { fn }
}

})"
`;

exports[`SFC compile <script setup> > <script> and <script setup> co-usage > script first 1`] = `
"import { x } from './x'

Expand Down
16 changes: 16 additions & 0 deletions packages/compiler-sfc/__tests__/compileScript.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,22 @@ defineExpose({ foo: 123 })
assertCode(content)
})
})

test('export call expression as default', () => {
const { content } = compile(`
<script>
function fn() {
return "hello, world";
}
export default fn();
</script>
<script setup>
console.log('foo')
</script>
`)
assertCode(content)
})
})

describe('imports', () => {
Expand Down

0 comments on commit 67ad426

Please sign in to comment.