mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-06 06:21:23 +08:00
4.3 KiB
4.3 KiB
import { render, screen, fireEvent } from '@testing-library/angular';
import { FormComponent } from './LoginForm.component';
import { InvalidForm } from './Form.stories'; //👈 Our stories imported here.
test('Checks if the form is valid ', async () => {
await render(FormComponent, {
componentProperties: InvalidForm.args,
});
fireEvent.click(screen.getByText('Submit'));
const isFormValid = screen.getByTestId('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
import '@testing-library/jest-dom/extend-expect';
import { h } from 'preact';
import { render, fireEvent } from '@testing-library/preact';
import { InvalidForm } from './LoginForm.stories'; //👈 Our stories imported here.
it('Checks if the form is valid', async () => {
const { getByTestId, getByText } = render(<InvalidForm {...InvalidForm.args} />);
fireEvent.click(getByText('Submit'));
const isFormValid = getByTestId('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
import { fireEvent, render, screen } from '@testing-library/react';
import { composeStories } from '@storybook/react';
import * as stories from './LoginForm.stories'; // 👈 Our stories imported here.
const { InvalidForm } = composeStories(stories);
test('Checks if the form is valid', async () => {
// Renders the composed story
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
import { fireEvent, render, screen } from '@testing-library/react';
import { composeStories } from '@storybook/react';
import * as stories from './LoginForm.stories'; // 👈 Our stories imported here.
const { InvalidForm } = composeStories(stories);
test('Checks if the form is valid', async () => {
// Renders the composed story
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
import { fireEvent, render, screen } from '@testing-library/svelte';
import { composeStories } from '@storybook/svelte';
import * as stories from './LoginForm.stories'; // 👈 Our stories imported here.
const { InvalidForm } = composeStories(stories);
it('Checks if the form is valid', async () => {
// Renders the composed story
await InvalidForm.run();
await fireEvent.click(screen.getByText('Submit'));
const isFormValid = screen.getByTestId('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
import { fireEvent, render, screen } from '@testing-library/vue';
import { composeStories } from '@storybook/vue3';
import * as stories from './LoginForm.stories'; // 👈 Our stories imported here.
const { InvalidForm } = composeStories(stories);
test('Checks if the form is valid', async () => {
// Renders the composed story
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});
import { fireEvent, render, screen } from '@testing-library/vue';
import { composeStories } from '@storybook/vue3';
import * as stories from './LoginForm.stories'; // 👈 Our stories imported here.
const { InvalidForm } = composeStories(stories);
test('Checks if the form is valid', async () => {
// Renders the composed story
await InvalidForm.run();
const buttonElement = screen.getByRole('button', {
name: 'Submit',
});
fireEvent.click(buttonElement);
const isFormValid = screen.getByLabelText('invalid-form');
expect(isFormValid).toBeInTheDocument();
});