-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Sidebar.spec.js
46 lines (41 loc) · 1.07 KB
/
Sidebar.spec.js
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
import React from 'react'
import { shallow } from 'enzyme'
import { Menu } from 'semantic-ui-react'
import { Sidebar } from '../components/Sidebar/index.jsx'
describe('<Sidebar />', () => {
window.require = jest.fn()
const wrapper = shallow(<Sidebar _id={0} />)
const withoutAuthRoutes = ['/', '/pattern', '/setting', '/about', '/login']
const authRoutes = [
'/',
'/pattern',
'/sheet',
'/redHeartList',
'/recentList',
'/trashList',
'/setting',
'/about',
'/personal'
]
test('navlink worked as expectly', () => {
let index = 0
wrapper.find(Menu.Item).forEach(l => {
expect(l.props().to).toBe(withoutAuthRoutes[index++])
})
})
test('navlink active class', () => {
expect(
wrapper
.find(Menu.Item)
.first()
.props().activeClassName
).toBe('active')
})
test('after login, navlink change', () => {
let wrapperWithId = shallow(<Sidebar _id={1} />)
let index = 0
wrapperWithId.find(Menu.Item).forEach(l => {
expect(l.props().to).toMatch(authRoutes[index++])
})
})
})