test: create activeUser and selectedUser tests

This commit is contained in:
GleidsonDaniel 2021-12-21 17:14:59 -03:00
parent 69f27438b2
commit b80c0635d6
2 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import { setActiveUsers } from '../../app/actions/activeUsers';
import { IActiveUsers } from '../../app/reducers/activeUsers';
import { mockedStore } from '../../__mocks__/mockedStore';
describe('test reducer', () => {
it('should return {} as initial state', async () => {
const state = mockedStore.getState().activeUsers;
expect(state).toEqual({});
});
it('should return modified store after action', async () => {
const activeUsers: IActiveUsers = { any: { status: 'online', statusText: 'any' } };
mockedStore.dispatch(setActiveUsers(activeUsers));
const state = mockedStore.getState().activeUsers;
expect(state).toEqual({ ...activeUsers });
});
});

View File

@ -0,0 +1,20 @@
import { addUser } from '../../app/actions/selectedUsers';
import { mockedStore } from '../../__mocks__/mockedStore';
describe('test reducer', () => {
const initialState = {
users: [],
loading: false
};
it('should return initial state', async () => {
const state = mockedStore.getState().selectedUsers;
expect(state).toEqual(initialState);
});
it('should return modified store after action', async () => {
const user = { _id: 'user.id', name: 'user.username', fname: 'user.name' };
mockedStore.dispatch(addUser(user));
const state = mockedStore.getState().selectedUsers;
expect(state).toEqual({ loading: false, users: [user] });
});
});