Skip to content

Commit

Permalink
feat: remove warning for no extreneous deps in stories
Browse files Browse the repository at this point in the history
  • Loading branch information
ixartz committed Apr 5, 2023
1 parent 51f3748 commit b243d44
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
10 changes: 9 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@
// Configuration for Storybook
{
"files": ["*.stories.*"],
"extends": ["plugin:storybook/recommended"]
"extends": ["plugin:storybook/recommended"],
"rules": {
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": true
}
]
}
}
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# testing
/coverage

# storybook
storybook-static

# cypress
cypress/screenshots
cypress/videos
Expand Down
42 changes: 42 additions & 0 deletions src/templates/Main.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Meta, StoryObj } from '@storybook/react';
import { userEvent, within } from '@storybook/testing-library';

import { Main } from './Main';

// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
const meta: Meta<typeof Main> = {
title: 'Example/Main',
component: Main,
tags: ['autodocs'],
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/7.0/react/configure/story-layout
layout: 'fullscreen',
},
};

export default meta;
type Story = StoryObj<typeof Main>;

export const MainWithReactComponent: Story = {
args: {
children: <div>Children node</div>,
},
};

export const MainWithString: Story = {
args: {
children: 'String',
},
};

// More on interaction testing: https://storybook.js.org/docs/7.0/react/writing-tests/interaction-testing
export const MainWithHomeLink: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const loginButton = await canvas.getByRole('link', {
name: /Home/i,
});

await userEvent.click(loginButton);
},
};
2 changes: 1 addition & 1 deletion src/templates/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Main = (props: IMainProps) => (

<div className="mx-auto max-w-screen-md">
<header className="border-b border-gray-300">
<div className="pt-16 pb-8">
<div className="pb-8 pt-16">
<h1 className="text-3xl font-bold text-gray-900">
{AppConfig.title}
</h1>
Expand Down

0 comments on commit b243d44

Please sign in to comment.