mirror of
https://github.com/kremalicious/blog.git
synced 2024-12-23 01:30:01 +01:00
test tweaks
This commit is contained in:
parent
273adeecb4
commit
dce40556d2
@ -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'))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -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" />
|
||||||
) : (
|
) : (
|
||||||
|
@ -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()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user