Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-docs/Vue: Add tests for sourceDecorator vnodeToString #17764

Merged
merged 2 commits into from
Mar 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions app/vue/src/client/docs/sourceDecorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,56 @@ describe('vnodeToString', () => {
)
).toMatchInlineSnapshot(`<div ><form ><button >Button</button></form></div>`);
});

it('empty tag', () => {
expect(
vnodeToString(
getVNode({
template: `
<div>
</div>`,
})
)
).toMatchInlineSnapshot(`<div />`);
});

it('tag in text', () => {
expect(
vnodeToString(
getVNode({
template: `
<div>
<>
</div>`,
})
)
).toMatchInlineSnapshot(`
<div >{{\`
<>
\`}}</div>
`);
});

it('component element with children', () => {
const MyComponent: ComponentOptions<any, any, any> = {
props: ['propA'],
template: '<div><slot /></div>',
};

expect(
vnodeToString(
getVNode({
components: { MyComponent },
data(): { props: Record<string, any> } {
return {
props: {
propA: 'propA',
},
};
},
template: `<my-component v-bind="props"><div /></my-component>`,
})
)
).toMatchInlineSnapshot(`<my-component propA="propA"><div /></my-component>`);
});
});