chore: exprot initial state and then import on tests
This commit is contained in:
parent
d12b28b5f5
commit
f0977ddb22
|
@ -1,11 +1,11 @@
|
||||||
import { setActiveUsers } from '../actions/activeUsers';
|
import { setActiveUsers } from '../actions/activeUsers';
|
||||||
import { IActiveUsers } from './activeUsers';
|
import { IActiveUsers, initialState } from './activeUsers';
|
||||||
import { mockedStore } from './mockedStore';
|
import { mockedStore } from './mockedStore';
|
||||||
|
|
||||||
describe('test reducer', () => {
|
describe('test reducer', () => {
|
||||||
it('should return {} as initial state', () => {
|
it('should return initial state', () => {
|
||||||
const state = mockedStore.getState().activeUsers;
|
const state = mockedStore.getState().activeUsers;
|
||||||
expect(state).toEqual({});
|
expect(state).toEqual(initialState);
|
||||||
});
|
});
|
||||||
it('should return modified store after action', () => {
|
it('should return modified store after action', () => {
|
||||||
const activeUsers: IActiveUsers = { any: { status: 'online', statusText: 'any' } };
|
const activeUsers: IActiveUsers = { any: { status: 'online', statusText: 'any' } };
|
||||||
|
|
|
@ -5,7 +5,7 @@ export interface IActiveUsers {
|
||||||
[key: string]: ActiveUser;
|
[key: string]: ActiveUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: IActiveUsers = {};
|
export const initialState: IActiveUsers = {};
|
||||||
|
|
||||||
export default function activeUsers(state = initialState, action: ApplicationActions): IActiveUsers {
|
export default function activeUsers(state = initialState, action: ApplicationActions): IActiveUsers {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import { addUser, reset, setLoading, removeUser } from '../actions/selectedUsers';
|
import { addUser, reset, setLoading, removeUser } from '../actions/selectedUsers';
|
||||||
import { mockedStore } from './mockedStore';
|
import { mockedStore } from './mockedStore';
|
||||||
|
import { initialState } from './selectedUsers';
|
||||||
|
|
||||||
describe('test selectedUsers reducer', () => {
|
describe('test selectedUsers reducer', () => {
|
||||||
const initialState = {
|
|
||||||
users: [],
|
|
||||||
loading: false
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should return initial state', () => {
|
it('should return initial state', () => {
|
||||||
const state = mockedStore.getState().selectedUsers;
|
const state = mockedStore.getState().selectedUsers;
|
||||||
expect(state).toEqual(initialState);
|
expect(state).toEqual(initialState);
|
||||||
|
@ -26,7 +22,7 @@ describe('test selectedUsers reducer', () => {
|
||||||
expect(state).toEqual([]);
|
expect(state).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return initialState after reset', () => {
|
it('should return initial state after reset', () => {
|
||||||
mockedStore.dispatch(reset());
|
mockedStore.dispatch(reset());
|
||||||
const state = mockedStore.getState().selectedUsers;
|
const state = mockedStore.getState().selectedUsers;
|
||||||
expect(state).toEqual(initialState);
|
expect(state).toEqual(initialState);
|
||||||
|
|
|
@ -6,7 +6,7 @@ export interface ISelectedUsers {
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: ISelectedUsers = {
|
export const initialState: ISelectedUsers = {
|
||||||
users: [],
|
users: [],
|
||||||
loading: false
|
loading: false
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue