Skip to content

Commit

Permalink
fix(storybook): properly identify file as story (#18016)
Browse files Browse the repository at this point in the history
(cherry picked from commit 21007d8)
  • Loading branch information
mandarini authored and FrozenPandaz committed Jul 7, 2023
1 parent b1a8917 commit 0c480fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/storybook/src/utils/utilities.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@ describe('testing utilities', () => {
`
);

appTree.write(
`test-ui-lib/src/lib/button/button.other.stories.ts`,
`
import type { Meta } from '@storybook/react';
import { Button } from './button';
const Story: Meta<typeof Button> = {
component: Button,
title: 'Layout/Texts/Button',
};
export default Story;
export const Primary = {
args: {},
};
`
);

appTree.write(
`test-ui-lib/src/lib/button/button.component.other.ts`,
`
Expand Down Expand Up @@ -155,6 +173,14 @@ describe('testing utilities', () => {
expect(fileIsStory).toBeTruthy();
});

it('should verify it is story when using Meta', () => {
const fileIsStory = isTheFileAStory(
appTree,
'test-ui-lib/src/lib/button/button.other.stories.ts'
);
expect(fileIsStory).toBeTruthy();
});

it('should verify it is story for ReactNative', () => {
const fileIsStory = isTheFileAStory(
appTree,
Expand Down
1 change: 1 addition & 0 deletions packages/storybook/src/utils/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export function isTheFileAStory(tree: Tree, path: string): boolean {
importSpecifiers.forEach((importSpecifier: ts.ImportSpecifier) => {
if (
importSpecifier.getText() === 'Story' ||
importSpecifier.getText() === 'Meta' ||
importSpecifier.getText() === 'storiesOf' ||
importSpecifier.getText() === 'ComponentStory'
) {
Expand Down

0 comments on commit 0c480fd

Please sign in to comment.