chore: add more tests
This commit is contained in:
parent
dbe8221d69
commit
b327c6e55b
|
@ -1,8 +1,6 @@
|
||||||
import { appInit, setMasterDetail } from '../actions/app';
|
import { connectRequest, connectSuccess, disconnect } from '../actions/connect';
|
||||||
import { initialState } from './connect';
|
import { initialState } from './connect';
|
||||||
import { mockedStore } from './mockedStore';
|
import { mockedStore } from './mockedStore';
|
||||||
// import { RootEnum } from '../definitions';
|
|
||||||
import { APP_STATE } from '../actions/actionsTypes';
|
|
||||||
|
|
||||||
describe('test reducer', () => {
|
describe('test reducer', () => {
|
||||||
it('should return initial state', () => {
|
it('should return initial state', () => {
|
||||||
|
@ -10,35 +8,21 @@ describe('test reducer', () => {
|
||||||
expect(meteor).toEqual(initialState);
|
expect(meteor).toEqual(initialState);
|
||||||
});
|
});
|
||||||
|
|
||||||
// it('should return root state after dispatch appStart action', () => {
|
it('should return correct meteor state after dispatch connectRequest action', () => {
|
||||||
// mockedStore.dispatch(appStart({ root: RootEnum.ROOT_INSIDE }));
|
mockedStore.dispatch(connectRequest());
|
||||||
// const { root } = mockedStore.getState().app;
|
const { meteor } = mockedStore.getState();
|
||||||
// expect(root).toEqual(RootEnum.ROOT_INSIDE);
|
expect(meteor).toEqual({ connecting: true, connected: false });
|
||||||
// });
|
|
||||||
|
|
||||||
it('should return ready state after dispatch appInit action', () => {
|
|
||||||
mockedStore.dispatch(appInit());
|
|
||||||
const { ready } = mockedStore.getState().app;
|
|
||||||
expect(ready).toEqual(false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return ready state after dispatch setMasterDetail action', () => {
|
it('should return correct meteor state after dispatch connectSuccess action', () => {
|
||||||
mockedStore.dispatch(setMasterDetail(false));
|
mockedStore.dispatch(connectSuccess());
|
||||||
const { isMasterDetail } = mockedStore.getState().app;
|
const { meteor } = mockedStore.getState();
|
||||||
expect(isMasterDetail).toEqual(false);
|
expect(meteor).toEqual({ connecting: false, connected: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return correct state after app go to foreground', () => {
|
it('should return correct meteor state after dispatch disconnect action', () => {
|
||||||
mockedStore.dispatch({ type: APP_STATE.FOREGROUND });
|
mockedStore.dispatch(disconnect());
|
||||||
const { foreground, background } = mockedStore.getState().app;
|
const { meteor } = mockedStore.getState();
|
||||||
expect(foreground).toEqual(true);
|
expect(meteor).toEqual(initialState);
|
||||||
expect(background).toEqual(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return correct state after app go to background', () => {
|
|
||||||
mockedStore.dispatch({ type: APP_STATE.BACKGROUND });
|
|
||||||
const { foreground, background } = mockedStore.getState().app;
|
|
||||||
expect(foreground).toEqual(false);
|
|
||||||
expect(background).toEqual(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue