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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1815 from oliv37/breadcrumbs
feat(breadcrumb): add a breadcrumb underneath the page header
- Loading branch information
Showing
20 changed files
with
463 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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') | ||
}) | ||
}) |
Oops, something went wrong.
878684c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: