mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-15 09:35:21 +01:00
test fixes
This commit is contained in:
parent
982b351c2c
commit
df9a850f92
@ -1,12 +1,19 @@
|
|||||||
import React from 'react'
|
import React, { Suspense } from 'react'
|
||||||
import { render, fireEvent } from '@testing-library/react'
|
import { render, fireEvent, waitForElement } from '@testing-library/react'
|
||||||
|
|
||||||
import Qr from './Qr'
|
import Qr from './Qr'
|
||||||
|
|
||||||
describe('Qr', () => {
|
describe('Qr', () => {
|
||||||
it('renders without crashing', () => {
|
test('renders lazy', async () => {
|
||||||
const { container } = render(<Qr address="xxx" />)
|
const { container } = render(
|
||||||
expect(container.firstChild).toBeInTheDocument()
|
<Suspense fallback="test loading">
|
||||||
|
<Qr address="xxx" />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
|
const lazyElement = await waitForElement(() =>
|
||||||
|
container.querySelector('button')
|
||||||
|
)
|
||||||
|
expect(lazyElement).toBeInTheDocument()
|
||||||
fireEvent.click(container.querySelector('button'))
|
fireEvent.click(container.querySelector('button'))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,9 +1,16 @@
|
|||||||
import React from 'react'
|
import React, { Suspense } from 'react'
|
||||||
// import { render } from '@testing-library/react'
|
import { render, waitForElement } from '@testing-library/react'
|
||||||
import testRender from '../../../jest/testRender'
|
|
||||||
|
|
||||||
import Time from './Time'
|
import Time from './Time'
|
||||||
|
|
||||||
describe('Time', () => {
|
describe('Time', () => {
|
||||||
testRender(<Time date="2017/12/23" />)
|
test('renders lazy', async () => {
|
||||||
|
const { getByText } = render(
|
||||||
|
<Suspense fallback="test loading">
|
||||||
|
<Time date="2017/12/23" />
|
||||||
|
</Suspense>
|
||||||
|
)
|
||||||
|
const lazyElement = await waitForElement(() => getByText(/years ago/i))
|
||||||
|
expect(lazyElement).toBeInTheDocument()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user