Team tests (ongoing)

This commit is contained in:
Rodrigo Pedroso 2019-07-25 23:45:01 -04:00
commit 97509a85d7
7 changed files with 283 additions and 230 deletions

31
src/views/Team.test.js Normal file
View 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')
})
})