mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 07:43:08 +02:00
use waitFor
This commit is contained in:
parent
0ba5edc6aa
commit
2184323ae7
1 changed files with 3 additions and 6 deletions
|
@ -1,10 +1,9 @@
|
||||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||||
import { expect } from '@storybook/jest';
|
import { expect } from '@storybook/jest';
|
||||||
import { userEvent, within } from '@storybook/testing-library';
|
import { userEvent, waitFor, within } from '@storybook/testing-library';
|
||||||
import { StoryObj } from '@storybook/vue3';
|
import { StoryObj } from '@storybook/vue3';
|
||||||
import MkAd from './MkAd.vue';
|
import MkAd from './MkAd.vue';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { tick } from '@/scripts/test-utils.js';
|
|
||||||
const common = {
|
const common = {
|
||||||
render(args) {
|
render(args) {
|
||||||
return {
|
return {
|
||||||
|
@ -37,8 +36,7 @@ const common = {
|
||||||
const i = buttons[0];
|
const i = buttons[0];
|
||||||
await expect(i).toBeInTheDocument();
|
await expect(i).toBeInTheDocument();
|
||||||
await userEvent.click(i);
|
await userEvent.click(i);
|
||||||
await tick();
|
await waitFor(() => expect(a).not.toBeInTheDocument());
|
||||||
await expect(a).not.toBeInTheDocument();
|
|
||||||
await expect(i).not.toBeInTheDocument();
|
await expect(i).not.toBeInTheDocument();
|
||||||
buttons = canvas.getAllByRole<HTMLButtonElement>('button');
|
buttons = canvas.getAllByRole<HTMLButtonElement>('button');
|
||||||
await expect(buttons).toHaveLength(args.__hasReduce ? 2 : 1);
|
await expect(buttons).toHaveLength(args.__hasReduce ? 2 : 1);
|
||||||
|
@ -51,11 +49,10 @@ const common = {
|
||||||
await expect(back).toBeInTheDocument();
|
await expect(back).toBeInTheDocument();
|
||||||
await expect(back).toHaveTextContent(i18n.ts._ad.back);
|
await expect(back).toHaveTextContent(i18n.ts._ad.back);
|
||||||
await userEvent.click(back);
|
await userEvent.click(back);
|
||||||
await tick();
|
await waitFor(() => expect(back).not.toBeInTheDocument());
|
||||||
if (reduce) {
|
if (reduce) {
|
||||||
await expect(reduce).not.toBeInTheDocument();
|
await expect(reduce).not.toBeInTheDocument();
|
||||||
}
|
}
|
||||||
await expect(back).not.toBeInTheDocument();
|
|
||||||
const aAgain = canvas.getByRole<HTMLAnchorElement>('link');
|
const aAgain = canvas.getByRole<HTMLAnchorElement>('link');
|
||||||
await expect(aAgain).toBeInTheDocument();
|
await expect(aAgain).toBeInTheDocument();
|
||||||
const imgAgain = within(aAgain).getByRole('img');
|
const imgAgain = within(aAgain).getByRole('img');
|
||||||
|
|
Loading…
Reference in a new issue