Skip to content

Instantly share code, notes, and snippets.

@eternal44
Created July 2, 2020 00:26
Show Gist options
  • Save eternal44/350fd02baf493dc894f16f15c3748329 to your computer and use it in GitHub Desktop.
Save eternal44/350fd02baf493dc894f16f15c3748329 to your computer and use it in GitHub Desktop.
jest test example
import React from 'react'
import { render } from '@testing-library/react'
import '@testing-library/jest-dom/extend-expect'
import ERshow from '../components/ERshow'
import {
offer,
YetAnotherMUAprofileShow,
MUAoffer,
exchangeRequest,
} from './__mocks__/resources'
jest.mock('axios')
describe('ERshow', () => {
describe('renders without errors', () => {
test('renders the page correctly', () => {
const { getByText, queryByText } = render(
<ERshow
exchangeRequest={exchangeRequest}
requestingOffer={offer}
respondingOffer={MUAoffer}
respondingProfile={YetAnotherMUAprofileShow}
/>
)
expect(getByText(/Job start and end/i)).toBeInTheDocument()
expect(getByText(/match score/i)).toBeInTheDocument()
expect(queryByText(/your availability/i)).toBeNull()
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment