Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
xeho91 committed Dec 14, 2024
1 parent 4cfb294 commit 54d04d9
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions src/compiler/pre-transform/codemods/legacy-story.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,7 @@ describe(transformLegacyStory.name, () => {
`);
});

it("leaves existing Story parameters untouched", async ({
expect,
}) => {
it('leaves existing Story parameters untouched', async ({ expect }) => {
const code = `
<script context="module">
import { Story } from "@storybook/addon-svelte-csf";
Expand Down Expand Up @@ -334,4 +332,39 @@ describe(transformLegacyStory.name, () => {
</Story>"
`);
});

it('legacy `source` prop with template literal value is supported _(moved to parameters)_', async ({
expect,
}) => {
const code = `
<script context="module">
import { Story } from "@storybook/addon-svelte-csf";
</script>
<Story
name="Default"
source={\`
<Foo bar />
\`}
>
<h1>{"Test"}</h1>
</Story>
`;
const component = await parseAndExtractSvelteNode<SvelteAST.Component>(code, 'Component');

expect(
print(
transformLegacyStory({
component,
state: { componentIdentifierName: {} },
})
)
).toMatchInlineSnapshot(`
"<Story name="Default" parameters={{
docs: { source: { code: "\\n <Foo bar />\\n " } }
}}>
<h1>{"Test"}</h1>
</Story>"
`);
});
});

0 comments on commit 54d04d9

Please sign in to comment.