add tests

This commit is contained in:
Gerzon Z 2022-01-19 12:30:45 -04:00
parent a75d372026
commit 64780dee6f
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,26 @@
import { selectServerRequest, selectServerSuccess } from '../actions/server';
import { mockedStore } from './mockedStore';
import { initialState } from './server';
describe('test server reducer', () => {
it('should return initial state', () => {
const state = mockedStore.getState().server;
expect(state).toEqual(initialState);
});
it('should return modified store after selectServer', () => {
const server = 'https://open.rocket.chat/';
mockedStore.dispatch(selectServerRequest(server));
const state = mockedStore.getState().server.server;
expect(state).toEqual(server);
});
it('should return modified store after selectServerSucess', () => {
const serverStr = 'https://mobile.rocket.chat/';
const versionStr = '4.1.0';
mockedStore.dispatch(selectServerSuccess(serverStr, versionStr));
const { server, version } = mockedStore.getState().server;
expect(server).toEqual(serverStr);
expect(version).toEqual(versionStr);
});
});

View File

@ -12,7 +12,7 @@ export interface IServer {
changingServer: boolean;
}
const initialState: IServer = {
export const initialState: IServer = {
connecting: false,
connected: false,
failure: false,