Skip to content

Commit

Permalink
test: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Jan 24, 2025
1 parent f725472 commit 1d49d53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/compiler-core/__tests__/transforms/vSkip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,21 @@ describe('compiler: v-skip', () => {
])
})

test('on component with default slot and slot props', () => {
const onError = vi.fn()
parseWithSkipTransform(
`<Comp v-skip="ok">
<template #default="foo">foo</template>
</Comp>`,
{ onError },
)
expect(onError.mock.calls[0]).toMatchObject([
{
code: ErrorCodes.X_V_SKIP_UNEXPECTED_SLOT,
},
])
})

test('with v-for', () => {
const onError = vi.fn()
parseWithSkipTransform(`<div v-for="i in items" v-skip="ok"/>`, {
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-core/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const errorMessages: Record<ErrorCodes, string> = {
[ErrorCodes.X_VNODE_HOOKS]: `@vnode-* hooks in templates are no longer supported. Use the vue: prefix instead. For example, @vnode-mounted should be changed to @vue:mounted. @vnode-* hooks support has been removed in 3.4.`,
[ErrorCodes.X_V_SKIP_NO_EXPRESSION]: `v-skip is missing expression.`,
[ErrorCodes.X_V_SKIP_ON_TEMPLATE]: `v-skip cannot be used on <template> or <slot> tags.`,
[ErrorCodes.X_V_SKIP_UNEXPECTED_SLOT]: `v-skip directive requires the component to have a default slot without slot props`,
[ErrorCodes.X_V_SKIP_UNEXPECTED_SLOT]: `v-skip requires the component to have a default slot without slot props`,
[ErrorCodes.X_V_SKIP_WITH_V_FOR]: `v-skip with v-for is not supported.`,

// generic errors
Expand Down

0 comments on commit 1d49d53

Please sign in to comment.