2022-01-12 20:09:45 +00:00
|
|
|
import { connectRequest, connectSuccess, disconnect } from '../actions/connect';
|
2022-01-12 20:08:45 +00:00
|
|
|
import { initialState } from './connect';
|
|
|
|
import { mockedStore } from './mockedStore';
|
|
|
|
|
|
|
|
describe('test reducer', () => {
|
|
|
|
it('should return initial state', () => {
|
|
|
|
const { meteor } = mockedStore.getState();
|
|
|
|
expect(meteor).toEqual(initialState);
|
|
|
|
});
|
|
|
|
|
2022-01-12 20:09:45 +00:00
|
|
|
it('should return correct meteor state after dispatch connectRequest action', () => {
|
|
|
|
mockedStore.dispatch(connectRequest());
|
|
|
|
const { meteor } = mockedStore.getState();
|
|
|
|
expect(meteor).toEqual({ connecting: true, connected: false });
|
2022-01-12 20:08:45 +00:00
|
|
|
});
|
|
|
|
|
2022-01-12 20:09:45 +00:00
|
|
|
it('should return correct meteor state after dispatch connectSuccess action', () => {
|
|
|
|
mockedStore.dispatch(connectSuccess());
|
|
|
|
const { meteor } = mockedStore.getState();
|
|
|
|
expect(meteor).toEqual({ connecting: false, connected: true });
|
2022-01-12 20:08:45 +00:00
|
|
|
});
|
|
|
|
|
2022-01-12 20:09:45 +00:00
|
|
|
it('should return correct meteor state after dispatch disconnect action', () => {
|
|
|
|
mockedStore.dispatch(disconnect());
|
|
|
|
const { meteor } = mockedStore.getState();
|
|
|
|
expect(meteor).toEqual(initialState);
|
2022-01-12 20:08:45 +00:00
|
|
|
});
|
|
|
|
});
|