diff --git a/app/reducers/server.test.ts b/app/reducers/server.test.ts new file mode 100644 index 000000000..e90d2cd9f --- /dev/null +++ b/app/reducers/server.test.ts @@ -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); + }); +}); diff --git a/app/reducers/server.ts b/app/reducers/server.ts index 906fe4148..5641ef03c 100644 --- a/app/reducers/server.ts +++ b/app/reducers/server.ts @@ -12,7 +12,7 @@ export interface IServer { changingServer: boolean; } -const initialState: IServer = { +export const initialState: IServer = { connecting: false, connected: false, failure: false,