2022-02-28 18:00:47 +00:00
|
|
|
import { IPreferences } from '../definitions';
|
|
|
|
import { setAllPreferences, setPreference } from '../actions/sortPreferences';
|
|
|
|
import { mockedStore } from './mockedStore';
|
|
|
|
import { initialState } from './sortPreferences';
|
2022-04-28 18:45:00 +00:00
|
|
|
import { DisplayMode, SortBy } from '../lib/constants';
|
2022-02-28 18:00:47 +00:00
|
|
|
|
|
|
|
describe('test sortPreferences reducer', () => {
|
|
|
|
it('should return initial state', () => {
|
|
|
|
const state = mockedStore.getState().sortPreferences;
|
|
|
|
expect(state).toEqual(initialState);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return correctly value after call setPreference action', () => {
|
|
|
|
const preferences: IPreferences = {
|
|
|
|
displayMode: DisplayMode.Condensed,
|
|
|
|
groupByType: true,
|
|
|
|
showAvatar: true,
|
|
|
|
showFavorites: true,
|
|
|
|
showUnread: true,
|
|
|
|
sortBy: SortBy.Activity
|
|
|
|
};
|
|
|
|
mockedStore.dispatch(setAllPreferences(preferences));
|
|
|
|
const state = mockedStore.getState().sortPreferences;
|
|
|
|
expect(state).toEqual(preferences);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should return correctly value after call setPreference action', () => {
|
|
|
|
const preference: Partial<IPreferences> = {
|
|
|
|
displayMode: DisplayMode.Expanded
|
|
|
|
};
|
|
|
|
mockedStore.dispatch(setPreference(preference));
|
|
|
|
const { displayMode } = mockedStore.getState().sortPreferences;
|
|
|
|
expect(displayMode).toEqual(DisplayMode.Expanded);
|
|
|
|
});
|
|
|
|
});
|