forked from ethereum/mist
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreducer.test.js
More file actions
73 lines (62 loc) · 2.45 KB
/
reducer.test.js
File metadata and controls
73 lines (62 loc) · 2.45 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
61
62
63
64
65
66
67
68
69
70
71
72
73
import { assert } from 'chai';
import reducer, { initialState } from '../../../../modules/core/ui/reducer';
describe('the ui reducer', () => {
it('should return a default initial state', () => {
assert.deepEqual(reducer(undefined, {}), initialState);
});
it('should handle the "[MAIN]:APP_QUIT:SUCCESS" action', () => {
const action = { type: '[MAIN]:APP_QUIT:SUCCESS' };
const expectedState = Object.assign({}, initialState, {
appQuit: true
});
assert.deepEqual(reducer(initialState, action), expectedState);
});
it('should handle the "[MAIN]:WINDOW:OPEN" action', () => {
const state = Object.assign({}, initialState, {
windowsOpen: ['about']
});
const action = {
type: '[MAIN]:WINDOW:OPEN',
payload: { windowType: 'importAccount' },
};
const expectedState = Object.assign({}, state, {
windowsOpen: ['about', 'importAccount']
});
assert.deepEqual(reducer(state, action), expectedState);
});
it('should handle the "[MAIN]:WINDOW:CLOSE" action', () => {
const state = Object.assign({}, initialState, {
windowsOpen: ['about', 'importAccount']
});
const action = {
type: '[MAIN]:WINDOW:CLOSE',
payload: { windowType: 'importAccount' },
};
const expectedState = Object.assign({}, state, {
windowsOpen: ['about']
});
assert.deepEqual(reducer(state, action), expectedState);
});
it('should handle the "[MAIN]:GENERIC_WINDOW:REUSE" action', () => {
const action = {
type: '[MAIN]:GENERIC_WINDOW:REUSE',
payload: { actingType: 'about' },
};
const expectedState = Object.assign({}, initialState, {
genericWindowActingType: 'about',
windowsOpen: ['generic'],
});
assert.deepEqual(reducer(initialState, action), expectedState);
});
it('should handle the "[MAIN]:GENERIC_WINDOW:RESET" action', () => {
const state = Object.assign({}, initialState, {
genericWindowActingType: 'about',
windowsOpen: ['generic', 'main'],
});
const action = { type: '[MAIN]:GENERIC_WINDOW:RESET' };
const expectedState = Object.assign({}, initialState, {
windowsOpen: ['main'],
});
assert.deepEqual(reducer(state, action), expectedState);
});
});