2022-02-09 20:44:53 +00:00
|
|
|
import { clearActiveUsers, setActiveUsers } from '../actions/activeUsers';
|
2022-02-18 13:53:36 +00:00
|
|
|
import { UserStatus } from '../definitions/UserStatus';
|
2022-01-11 13:48:01 +00:00
|
|
|
import { IActiveUsers, initialState } from './activeUsers';
|
|
|
|
import { mockedStore } from './mockedStore';
|
|
|
|
|
|
|
|
describe('test reducer', () => {
|
|
|
|
it('should return initial state', () => {
|
|
|
|
const state = mockedStore.getState().activeUsers;
|
|
|
|
expect(state).toEqual(initialState);
|
|
|
|
});
|
|
|
|
it('should return modified store after action', () => {
|
2022-02-18 13:53:36 +00:00
|
|
|
const activeUsers: IActiveUsers = { any: { status: UserStatus.ONLINE, statusText: 'any' } };
|
2022-01-11 13:48:01 +00:00
|
|
|
mockedStore.dispatch(setActiveUsers(activeUsers));
|
|
|
|
const state = mockedStore.getState().activeUsers;
|
|
|
|
expect(state).toEqual({ ...activeUsers });
|
|
|
|
});
|
2022-02-09 20:44:53 +00:00
|
|
|
it('should return initial state after dispatching clear', () => {
|
|
|
|
const previousState = mockedStore.getState().activeUsers;
|
|
|
|
expect(previousState).not.toBe(initialState);
|
|
|
|
mockedStore.dispatch(clearActiveUsers());
|
|
|
|
const state = mockedStore.getState().activeUsers;
|
|
|
|
expect(state).toEqual(initialState);
|
|
|
|
});
|
2022-01-11 13:48:01 +00:00
|
|
|
});
|