From ccbc580e793bc619b6420184f6c7ad3fe89bdedd Mon Sep 17 00:00:00 2001 From: Zoltan Toth Date: Tue, 5 Mar 2019 13:06:01 -0500 Subject: [PATCH 1/3] Complete reducers tests --- __tests__/reducers/reducers.test.js | 71 +++++++++++++++++++++++------ 1 file changed, 58 insertions(+), 13 deletions(-) diff --git a/__tests__/reducers/reducers.test.js b/__tests__/reducers/reducers.test.js index 0104ed1..a2ef218 100644 --- a/__tests__/reducers/reducers.test.js +++ b/__tests__/reducers/reducers.test.js @@ -1,26 +1,36 @@ import reducer from '../../src/reducers'; -import { SUBMIT, TOGGLE, TOGGLE_JS, TOGGLE_MODE } from '../../src/static/constants/actions'; +import { + SUBMIT, + TOGGLE, + TOGGLE_JS, + TOGGLE_MODE, + RESTART +} from '../../src/static/constants/actions'; const answers = [ { name: 'Template', type: 'behavioral', - codeES5: 'Code ES5', - codeES6: 'Code ES6', - answered: false, - correct: null, - answerId: null, + answered: true, + correct: true, + answerId: 'ba2ca6b0-0c86-4573-baf0-60f33ce6e947', uuid: 'ba2ca6b0-0c86-4573-baf0-60f33ce6e947' }, { name: 'Visitor', type: 'behavioral', - codeES5: 'Code ES5', - codeES6: 'Code ES6', answered: false, correct: null, answerId: null, uuid: 'eb9427c5-0167-4d65-a99b-a5ffadf5fd46' + }, + { + name: 'Singleton', + type: 'creational', + answered: false, + correct: null, + answerId: null, + uuid: 'slearknbqarlnbqasOLdnv' } ]; @@ -75,12 +85,12 @@ describe('Reducers', () => { }); }); - xit('should handle SUBMIT', () => { + it('should handle SUBMIT', () => { const action = { type: SUBMIT, payload: { - currentIndex: 0, - remainingPatterns: answers[1], + currentIndex: 1, + remainingPatterns: [answers[1], answers[2]], recentlyAnswered: answers[0] } }; @@ -88,9 +98,44 @@ describe('Reducers', () => { expect(reducer(initialState, action)).toMatchObject({ ...initialState, progress: { - remaining: [answers[1]], + remaining: [answers[1], answers[2]], answers: [answers[0]], - current: answers[1] + current: answers[2] + } + }); + }); + + it('should handle the _last_ SUBMIT', () => { + const action = { + type: SUBMIT, + payload: { + currentIndex: null, + remainingPatterns: [], + recentlyAnswered: answers[2] + } + }; + + expect(reducer(initialState, action)).toMatchObject({ + ...initialState, + progress: { + remaining: [], + answers: [answers[2]], + current: null + } + }); + }); + + it('should handle RESTART', () => { + const action = { + type: RESTART, + payload: null + }; + + expect(reducer(initialState, action)).toMatchObject({ + ...initialState, + progress: { + remaining: answers, + answers: [] } }); }); From 154981c2ff1f4c92d6f7984ad33a9ce2dc7f6619 Mon Sep 17 00:00:00 2001 From: Zoltan Toth Date: Tue, 5 Mar 2019 13:48:11 -0500 Subject: [PATCH 2/3] Twitter share URL update --- src/pages/Game.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/Game.jsx b/src/pages/Game.jsx index d965604..b69f6c9 100644 --- a/src/pages/Game.jsx +++ b/src/pages/Game.jsx @@ -61,7 +61,7 @@ const Game = ({ current, answers, style, onRestart }) => { Tweet Your Score From 934f4a543d2e5a9b3fc540527528c09bf905665a Mon Sep 17 00:00:00 2001 From: Zoltan Toth Date: Tue, 5 Mar 2019 13:51:46 -0500 Subject: [PATCH 3/3] Update _Button_ story with action --- stories/Button.stories.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stories/Button.stories.js b/stories/Button.stories.js index c8d0dd3..cea2e85 100644 --- a/stories/Button.stories.js +++ b/stories/Button.stories.js @@ -1,5 +1,6 @@ import React from 'react'; import Provider from './Provider.js'; +import { action } from '@storybook/addon-actions'; import { storiesOf } from '@storybook/react'; import { withKnobs, text } from '@storybook/addon-knobs'; import Button from '../src/components/Button'; @@ -12,5 +13,5 @@ storiesOf('Button', module) .addDecorator(withKnobs) .add('default', () => ( -