Skip to content

Commit b7f6a1f

Browse files
authored
Merge pull request #284 from hhubik/settings-reducer-test
test(settings): Added settingsReducer unit tests
2 parents 0e4676d + 0709a56 commit b7f6a1f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import {
2+
initialState,
3+
settingsReducer,
4+
ActionSettingsChangeTheme,
5+
ActionSettingsChangeAnimationsPage,
6+
ActionSettingsChangeAnimationsPageDisabled,
7+
ActionSettingsChangeAnimationsElements,
8+
ActionSettingsChangeAutoNightMode
9+
} from './settings.reducer';
10+
11+
describe('SettingsReducer', () => {
12+
it('should return default state', () => {
13+
const action = {} as any;
14+
const state = settingsReducer(undefined, action);
15+
expect(state).toBe(initialState);
16+
});
17+
18+
it('should update theme', () => {
19+
const action = new ActionSettingsChangeTheme({ theme: 'dark' });
20+
const state = settingsReducer(undefined, action);
21+
expect(state.theme).toEqual('dark');
22+
});
23+
24+
it('should update pageAnimations', () => {
25+
const action = new ActionSettingsChangeAnimationsPage({
26+
pageAnimations: false
27+
});
28+
const state = settingsReducer(undefined, action);
29+
expect(state.pageAnimations).toEqual(false);
30+
});
31+
32+
it('should update pageAnimationsDisabled and pageAnimations', () => {
33+
const action = new ActionSettingsChangeAnimationsPageDisabled({
34+
pageAnimationsDisabled: true
35+
});
36+
const state = settingsReducer(undefined, action);
37+
expect(state.pageAnimationsDisabled).toEqual(true);
38+
expect(state.pageAnimations).toEqual(false);
39+
});
40+
41+
it('should update elementsAnimations', () => {
42+
const action = new ActionSettingsChangeAnimationsElements({
43+
elementsAnimations: false
44+
});
45+
const state = settingsReducer(undefined, action);
46+
expect(state.elementsAnimations).toEqual(false);
47+
});
48+
49+
it('should update autoNightMode', () => {
50+
const action = new ActionSettingsChangeAutoNightMode({
51+
autoNightMode: true
52+
});
53+
const state = settingsReducer(undefined, action);
54+
expect(state.autoNightMode).toEqual(true);
55+
});
56+
});

0 commit comments

Comments
 (0)