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

Commit 90df26e

Browse files
authored
Merge pull request #108 from storybookjs/storyname-test
Add test for handling csf3 `name` -> `storyName`
2 parents 16f7182 + 79867fb commit 90df26e

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

example/src/__snapshots__/internals.test.tsx.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,18 @@ exports[`Renders WithLocale story 1`] = `
143143
</div>
144144
</body>
145145
`;
146+
147+
exports[`Renders custom name story 1`] = `
148+
<body>
149+
<div>
150+
<div>
151+
Locale:
152+
en
153+
</div>
154+
<button
155+
class="storybook-button storybook-button--medium storybook-button--secondary"
156+
type="button"
157+
/>
158+
</div>
159+
</body>
160+
`;

example/src/components/Button.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,8 @@ export const StoryWithDecoratorUseHook: CSF3Story<ButtonProps> = {
9999
}
100100
]
101101
};
102+
103+
export const StoryWithName: CSF3Story<ButtonProps> = {
104+
name: "custom name",
105+
args: {}
106+
}

example/src/internals.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ test('should pass with decorators that need addons channel', () => {
3737
expect(buttonElement).not.toBeNull();
3838
});
3939

40+
test('should convert a csf3 name to storyName', () => {
41+
const ComposedStoryWithName = composeStory(stories.StoryWithName, stories.default);
42+
expect(ComposedStoryWithName.storyName).toBe('custom name');
43+
});
44+
4045
describe('Unsupported formats', () => {
4146
test('should throw error StoryFn.story notation', () => {
4247
const UnsupportedStory = () => <div>hello world</div>;

0 commit comments

Comments
 (0)