1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-22 09:13:35 +01:00

test fixes

This commit is contained in:
Matthias Kretschmann 2019-11-23 13:31:04 +01:00
parent 982b351c2c
commit df9a850f92
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 23 additions and 9 deletions

View File

@ -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'))
})
})

View File

@ -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()
})
})