Skip to content

Commit 2794bc8

Browse files
committed
test: test throw for invalid refs
1 parent a113a2d commit 2794bc8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/core/definePage.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,24 @@ definePage({
153153
expect(result?.code).toMatchInlineSnapshot()
154154
})
155155

156+
it('throws if definePage uses a variable from the setup', async () => {
157+
const code = `
158+
<script setup>
159+
const a = 1
160+
definePage({
161+
name: a,
162+
})
163+
</script>
164+
`
165+
// the function syntax works with sync and async errors
166+
await expect(async () => {
167+
await definePageTransform({
168+
code,
169+
id: 'src/pages/basic.vue&definePage&vue',
170+
})
171+
}).rejects.toThrowError()
172+
})
173+
156174
it('extracts name and path', async () => {
157175
expect(
158176
await extractDefinePageNameAndPath(sampleCode, 'src/pages/basic.vue')

0 commit comments

Comments
 (0)