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: []
}
});
});
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
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', () => (
-