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
/
Breadcrumbs.test.tsx
58 lines (48 loc) · 1.63 KB
/
Breadcrumbs.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
import '../../__mocks__/matchMediaMock'
import React from 'react'
import { Provider } from 'react-redux'
import { mount } from 'enzyme'
import { createMemoryHistory } from 'history'
import { Router } from 'react-router-dom'
import configureMockStore from 'redux-mock-store'
import {
Breadcrumb as HRBreadcrumb,
BreadcrumbItem as HRBreadcrumbItem,
} from '@hospitalrun/components'
import Breadcrumbs from 'breadcrumbs/Breadcrumbs'
import Breadcrumb from 'model/Breadcrumb'
const mockStore = configureMockStore()
describe('Breadcrumbs', () => {
const setup = (breadcrumbs: Breadcrumb[]) => {
const history = createMemoryHistory()
const store = mockStore({
breadcrumbs: { breadcrumbs },
})
const wrapper = mount(
<Provider store={store}>
<Router history={history}>
<Breadcrumbs />
</Router>
</Provider>,
)
return wrapper
}
it('should not render the breadcrumb when there are no items in the store', () => {
const wrapper = setup([])
expect(wrapper.find(HRBreadcrumb)).toHaveLength(0)
expect(wrapper.find(HRBreadcrumbItem)).toHaveLength(0)
})
it('should render breadcrumbs items', () => {
const breadcrumbs = [
{ i18nKey: 'patient.label', location: '/patient' },
{ text: 'Bob', location: '/patient/1' },
{ text: 'Edit Patient', location: '/patient/1/edit' },
]
const wrapper = setup(breadcrumbs)
const items = wrapper.find(HRBreadcrumbItem)
expect(items).toHaveLength(3)
expect(items.at(0).text()).toEqual('patient.label')
expect(items.at(1).text()).toEqual('Bob')
expect(items.at(2).text()).toEqual('Edit Patient')
})
})