mirror of
https://github.com/kremalicious/blog.git
synced 2024-12-22 09:13:35 +01:00
test fixes
This commit is contained in:
parent
982b351c2c
commit
df9a850f92
@ -1,12 +1,19 @@
|
||||
import React from 'react'
|
||||
import { render, fireEvent } from '@testing-library/react'
|
||||
import React, { Suspense } from 'react'
|
||||
import { render, fireEvent, waitForElement } from '@testing-library/react'
|
||||
|
||||
import Qr from './Qr'
|
||||
|
||||
describe('Qr', () => {
|
||||
it('renders without crashing', () => {
|
||||
const { container } = render(<Qr address="xxx" />)
|
||||
expect(container.firstChild).toBeInTheDocument()
|
||||
test('renders lazy', async () => {
|
||||
const { container } = render(
|
||||
<Suspense fallback="test loading">
|
||||
<Qr address="xxx" />
|
||||
</Suspense>
|
||||
)
|
||||
const lazyElement = await waitForElement(() =>
|
||||
container.querySelector('button')
|
||||
)
|
||||
expect(lazyElement).toBeInTheDocument()
|
||||
fireEvent.click(container.querySelector('button'))
|
||||
})
|
||||
})
|
||||
|
@ -1,9 +1,16 @@
|
||||
import React from 'react'
|
||||
// import { render } from '@testing-library/react'
|
||||
import testRender from '../../../jest/testRender'
|
||||
import React, { Suspense } from 'react'
|
||||
import { render, waitForElement } from '@testing-library/react'
|
||||
|
||||
import Time from './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