1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-23 01:30:01 +01:00

test tweaks

This commit is contained in:
Matthias Kretschmann 2021-03-14 01:54:16 +01:00
parent 273adeecb4
commit dce40556d2
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 8 additions and 12 deletions

View File

@ -1,5 +1,5 @@
import React, { Suspense } from 'react' 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' import Qr from './Qr'
@ -10,10 +10,8 @@ describe('Qr', () => {
<Qr address="xxx" /> <Qr address="xxx" />
</Suspense> </Suspense>
) )
const lazyElement = await waitForElement(() => expect(container.firstChild).toBeInTheDocument()
container.querySelector('button') await waitFor(() => container.querySelector('button'))
)
expect(lazyElement).toBeInTheDocument()
fireEvent.click(container.querySelector('button')) fireEvent.click(container.querySelector('button'))
}) })
}) })

View File

@ -5,7 +5,7 @@ import { PageContext } from '../../@types/Post'
import Icon from '../atoms/Icon' import Icon from '../atoms/Icon'
import { import {
current as styleCurrent, current as styleCurrent,
number, number as styleNumber,
pagination pagination
} from './Pagination.module.css' } from './Pagination.module.css'
@ -18,7 +18,7 @@ const PageNumber = ({
slug: string slug: string
current?: boolean current?: boolean
}) => { }) => {
const classes = current ? styleCurrent : number const classes = current ? styleCurrent : styleNumber
const link = i === 0 ? slug : `${slug}page/${i + 1}` const link = i === 0 ? slug : `${slug}page/${i + 1}`
return ( return (
@ -40,7 +40,7 @@ function PrevNext({
const title = prevPagePath ? 'Newer Posts' : 'Older Posts' const title = prevPagePath ? 'Newer Posts' : 'Older Posts'
return ( return (
<Link to={link} rel={rel} title={title} className={styles.number}> <Link to={link} rel={rel} title={title} className={styleNumber}>
{prevPagePath ? ( {prevPagePath ? (
<Icon name="ChevronLeft" /> <Icon name="ChevronLeft" />
) : ( ) : (

View File

@ -1,13 +1,11 @@
import React from 'react' import React from 'react'
import { render, waitForElement } from '@testing-library/react' import { render, waitFor } from '@testing-library/react'
import Thanks from '../thanks' import Thanks from '../thanks'
describe('/thanks', () => { describe('/thanks', () => {
it('renders without crashing', async () => { it('renders without crashing', async () => {
const { container } = render(<Thanks />) const { container } = render(<Thanks />)
const lazyElement = await waitForElement(() => const lazyElement = await waitFor(() => container.querySelector('button'))
container.querySelector('button')
)
expect(lazyElement).toBeInTheDocument() expect(lazyElement).toBeInTheDocument()
}) })
}) })