This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Breadcrumb.test.tsx
61 lines (54 loc) · 2.12 KB
/
Breadcrumb.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import '../../../__mocks__/matchMediaMock'
import React from 'react'
import { Router } from 'react-router'
import { Provider } from 'react-redux'
import { mount } from 'enzyme'
import configureMockStore from 'redux-mock-store'
import { createMemoryHistory } from 'history'
import DefaultBreadcrumb from 'components/breadcrumb/DefaultBreadcrumb'
import PatientBreadcrumb from 'components/breadcrumb/PatientBreadcrumb'
import AppointmentBreadcrumb from 'components/breadcrumb/AppointmentBreadcrumb'
import Breadcrumb from 'components/breadcrumb/Breadcrumb'
const mockStore = configureMockStore()
describe('Breadcrumb', () => {
const setup = (location: string) => {
const history = createMemoryHistory()
history.push(location)
return mount(
<Provider
store={mockStore({
patient: { patient: {} },
appointment: { appointment: {} },
})}
>
<Router history={history}>
<Breadcrumb />
</Router>
</Provider>,
)
}
it('should render the patient breadcrumb when /patients/:id is accessed', () => {
const wrapper = setup('/patients/1234')
expect(wrapper.find(PatientBreadcrumb)).toHaveLength(1)
})
it('should render the appointment breadcrumb when /appointments/:id is accessed', () => {
const wrapper = setup('/appointments/1234')
expect(wrapper.find(AppointmentBreadcrumb)).toHaveLength(1)
})
it('should render the default breadcrumb when /patients/new is accessed', () => {
const wrapper = setup('/patients/new')
expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)
})
it('should render the default breadcrumb when /appointments/new is accessed', () => {
const wrapper = setup('/appointments/new')
expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)
})
it('should render the default breadcrumb when any other path is accessed', () => {
let wrapper = setup('/appointments')
expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)
wrapper = setup('/patients')
expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)
wrapper = setup('/')
expect(wrapper.find(DefaultBreadcrumb)).toHaveLength(1)
})
})