2019-04-30 19:19:28 +02:00
|
|
|
import React from 'react'
|
2019-05-31 13:38:38 +02:00
|
|
|
import { render } from '@testing-library/react'
|
2019-04-30 19:19:28 +02:00
|
|
|
import Route from './Route'
|
2019-06-18 00:05:40 +02:00
|
|
|
import { BrowserRouter as Router } from 'react-router-dom'
|
2019-04-30 19:19:28 +02:00
|
|
|
|
|
|
|
describe('Route', () => {
|
|
|
|
it('renders without crashing', () => {
|
2019-06-18 00:05:40 +02:00
|
|
|
const { container } = render(
|
|
|
|
<Router>
|
|
|
|
<Route title="Hello Title">Hello</Route>
|
|
|
|
</Router>
|
|
|
|
)
|
2019-04-30 19:19:28 +02:00
|
|
|
expect(container.firstChild).toBeInTheDocument()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('renders title & description', () => {
|
|
|
|
const { container } = render(
|
2019-06-18 00:05:40 +02:00
|
|
|
<Router>
|
|
|
|
<Route title="Hello Title" description="Hello Description">
|
|
|
|
Hello
|
|
|
|
</Route>
|
|
|
|
</Router>
|
2019-04-30 19:19:28 +02:00
|
|
|
)
|
|
|
|
expect(container.querySelector('.title')).toHaveTextContent(
|
|
|
|
'Hello Title'
|
|
|
|
)
|
|
|
|
expect(container.querySelector('.description')).toHaveTextContent(
|
|
|
|
'Hello Description'
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|