mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
81 lines
2.6 KiB
TypeScript
81 lines
2.6 KiB
TypeScript
import '@testing-library/jest-dom';
|
|
import { render } from '@testing-library/svelte';
|
|
import { wizard } from '../../../src/lib/stores/wizard';
|
|
import { tick } from 'svelte';
|
|
import WizardComponent from '../../../src/lib/mock/wizard.test.svelte';
|
|
import WizardContainer from '../../../src/lib/mock/wizard.container.test.svelte';
|
|
|
|
test('shows wizard and hides it', async () => {
|
|
const { queryByText } = render(WizardContainer);
|
|
|
|
/**
|
|
* Wizard is hidden before started.
|
|
*/
|
|
expect(queryByText('wizard-title')).not.toBeInTheDocument();
|
|
expect(queryByText('step-1')).not.toBeInTheDocument();
|
|
expect(queryByText('sub-title-1')).not.toBeInTheDocument();
|
|
expect(queryByText('step-2')).not.toBeInTheDocument();
|
|
expect(queryByText('sub-title-2')).not.toBeInTheDocument();
|
|
|
|
wizard.start(WizardComponent);
|
|
await tick();
|
|
|
|
/**
|
|
* First step is shown, second is hidden.
|
|
*/
|
|
expect(queryByText('wizard-title')).toBeInTheDocument();
|
|
expect(queryByText('step-1')).toBeInTheDocument();
|
|
expect(queryByText('sub-title-1')).toBeInTheDocument();
|
|
|
|
expect(queryByText('step-2')).not.toBeInTheDocument();
|
|
expect(queryByText('sub-title-2')).not.toBeInTheDocument();
|
|
|
|
wizard.hide();
|
|
await tick();
|
|
|
|
/**
|
|
* Wizard is hidden.
|
|
*/
|
|
expect(queryByText('wizard-title')).not.toBeInTheDocument();
|
|
expect(queryByText('step-1')).not.toBeInTheDocument();
|
|
expect(queryByText('sub-title-1')).not.toBeInTheDocument();
|
|
expect(queryByText('step-2')).not.toBeInTheDocument();
|
|
expect(queryByText('sub-title-2')).not.toBeInTheDocument();
|
|
});
|
|
|
|
test('shows next step with submit', async () => {
|
|
const { getByTestId, getByRole, queryByText } = render(WizardContainer);
|
|
|
|
wizard.start(WizardComponent);
|
|
await tick();
|
|
|
|
const form = getByRole('form') as HTMLFormElement;
|
|
const step1 = queryByText('step-1');
|
|
const step1Required = getByTestId('step-1-required');
|
|
const step1Optional = getByTestId('step-1-optional');
|
|
|
|
expect(step1).toBeInTheDocument();
|
|
expect(step1Required).toBeInTheDocument();
|
|
expect(step1Optional).toBeInTheDocument();
|
|
|
|
form.submit();
|
|
await tick();
|
|
|
|
expect(step1).not.toBeInTheDocument();
|
|
|
|
const step2 = queryByText('step-2');
|
|
const step2First = getByTestId('step-2-first');
|
|
const step2Second = getByTestId('step-2-second');
|
|
|
|
expect(step2).toBeInTheDocument();
|
|
expect(step2First).toBeInTheDocument();
|
|
expect(step2Second).toBeInTheDocument();
|
|
|
|
form.submit();
|
|
await tick();
|
|
|
|
expect(form).not.toBeInTheDocument();
|
|
expect(step1).not.toBeInTheDocument();
|
|
expect(step2).not.toBeInTheDocument();
|
|
});
|