mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 21:31:48 +08:00
25 lines
557 B
Plaintext
25 lines
557 B
Plaintext
```ts
|
|
// Form.test.ts|tsx
|
|
|
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
|
|
import { composeStory } from '@storybook/react';
|
|
|
|
import Meta, { ValidForm as ValidFormStory } from './LoginForm.stories';
|
|
|
|
const FormOK = composeStory(ValidFormStory, Meta);
|
|
|
|
test('Validates form', () => {
|
|
render(<FormOK />);
|
|
|
|
const buttonElement = screen.getByRole('button', {
|
|
name: 'Submit',
|
|
});
|
|
|
|
fireEvent.click(buttonElement);
|
|
|
|
const isFormValid = screen.getByLabelText('invalid-form');
|
|
expect(isFormValid).not.toBeInTheDocument();
|
|
});
|
|
```
|