mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 06:51:17 +08:00
3.5 KiB
3.5 KiB
import { fireEvent, screen } from '@testing-library/react';
import { composeStories } from '@storybook/react';
import * as FormStories from './LoginForm.stories';
const { InvalidForm, ValidForm } = composeStories(FormStories);
test('Tests invalid form state', async () => {
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
test('Tests filled form', async () => {
await ValidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).not.toBeInTheDocument();
});
import { fireEvent, screen } from '@testing-library/react';
import { composeStories } from '@storybook/react';
import * as FormStories from './LoginForm.stories';
const { InvalidForm, ValidForm } = composeStories(FormStories);
test('Tests invalid form state', async () => {
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
test('Tests filled form', async () => {
await ValidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).not.toBeInTheDocument();
});
import { fireEvent, screen } from '@testing-library/vue';
import { composeStories } from '@storybook/vue3';
import * as FormStories from './LoginForm.stories';
const { InvalidForm, ValidForm } = composeStories(FormStories);
test('Tests invalid form state', async () => {
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
test('Tests filled form', async () => {
await ValidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).not.toBeInTheDocument();
});
import { fireEvent, screen } from '@testing-library/vue';
import { composeStories } from '@storybook/vue3';
import * as FormStories from './LoginForm.stories';
const { InvalidForm, ValidForm } = composeStories(FormStories);
test('Tests invalid form state', async () => {
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
test('Tests filled form', async () => {
await ValidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).not.toBeInTheDocument();
});