Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Moved code into new line and updated tests
  • Loading branch information
AntarEspadas committed Apr 30, 2023
commit 3ce718475c914b6d6027a10fd9e19c3f2d9f3cf2
3 changes: 2 additions & 1 deletion src/core/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ function generateStoryImport(
return `
${renderFunction}
export const ${id} = () => Object.assign({render: render${id}}, _sfc_main)
${id}.storyName = '${title}'${play ? `\n${id}.play = ${play}` : ''}
${id}.storyName = '${title}'
${play ? `${id}.play = ${play}` : ''}
${id}.parameters = {
docs: { source: { code: \`${template.trim()}\` } },
};`
Expand Down
11 changes: 11 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`hello\` } },
};
Expand All @@ -44,6 +45,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`hello\` } },
};
Expand Down Expand Up @@ -75,6 +77,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`hello\` } },
};
Expand All @@ -98,6 +101,7 @@ describe('transform', () => {
export const Primary_story = () =>
Object.assign({ render: renderPrimary_story }, _sfc_main);
Primary_story.storyName = \\"Primary story\\";

Primary_story.parameters = {
docs: { source: { code: \`hello\` } },
};
Expand All @@ -121,6 +125,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`hello\` } },
};
Expand Down Expand Up @@ -149,6 +154,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`hello\` } },
};
Expand All @@ -159,6 +165,7 @@ describe('transform', () => {
export const Secondary = () =>
Object.assign({ render: renderSecondary }, _sfc_main);
Secondary.storyName = \\"Secondary\\";

Secondary.parameters = {
docs: { source: { code: \`world\` } },
};
Expand Down Expand Up @@ -195,6 +202,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`<Button>\` } },
};
Expand All @@ -207,6 +215,7 @@ describe('transform', () => {
export const Secondary = () =>
Object.assign({ render: renderSecondary }, _sfc_main);
Secondary.storyName = \\"Secondary\\";

Secondary.parameters = {
docs: { source: { code: \`<Button>\` } },
};
Expand Down Expand Up @@ -262,6 +271,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`<test></test>\` } },
};
Expand Down Expand Up @@ -298,6 +308,7 @@ describe('transform', () => {
export const Primary = () =>
Object.assign({ render: renderPrimary }, _sfc_main);
Primary.storyName = \\"Primary\\";

Primary.parameters = {
docs: { source: { code: \`hello\` } },
}; /*@jsxRuntime automatic @jsxImportSource react*/
Expand Down