Skip to content

Commit

Permalink
Fix storyName not working with CSF3 and storyStoreV7 enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Jun 11, 2022
1 parent b2f4390 commit 3bba2d7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
23 changes: 23 additions & 0 deletions lib/csf-tools/src/CsfFile.test.ts
Expand Up @@ -613,5 +613,28 @@ describe('CsfFile', () => {
__id: foo-bar--a
`);
});

it('Object export with storyName', () => {
expect(
parse(
dedent`
export default { title: 'foo/bar' };
export const A = {
storyName: 'Apple'
}
`,
true
)
).toMatchInlineSnapshot(`
meta:
title: foo/bar
stories:
- id: foo-bar--a
name: Apple
parameters:
__isArgsStory: true
__id: foo-bar--a
`);
});
});
});
5 changes: 4 additions & 1 deletion lib/csf-tools/src/CsfFile.ts
Expand Up @@ -266,7 +266,10 @@ export class CsfFile {
if (t.isIdentifier(p.key)) {
if (p.key.name === 'render') {
__isArgsStory = isArgsStory(p.value as t.Expression, parent, self);
} else if (p.key.name === 'name' && t.isStringLiteral(p.value)) {
} else if (
(p.key.name === 'name' || p.key.name === 'storyName') &&
t.isStringLiteral(p.value)
) {
name = p.value.value;
}
self._storyAnnotations[exportName][p.key.name] = p.value;
Expand Down

0 comments on commit 3bba2d7

Please sign in to comment.