Skip to content

Commit

Permalink
add test for using both directives - let:args & let:context
Browse files Browse the repository at this point in the history
  • Loading branch information
xeho91 committed Sep 5, 2024
1 parent 4a5fe10 commit 2468f04
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/compiler/pre-transform/codemods/legacy-story.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,29 @@ describe(transformLegacyStory.name, () => {
</Story>"
`);
});

it("when both directives 'let:args' and 'let:context' is used then it wraps Story fragment with 'children' snippet block", async ({
expect,
}) => {
const code = `
<script context="module">
import { Story } from "@storybook/addon-svelte-csf";
</script>
<Story name="Default" let:args let:context>
<h1>{args.title}</h1>
<p>{context.id}</p>
</Story>
`;
const node = await parseAndExtractSvelteNode<Component>(code, 'Component');

expect(print(transformLegacyStory({ node }))).toMatchInlineSnapshot(`
"<Story name="Default">
{#snippet children(args, context)}
<h1>{args.title}</h1>
<p>{context.id}</p>
{/snippet}
</Story>"
`);
});
});

0 comments on commit 2468f04

Please sign in to comment.