2019-04-16 21:21:01 +02:00
|
|
|
import React from 'react'
|
2019-05-30 22:55:12 +02:00
|
|
|
import { render } from '@testing-library/react'
|
2019-04-16 21:21:01 +02:00
|
|
|
import { StaticQuery, useStaticQuery } from 'gatsby'
|
|
|
|
import Header from './Header'
|
|
|
|
import { Provider } from '../../store/createContext'
|
|
|
|
import data from '../../../jest/__fixtures__/meta.json'
|
|
|
|
|
|
|
|
describe('Header', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
StaticQuery.mockImplementation(({ render }) => render({ ...data }))
|
|
|
|
useStaticQuery.mockImplementation(() => ({ ...data }))
|
|
|
|
})
|
|
|
|
|
|
|
|
it('renders correctly', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<Provider value={{ dark: false, toggleDark: () => null }}>
|
|
|
|
<Header />
|
|
|
|
</Provider>
|
|
|
|
)
|
|
|
|
expect(container.firstChild).toBeInTheDocument()
|
|
|
|
})
|
2019-04-28 15:01:38 +02:00
|
|
|
|
|
|
|
it('Availability can be hidden', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<Provider value={{ dark: false, toggleDark: () => null }}>
|
|
|
|
<Header minimal={true} />
|
|
|
|
</Provider>
|
|
|
|
)
|
|
|
|
expect(container.querySelector('.availability')).not.toBeInTheDocument()
|
|
|
|
})
|
2019-04-16 21:21:01 +02:00
|
|
|
})
|