portfolio/src/components/organisms/Header.test.jsx

28 lines
814 B
React
Raw Normal View History

2019-04-16 21:21:01 +02:00
import React from 'react'
2019-11-11 23:46:47 +01:00
import { render, cleanup, wait } from '@testing-library/react'
2019-11-10 14:40:45 +01:00
import { useStaticQuery } from 'gatsby'
2019-04-16 21:21:01 +02:00
import Header from './Header'
import data from '../../../jest/__fixtures__/meta.json'
describe('Header', () => {
beforeEach(() => {
2019-11-10 14:40:45 +01:00
useStaticQuery.mockImplementation(() => {
2019-11-11 23:46:47 +01:00
return { ...data }
2019-11-10 14:40:45 +01:00
})
2019-04-16 21:21:01 +02:00
})
2019-11-11 23:46:47 +01:00
afterEach(cleanup)
it('renders correctly', async () => {
const { container } = render(<Header />)
await wait(() => container.firstChild)
2019-04-16 21:21:01 +02:00
expect(container.firstChild).toBeInTheDocument()
})
2019-04-28 15:01:38 +02:00
2019-11-11 23:46:47 +01:00
it('Availability can be hidden', async () => {
const { container } = render(<Header minimal={true} />)
await wait(() => container.querySelector('.availability'))
2019-04-28 15:01:38 +02:00
expect(container.querySelector('.availability')).not.toBeInTheDocument()
})
2019-04-16 21:21:01 +02:00
})