This repository was archived by the owner on Apr 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
/
Copy pathNodeView.test.tsx
73 lines (66 loc) · 2.24 KB
/
NodeView.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { shallow } from "enzyme"
import { shallowToJson } from "enzyme-to-json"
import * as React from "react"
import { DragAndDrop } from "./../browser/src/Services/DragAndDrop"
import { ExplorerNode } from "./../browser/src/Services/Explorer/ExplorerSelectors"
import { NodeView, NodeWrapper } from "./../browser/src/Services/Explorer/ExplorerView"
import { TextInputView } from "./../browser/src/UI/components/LightweightText"
describe("<NodeView />", () => {
const testNode = {
id: "2",
filePath: "/test/a/file.txt",
type: "file",
modified: false,
name: "file.txt",
indentationLevel: 2,
} as ExplorerNode
const Node = (
<NodeView
yanked={[] as string[]}
measure={() => null}
isCreating={false}
isRenaming={testNode}
moveFileOrFolder={() => ({})}
node={testNode}
isSelected={false}
onClick={() => ({})}
onCancelRename={() => ({})}
onCompleteRename={() => ({})}
/>
)
it("Should render without crashing", () => {
const wrapper = shallow(Node)
expect(wrapper.length).toEqual(1)
})
it("Should render and input element if the selected element is renaming", () => {
const wrapper = shallow(
<NodeView
yanked={[] as string[]}
measure={() => null}
isCreating={false}
isRenaming={testNode}
moveFileOrFolder={() => ({})}
node={testNode}
isSelected={true}
onClick={() => ({})}
onCancelRename={() => ({})}
onCompleteRename={() => ({})}
/>,
)
const input = wrapper.find(TextInputView)
expect(input.length).toEqual(1)
})
it("Should render the node if the selected element is not renaming", () => {
const wrapper = shallow(Node)
expect(
wrapper
.find(NodeWrapper)
.dive()
.find(DragAndDrop),
).toHaveLength(1)
})
it("Should match the snapshot", () => {
const wrapper = shallow(Node)
expect(shallowToJson(wrapper)).toMatchSnapshot()
})
})