Team tests (ongoing)
This commit is contained in:
parent
f2303fb70c
commit
97509a85d7
7 changed files with 283 additions and 230 deletions
31
src/views/Team.test.js
Normal file
31
src/views/Team.test.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
import React from 'react'
|
||||
import { render, waitForElement } from '@testing-library/react'
|
||||
import '@testing-library/jest-dom/extend-expect'
|
||||
import '@testing-library/react/cleanup-after-each'
|
||||
import axiosMock from 'axios'
|
||||
import Team from './Team'
|
||||
|
||||
describe('A team page', () => {
|
||||
it('should render without crashing', () => {
|
||||
const { getByTestId } = render(<Team />)
|
||||
|
||||
expect(getByTestId('loading')).toHaveTextContent('Loading...')
|
||||
})
|
||||
|
||||
it('should fetch and display data', async () => {
|
||||
const callData = {
|
||||
teamProps: {
|
||||
id: 3
|
||||
},
|
||||
usersProps: [{ name: 'UserName' }]
|
||||
}
|
||||
|
||||
axiosMock.get.mockResolvedValueOnce({ data: callData })
|
||||
|
||||
const address = { url: '/team3' }
|
||||
const { getByTestId } = render(<Team props={address} />)
|
||||
const resolvedSpan = await waitForElement(() => getByTestId('resolved'))
|
||||
|
||||
expeted(resolvedSpan).toHaveContent('Team')
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue