Skip to content

Commit

Permalink
fix eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Oct 10, 2022
1 parent 609f3ab commit 90ef1e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AsyncTestComponent extends React.Component {

export default {
title: 'Async',
includeStories: ['withTimeout'],
includeStories: ['WithTimeout'],
};

export const WithTimeout = () => <AsyncTestComponent />;
Expand Down
42 changes: 19 additions & 23 deletions code/examples/external-docs/components/AccountForm.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable storybook/await-interactions */
/* eslint-disable storybook/use-storybook-testing-library */
// @TODO: use addon-interactions and remove the rule disable above
import { ComponentStoryObj, ComponentMeta } from '@storybook/react';
Expand All @@ -15,21 +14,18 @@ export default {
},
} as ComponentMeta<typeof AccountForm>;

// export const Standard = (args: any) => <AccountForm {...args} />;
// Standard.args = { passwordVerification: false };
// Standard.play = () => userEvent.type(screen.getByTestId('email'), '[email protected]');
type Story = ComponentStoryObj<typeof AccountForm>;

export const Standard: ComponentStoryObj<typeof AccountForm> = {
// render: (args: AccountFormProps) => <AccountForm {...args} />,
export const Standard: Story = {
args: { passwordVerification: false },
};

export const StandardEmailFilled = {
export const StandardEmailFilled: Story = {
...Standard,
play: () => userEvent.type(screen.getByTestId('email'), '[email protected]'),
};

export const StandardEmailFailed = {
export const StandardEmailFailed: Story = {
...Standard,
play: async () => {
await userEvent.type(screen.getByTestId('email'), '[email protected]@com');
Expand All @@ -38,21 +34,21 @@ export const StandardEmailFailed = {
},
};

export const StandardPasswordFailed = {
export const StandardPasswordFailed: Story = {
...Standard,
play: async () => {
await StandardEmailFilled.play();
play: async (context) => {
await StandardEmailFilled.play(context);
await userEvent.type(screen.getByTestId('password1'), 'asdf');
await userEvent.click(screen.getByTestId('submit'));
},
};

const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));

export const StandardFailHover = {
export const StandardFailHover: Story = {
...StandardPasswordFailed,
play: async () => {
await StandardPasswordFailed.play();
play: async (context) => {
await StandardPasswordFailed.play(context);
await sleep(100);
await userEvent.hover(screen.getByTestId('password-error-info'));
},
Expand All @@ -62,29 +58,29 @@ export const Verification: ComponentStoryObj<typeof AccountForm> = {
args: { passwordVerification: true },
};

export const VerificationPasssword1 = {
export const VerificationPasssword1: Story = {
...Verification,
play: async () => {
await StandardEmailFilled.play();
play: async (context) => {
await StandardEmailFilled.play(context);
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf');
await userEvent.click(screen.getByTestId('submit'));
},
};

export const VerificationPasswordMismatch = {
export const VerificationPasswordMismatch: Story = {
...Verification,
play: async () => {
await StandardEmailFilled.play();
play: async (context) => {
await StandardEmailFilled.play(context);
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf');
await userEvent.type(screen.getByTestId('password2'), 'asdf1234');
await userEvent.click(screen.getByTestId('submit'));
},
};

export const VerificationSuccess = {
export const VerificationSuccess: Story = {
...Verification,
play: async () => {
await StandardEmailFilled.play();
play: async (context) => {
await StandardEmailFilled.play(context);
await sleep(1000);
await userEvent.type(screen.getByTestId('password1'), 'asdfasdf', { delay: 50 });
await sleep(1000);
Expand Down

0 comments on commit 90ef1e1

Please sign in to comment.