Skip to content

Commit

Permalink
Merge pull request #284 from hhubik/settings-reducer-test
Browse files Browse the repository at this point in the history
test(settings): Added settingsReducer unit tests
  • Loading branch information
tomastrajan authored Jul 19, 2018
2 parents 0e4676d + 0709a56 commit b7f6a1f
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/app/settings/settings.reducer.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
initialState,
settingsReducer,
ActionSettingsChangeTheme,
ActionSettingsChangeAnimationsPage,
ActionSettingsChangeAnimationsPageDisabled,
ActionSettingsChangeAnimationsElements,
ActionSettingsChangeAutoNightMode
} from './settings.reducer';

describe('SettingsReducer', () => {
it('should return default state', () => {
const action = {} as any;
const state = settingsReducer(undefined, action);
expect(state).toBe(initialState);
});

it('should update theme', () => {
const action = new ActionSettingsChangeTheme({ theme: 'dark' });
const state = settingsReducer(undefined, action);
expect(state.theme).toEqual('dark');
});

it('should update pageAnimations', () => {
const action = new ActionSettingsChangeAnimationsPage({
pageAnimations: false
});
const state = settingsReducer(undefined, action);
expect(state.pageAnimations).toEqual(false);
});

it('should update pageAnimationsDisabled and pageAnimations', () => {
const action = new ActionSettingsChangeAnimationsPageDisabled({
pageAnimationsDisabled: true
});
const state = settingsReducer(undefined, action);
expect(state.pageAnimationsDisabled).toEqual(true);
expect(state.pageAnimations).toEqual(false);
});

it('should update elementsAnimations', () => {
const action = new ActionSettingsChangeAnimationsElements({
elementsAnimations: false
});
const state = settingsReducer(undefined, action);
expect(state.elementsAnimations).toEqual(false);
});

it('should update autoNightMode', () => {
const action = new ActionSettingsChangeAutoNightMode({
autoNightMode: true
});
const state = settingsReducer(undefined, action);
expect(state.autoNightMode).toEqual(true);
});
});

0 comments on commit b7f6a1f

Please sign in to comment.