mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
26 lines
694 B
Plaintext
26 lines
694 B
Plaintext
```ts
|
|
// Form.stories.ts
|
|
|
|
import userEvent, { expect, screen } from '@storybook/addon-interactions';
|
|
|
|
import { LoginForm } from './LoginForm';
|
|
|
|
export default {
|
|
component: LoginForm,
|
|
//👇 Marking the onSubmit with this configuration will log the event in the Actions panel
|
|
argTypes: { onSubmit: { action: true } },
|
|
};
|
|
|
|
export const FilledForm = {
|
|
play: async ({ args }) => {
|
|
await userEvent.type(screen.getByTestId('email'), 'email', {
|
|
delay: 100,
|
|
});
|
|
await userEvent.type(screen.getByTestId('password'), 'passoword', {
|
|
delay: 100,
|
|
});
|
|
await userEvent.click(screen.getByTestId('submit'));
|
|
await expect(args.onSubmit).toHaveBeenCalled();
|
|
},
|
|
};
|
|
``` |