test: create activeUser and selectedUser tests
This commit is contained in:
parent
69f27438b2
commit
b80c0635d6
|
@ -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 });
|
||||
});
|
||||
});
|
|
@ -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] });
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue