Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Mar 16, 2023
1 parent 4028385 commit 6aef72a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,34 @@ describe('docs-mdx-compiler-plugin', () => {
).rejects.toThrow('Expected a Story name, id, or story attribute');
});

it("errors on story 'of' prop", async () => {
await expect(async () =>
clean(dedent`
import * as MyStories from './My.stories';
import { Story, Meta } from '@storybook/addon-docs';
<Meta title="Button" />
# Bad story
<Story of={MyStories.Primary} />
`)
).rejects.toThrow(`The 'of' prop is not supported in .stories.mdx files, only .mdx files.
See https://storybook.js.org/docs/7.0/react/writing-docs/mdx on how to write MDX files and stories separately.`);
});

it("errors on meta 'of' prop", async () => {
await expect(async () =>
clean(dedent`
import * as MyStories from './My.stories';
import { Meta } from '@storybook/addon-docs';
<Meta title="Button" of={MyStories} />
`)
).rejects.toThrow(`The 'of' prop is not supported in .stories.mdx files, only .mdx files.
See https://storybook.js.org/docs/7.0/react/writing-docs/mdx on how to write MDX files and stories separately.`);
});

describe('csf3', () => {
it('auto-title-docs-only.mdx', () => {
expect(
Expand Down

0 comments on commit 6aef72a

Please sign in to comment.