forked from ucfopen/Obojobo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview-menu.test.js
More file actions
60 lines (50 loc) · 1.33 KB
/
Copy pathview-menu.test.js
File metadata and controls
60 lines (50 loc) · 1.33 KB
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
import { mount, shallow } from 'enzyme'
import React from 'react'
import ViewMenu from '../../../../src/scripts/oboeditor/components/toolbars/view-menu'
const XML_MODE = 'xml'
const JSON_MODE = 'json'
const VISUAL_MODE = 'visual'
describe('ViewMenu', () => {
test('ViewMenu node', () => {
const component = shallow(<ViewMenu draftId="mock-id" mode={JSON_MODE} />)
const tree = component.html()
expect(tree).toMatchSnapshot()
})
test('ViewMenu node in XML_MODE', () => {
const save = () => ({
then: func => func()
})
const switchMode = jest.fn()
const component = mount(
<ViewMenu draftId="mock-id" onSave={save} switchMode={switchMode} mode={XML_MODE} />
)
component
.find('button')
.at(4)
.simulate('click')
expect(switchMode).toHaveBeenCalledWith(VISUAL_MODE)
})
test('ViewMenu performs actions', () => {
const save = () => ({
then: func => func()
})
const switchMode = jest.fn()
const component = mount(
<ViewMenu draftId="mock-id" onSave={save} switchMode={switchMode} mode={VISUAL_MODE} />
)
component
.find('button')
.at(2)
.simulate('click')
expect(switchMode).toHaveBeenCalledWith(JSON_MODE)
component
.find('button')
.at(3)
.simulate('click')
expect(switchMode).toHaveBeenCalledWith(XML_MODE)
component
.find('button')
.at(5)
.simulate('click')
})
})