Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
Merge pull request #108 from storybookjs/storyname-test
Browse files Browse the repository at this point in the history
Add test for handling csf3 `name` -> `storyName`
  • Loading branch information
yannbf authored Jul 15, 2022
2 parents 16f7182 + 79867fb commit 90df26e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions example/src/__snapshots__/internals.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,18 @@ exports[`Renders WithLocale story 1`] = `
</div>
</body>
`;

exports[`Renders custom name story 1`] = `
<body>
<div>
<div>
Locale:
en
</div>
<button
class="storybook-button storybook-button--medium storybook-button--secondary"
type="button"
/>
</div>
</body>
`;
5 changes: 5 additions & 0 deletions example/src/components/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,8 @@ export const StoryWithDecoratorUseHook: CSF3Story<ButtonProps> = {
}
]
};

export const StoryWithName: CSF3Story<ButtonProps> = {
name: "custom name",
args: {}
}
5 changes: 5 additions & 0 deletions example/src/internals.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ test('should pass with decorators that need addons channel', () => {
expect(buttonElement).not.toBeNull();
});

test('should convert a csf3 name to storyName', () => {
const ComposedStoryWithName = composeStory(stories.StoryWithName, stories.default);
expect(ComposedStoryWithName.storyName).toBe('custom name');
});

describe('Unsupported formats', () => {
test('should throw error StoryFn.story notation', () => {
const UnsupportedStory = () => <div>hello world</div>;
Expand Down

0 comments on commit 90df26e

Please sign in to comment.