forked from 10up/block-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reducer.test.js
93 lines (82 loc) · 2.53 KB
/
reducer.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
import reducer from './reducer';
import { registerIconSet, removeIconSet } from './actions';
describe( 'icon store | reducer', () => {
test('adding iconSets to existing store', () => {
const state = {
iconSets: {
dashicons: {
name: 'dashicons',
label: 'Dashicons',
icons: [
{
name: 'dashicons-menu',
label: 'Menu',
}
]
},
}
};
const newIconsSetData = {
name: 'example/theme',
label: "Example",
icons: [
{
source: 'test-string',
name: "search",
label: "Search"
}
]
};
const registerIconAction = registerIconSet(newIconsSetData);
const newState = reducer(state, registerIconAction);
expect(newState).toMatchSnapshot();
})
test('adding iconSets to empty store', () => {
const state = {
iconSets: {}
};
const newIconsSetData = {
name: 'example/theme',
label: "Example",
icons: [
{
source: 'test-string',
name: "search",
label: "Search"
}
]
};
const registerIconAction = registerIconSet(newIconsSetData);
const newState = reducer(state, registerIconAction);
expect(newState).toMatchSnapshot();
})
test('removing iconSets', () => {
const state = {
iconSets: {
dashicons: {
name: 'dashicons',
label: 'Dashicons',
icons: [
{
name: 'dashicons-menu',
label: 'Menu',
}
]
},
theme: {
name: 'theme',
label: 'Theme',
icons: [
{
name: 'theme-menu',
label: 'Menu',
}
]
}
}
};
const removeIconAction = removeIconSet('dashicons');
const newState = reducer(state, removeIconAction);
expect(newState).toMatchSnapshot();
})
} )