From dce40556d225bafa27f3914e2a0d830ebe8a42d9 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 14 Mar 2021 01:54:16 +0100 Subject: [PATCH] test tweaks --- src/components/atoms/Qr.test.tsx | 8 +++----- src/components/molecules/Pagination.tsx | 6 +++--- src/pages/__tests__/thanks.test.tsx | 6 ++---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/components/atoms/Qr.test.tsx b/src/components/atoms/Qr.test.tsx index 5b719367..e8ffdf43 100644 --- a/src/components/atoms/Qr.test.tsx +++ b/src/components/atoms/Qr.test.tsx @@ -1,5 +1,5 @@ import React, { Suspense } from 'react' -import { render, fireEvent, waitForElement } from '@testing-library/react' +import { render, fireEvent, waitFor } from '@testing-library/react' import Qr from './Qr' @@ -10,10 +10,8 @@ describe('Qr', () => { ) - const lazyElement = await waitForElement(() => - container.querySelector('button') - ) - expect(lazyElement).toBeInTheDocument() + expect(container.firstChild).toBeInTheDocument() + await waitFor(() => container.querySelector('button')) fireEvent.click(container.querySelector('button')) }) }) diff --git a/src/components/molecules/Pagination.tsx b/src/components/molecules/Pagination.tsx index 15625858..a0b30812 100644 --- a/src/components/molecules/Pagination.tsx +++ b/src/components/molecules/Pagination.tsx @@ -5,7 +5,7 @@ import { PageContext } from '../../@types/Post' import Icon from '../atoms/Icon' import { current as styleCurrent, - number, + number as styleNumber, pagination } from './Pagination.module.css' @@ -18,7 +18,7 @@ const PageNumber = ({ slug: string current?: boolean }) => { - const classes = current ? styleCurrent : number + const classes = current ? styleCurrent : styleNumber const link = i === 0 ? slug : `${slug}page/${i + 1}` return ( @@ -40,7 +40,7 @@ function PrevNext({ const title = prevPagePath ? 'Newer Posts' : 'Older Posts' return ( - + {prevPagePath ? ( ) : ( diff --git a/src/pages/__tests__/thanks.test.tsx b/src/pages/__tests__/thanks.test.tsx index 96de204f..6959bbeb 100644 --- a/src/pages/__tests__/thanks.test.tsx +++ b/src/pages/__tests__/thanks.test.tsx @@ -1,13 +1,11 @@ import React from 'react' -import { render, waitForElement } from '@testing-library/react' +import { render, waitFor } from '@testing-library/react' import Thanks from '../thanks' describe('/thanks', () => { it('renders without crashing', async () => { const { container } = render() - const lazyElement = await waitForElement(() => - container.querySelector('button') - ) + const lazyElement = await waitFor(() => container.querySelector('button')) expect(lazyElement).toBeInTheDocument() }) })