1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-10-31 23:35:29 +01:00
portfolio/src/components/organisms/Header.test.jsx

32 lines
1007 B
React
Raw Normal View History

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'
2019-11-09 19:12:58 +01:00
import Context from '../../store/createContext'
2019-04-16 21:21:01 +02:00
import data from '../../../jest/__fixtures__/meta.json'
describe('Header', () => {
beforeEach(() => {
StaticQuery.mockImplementation(({ render }) => render({ ...data }))
useStaticQuery.mockImplementation(() => ({ ...data }))
})
it('renders correctly', () => {
const { container } = render(
<Context.Provider value={{ darkMode: false, toggleDark: () => null }}>
2019-04-16 21:21:01 +02:00
<Header />
2019-11-09 19:12:58 +01:00
</Context.Provider>
2019-04-16 21:21:01 +02:00
)
expect(container.firstChild).toBeInTheDocument()
})
2019-04-28 15:01:38 +02:00
it('Availability can be hidden', () => {
const { container } = render(
<Context.Provider value={{ darkMode: false, toggleDark: () => null }}>
2019-04-28 15:01:38 +02:00
<Header minimal={true} />
2019-11-09 19:12:58 +01:00
</Context.Provider>
2019-04-28 15:01:38 +02:00
)
expect(container.querySelector('.availability')).not.toBeInTheDocument()
})
2019-04-16 21:21:01 +02:00
})