mirror of
https://github.com/kremalicious/portfolio.git
synced 2025-02-14 21:10:41 +01:00
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
import React from 'react'
|
|
import { render } from '@testing-library/react'
|
|
import Availability from './Availability'
|
|
import { useStaticQuery } from 'gatsby'
|
|
|
|
describe('Availability', () => {
|
|
it('renders correctly from data file values', () => {
|
|
const { container } = render(<Availability />)
|
|
expect(container.firstChild).toBeInTheDocument()
|
|
})
|
|
|
|
it('renders correctly when status: true', () => {
|
|
useStaticQuery.mockImplementationOnce(() => {
|
|
return {
|
|
metaYaml: {
|
|
availability: {
|
|
status: true,
|
|
available: 'I am available.',
|
|
unavailable: 'Not available.'
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
const { container } = render(<Availability />)
|
|
expect(container.firstChild).toBeInTheDocument()
|
|
expect(container.firstChild).toHaveTextContent('I am available.')
|
|
})
|
|
|
|
it('renders correctly when status: false', () => {
|
|
useStaticQuery.mockImplementationOnce(() => {
|
|
return {
|
|
metaYaml: {
|
|
availability: {
|
|
status: false,
|
|
available: 'I am available.',
|
|
unavailable: 'Not available.'
|
|
}
|
|
}
|
|
}
|
|
})
|
|
|
|
const { container } = render(<Availability />)
|
|
expect(container.firstChild).toBeInTheDocument()
|
|
expect(container.firstChild).toHaveTextContent('Not available.')
|
|
})
|
|
|
|
it('can be hidden', () => {
|
|
const { container } = render(<Availability hide={true} />)
|
|
expect(container.firstChild).not.toBeInTheDocument()
|
|
})
|
|
})
|