mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 07:13:34 +08:00
25 lines
554 B
Plaintext
25 lines
554 B
Plaintext
```js
|
|
// tests/Form.test.js
|
|
|
|
import { fireEvent, render, screen } from '@testing-library/vue';
|
|
|
|
import { composeStory } from '@storybook/vue3';
|
|
|
|
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();
|
|
});
|
|
```
|