chore: exprot initial state and then import on tests

This commit is contained in:
GleidsonDaniel 2021-12-22 16:33:39 -03:00
parent d12b28b5f5
commit f0977ddb22
4 changed files with 7 additions and 11 deletions

View File

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

View File

@ -5,7 +5,7 @@ export interface IActiveUsers {
[key: string]: ActiveUser;
}
const initialState: IActiveUsers = {};
export const initialState: IActiveUsers = {};
export default function activeUsers(state = initialState, action: ApplicationActions): IActiveUsers {
switch (action.type) {

View File

@ -1,12 +1,8 @@
import { addUser, reset, setLoading, removeUser } from '../actions/selectedUsers';
import { mockedStore } from './mockedStore';
import { initialState } from './selectedUsers';
describe('test selectedUsers reducer', () => {
const initialState = {
users: [],
loading: false
};
it('should return initial state', () => {
const state = mockedStore.getState().selectedUsers;
expect(state).toEqual(initialState);
@ -26,7 +22,7 @@ describe('test selectedUsers reducer', () => {
expect(state).toEqual([]);
});
it('should return initialState after reset', () => {
it('should return initial state after reset', () => {
mockedStore.dispatch(reset());
const state = mockedStore.getState().selectedUsers;
expect(state).toEqual(initialState);

View File

@ -6,7 +6,7 @@ export interface ISelectedUsers {
loading: boolean;
}
const initialState: ISelectedUsers = {
export const initialState: ISelectedUsers = {
users: [],
loading: false
};