-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathactions.test.js
188 lines (173 loc) · 4.86 KB
/
actions.test.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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import animals from '../utils/data/animals.mock';
import {
CHANGE_FLAG,
RESET_DATA,
TOGGLE_LAYERS,
TOGGLE_EXPORT_MODAL,
TOGGLE_SIDEBAR,
TOGGLE_TEXT_LABELS,
TOGGLE_THEME,
UPDATE_CHART_SIZE,
UPDATE_FONT_LOADED,
changeFlag,
resetData,
toggleLayers,
toggleExportModal,
toggleSidebar,
toggleTextLabels,
toggleTheme,
updateChartSize,
updateFontLoaded
} from '../actions';
import {
TOGGLE_NODE_CLICKED,
TOGGLE_NODES_DISABLED,
TOGGLE_NODE_HOVERED,
toggleNodeClicked,
toggleNodesDisabled,
toggleNodeHovered
} from '../actions/nodes';
import {
TOGGLE_TAG_ACTIVE,
TOGGLE_TAG_FILTER,
toggleTagActive,
toggleTagFilter
} from '../actions/tags';
import { TOGGLE_TYPE_DISABLED, toggleTypeDisabled } from '../actions/node-type';
describe('actions', () => {
it('should create an action to reset pipeline data', () => {
const expectedAction = {
type: RESET_DATA,
data: animals
};
expect(resetData(animals)).toEqual(expectedAction);
});
it('should create an action to toggle whether to show layers', () => {
const visible = false;
const expectedAction = {
type: TOGGLE_LAYERS,
visible
};
expect(toggleLayers(visible)).toEqual(expectedAction);
});
it('should create an action to toggle whether to show the export modal', () => {
const visible = false;
const expectedAction = {
type: TOGGLE_EXPORT_MODAL,
visible
};
expect(toggleExportModal(visible)).toEqual(expectedAction);
});
it('should create an action to toggle whether the sidebar is open', () => {
const visible = false;
const expectedAction = {
type: TOGGLE_SIDEBAR,
visible
};
expect(toggleSidebar(visible)).toEqual(expectedAction);
});
it('should create an action to toggle whether a node has been clicked', () => {
const nodeClicked = '12367890';
const expectedAction = {
type: TOGGLE_NODE_CLICKED,
nodeClicked
};
expect(toggleNodeClicked(nodeClicked)).toEqual(expectedAction);
});
it('should create an action to toggle whether a node has been clicked', () => {
const nodeHovered = '12367890';
const expectedAction = {
type: TOGGLE_NODE_HOVERED,
nodeHovered
};
expect(toggleNodeHovered(nodeHovered)).toEqual(expectedAction);
});
it('should create an action to toggle whether somes nodes are disabled', () => {
const nodeIDs = ['12367890', '0987654321', 'qwertyuiop'];
const isDisabled = false;
const expectedAction = {
type: TOGGLE_NODES_DISABLED,
nodeIDs,
isDisabled
};
expect(toggleNodesDisabled(nodeIDs, isDisabled)).toEqual(expectedAction);
});
it('should create an action to toggle whether to show text labels on/off', () => {
const textLabels = false;
const expectedAction = {
type: TOGGLE_TEXT_LABELS,
textLabels
};
expect(toggleTextLabels(textLabels)).toEqual(expectedAction);
});
it("should create an action to toggle a tag's active state on/off", () => {
const tagID = '1234567890';
const active = false;
const expectedAction = {
type: TOGGLE_TAG_ACTIVE,
tagID,
active
};
expect(toggleTagActive(tagID, active)).toEqual(expectedAction);
});
it('should create an action to toggle a tag on/off', () => {
const tagID = '1234567890';
const enabled = false;
const expectedAction = {
type: TOGGLE_TAG_FILTER,
tagID,
enabled
};
expect(toggleTagFilter(tagID, enabled)).toEqual(expectedAction);
});
it('should create an action to toggle the theme', () => {
const theme = 'light';
const expectedAction = {
type: TOGGLE_THEME,
theme
};
expect(toggleTheme(theme)).toEqual(expectedAction);
});
it('should create an action to toggle whether a type is disabled', () => {
const typeID = '123';
const disabled = true;
const expectedAction = {
type: TOGGLE_TYPE_DISABLED,
typeID,
disabled
};
expect(toggleTypeDisabled(typeID, disabled)).toEqual(expectedAction);
});
it('should create an action to update the chart size', () => {
const chartSize = {
x: 10,
y: 20,
outerWidth: 30,
outerHeight: 40,
width: 50,
height: 60,
navOffset: 70
};
const expectedAction = {
type: UPDATE_CHART_SIZE,
chartSize
};
expect(updateChartSize(chartSize)).toEqual(expectedAction);
});
it('should create an action to update the state when the webfont has loaded', () => {
const fontLoaded = true;
const expectedAction = {
type: UPDATE_FONT_LOADED,
fontLoaded
};
expect(updateFontLoaded(fontLoaded)).toEqual(expectedAction);
});
it('should create an action to change a flag', () => {
const expectedAction = {
type: CHANGE_FLAG,
name: 'testFlag',
value: true
};
expect(changeFlag('testFlag', true)).toEqual(expectedAction);
});
});