storybook/docs/snippets/angular/form-story-component-with-play-function.ts.mdx
2021-09-17 15:54:43 +01:00

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();
},
};
```