-
-
Notifications
You must be signed in to change notification settings - Fork 756
/
Copy pathhistory.test.js
105 lines (100 loc) · 1.96 KB
/
history.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
import history from './history';
import {
GET_HISTORY,
REVERT_HISTORY,
} from '@plone/volto/constants/ActionTypes';
describe('History reducer', () => {
it('should return the initial state', () => {
expect(history()).toEqual({
entries: [],
get: {
error: null,
loaded: false,
loading: false,
},
revert: {
error: null,
loaded: false,
loading: false,
},
});
});
it('should handle GET_HISTORY_PENDING', () => {
expect(
history(undefined, {
type: `${GET_HISTORY}_PENDING`,
}),
).toEqual({
entries: [],
get: {
error: null,
loaded: false,
loading: true,
},
revert: {
error: null,
loaded: false,
loading: false,
},
});
});
it('should handle GET_HISTORY_SUCCESS', () => {
expect(
history(undefined, {
type: `${GET_HISTORY}_SUCCESS`,
result: 'result',
}),
).toEqual({
entries: 'result',
get: {
error: null,
loaded: true,
loading: false,
},
revert: {
error: null,
loaded: false,
loading: false,
},
});
});
it('should handle GET_HISTORY_FAIL', () => {
expect(
history(undefined, {
type: `${GET_HISTORY}_FAIL`,
error: 'failed',
}),
).toEqual({
entries: [],
get: {
error: 'failed',
loaded: false,
loading: false,
},
revert: {
error: null,
loaded: false,
loading: false,
},
});
});
it('should handle REVERT_HISTORY_SUCCESS', () => {
expect(
history(undefined, {
type: `${REVERT_HISTORY}_SUCCESS`,
}),
).toEqual({
entries: [],
get: {
error: null,
loaded: false,
loading: false,
},
revert: {
error: null,
loaded: true,
loading: false,
},
});
});
});