-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chris Maina
committed
Apr 2, 2019
1 parent
38c2753
commit a5a9668
Showing
2 changed files
with
29 additions
and
13 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
36 changes: 26 additions & 10 deletions
36
src/app/Sidebar/components/tests/SidebarContainer.test.js
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 |
---|---|---|
@@ -1,21 +1,37 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { mount } from 'enzyme'; | ||
import { SidebarContainer } from '../SidebarContainer'; | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
|
||
describe('<SidebarContainer />', () => { | ||
const props = { | ||
className: '', | ||
userRole: {}, | ||
fetchUserRole: jest.fn(), | ||
toggleSidebarState: jest.fn(), | ||
} | ||
const shallowWrapper = shallow(<SidebarContainer {...props} />); | ||
const setUpWrapper = ({ userRole = {} } = {}) => { | ||
const props = { | ||
userRole, | ||
userId: '', | ||
className: '', | ||
fetchUserRole: jest.fn(), | ||
toggleSidebarState: jest.fn(), | ||
}; | ||
return mount(<Router><SidebarContainer {...props} /></Router>); | ||
}; | ||
|
||
it('should have the a nav item with text Settings', () => { | ||
expect(shallowWrapper.find('.sidebar_nav-label--footer').html()).toContain('Settings'); | ||
const wrapper = setUpWrapper(); | ||
expect(wrapper.find('.sidebar_nav-label--footer').html()).toContain('Settings'); | ||
}); | ||
|
||
it('has LogoComponent', () => { | ||
expect(shallowWrapper.find('LogoComponent')).toHaveLength(1); | ||
const wrapper = setUpWrapper(); | ||
expect(wrapper.find('LogoComponent')).toHaveLength(1); | ||
}); | ||
|
||
it('has Verify Activities navigation item', () => { | ||
const wrapper = setUpWrapper({ userRole: { 'society secretary': '12345' }}); | ||
expect(wrapper.html()).toContain('Verify-activities'); | ||
}); | ||
|
||
it('has Redemptions navigation item', () => { | ||
const wrapper = setUpWrapper({ userRole: { 'society president': '12345' }}); | ||
expect(wrapper.html()).toContain('Redemptions'); | ||
}); | ||
}); |