From 7a2b1dd893da5b59122d49a275aa6400c005b366 Mon Sep 17 00:00:00 2001 From: Tim Glasgow Date: Thu, 11 Aug 2022 18:42:59 -0500 Subject: [PATCH] user reducer tests --- squarenotsquare/__tests__/Redux-test.js | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/squarenotsquare/__tests__/Redux-test.js b/squarenotsquare/__tests__/Redux-test.js index aad7137..813c796 100644 --- a/squarenotsquare/__tests__/Redux-test.js +++ b/squarenotsquare/__tests__/Redux-test.js @@ -2,6 +2,8 @@ import configStore from '../src/redux/CreateStore'; import {systemReducer} from '../src/redux/reducers/SystemReducer'; import rootReducer from '../src/redux/reducers/RootReducer'; import { APP_INIT } from '../src/redux/types/SystemTypes'; +import { userReducer } from '../src/redux/reducers/UserReducer'; +import { ADDITION_FINISHED, ADDITION_START, SQUARE_FINISHED, SQUARE_START } from '../src/redux/types/UserTypes'; jest.useRealTimers(); test('configures redux store', () => { @@ -16,4 +18,29 @@ test('rootReducer constructs', () => { test('systemReducer response to app-init', () => { let nextState = systemReducer.system({}, {type: APP_INIT, system: {value: 0}}); expect(nextState.value).toEqual(0); +}) + +test('userReducer response to app-init', () => { + let nextState = userReducer.user({}, {type: APP_INIT, user: {username: 'unittest'}}); + expect(nextState.username).toEqual('unittest'); +}) + +test('userReducer response to square-start', () => { + let nextState = userReducer.user({}, {type: SQUARE_START, user: {username: 'unittest'}}); + expect(nextState.username).toEqual('unittest'); +}) + +test('userReducer response to addition-start', () => { + let nextState = userReducer.user({}, {type: ADDITION_START, user: {username: 'unittest'}}); + expect(nextState.username).toEqual('unittest'); +}) + +test('userReducer response to square-finished', () => { + let nextState = userReducer.user({}, {type: SQUARE_FINISHED, user: {username: 'unittest'}}); + expect(nextState.username).toEqual('unittest'); +}) + +test('userReducer response to addition-finished', () => { + let nextState = userReducer.user({}, {type: ADDITION_FINISHED, user: {username: 'unittest'}}); + expect(nextState.username).toEqual('unittest'); }) \ No newline at end of file