storybook/docs/snippets/react/register-component-with-play-function.js.mdx
2021-10-08 19:32:55 +01:00

40 lines
1.0 KiB
Plaintext

```js
// RegistrationForm.stories.js | RegistrationForm.stories.jsx | RegistrationForm.stories.ts | RegistrationForm.stories.tsx
// These are placeholders until the addon-interaction is out
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { RegistrationForm } from './RegistrationForm.js';
export default {
component: RegistrationForm,
//👇 Marking the onSubmit with this configuration will log the event in the Actions panel
argTypes: { onSubmit: { action: true } },
};
export const FilledForm = {
play: async () => {
const emailInput = screen.getByLabelText('email', {
selector: "input",
});
await userEvent.type(emailInput, 'example-email@email.com', {
delay: 100,
});
const passwordInput = screen.getByLabelText('password', {
selector: "input",
});
await userEvent.type(passwordInput, 'ExamplePassword', {
delay: 100,
});
const Submit = screen.getByRole('button');
await userEvent.click(Submit);
},
};
```