Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ccbc580

Browse files
Complete reducers tests
1 parent 5add1eb commit ccbc580

File tree

1 file changed

+58
-13
lines changed

1 file changed

+58
-13
lines changed

‎__tests__/reducers/reducers.test.js‎

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
11
import reducer from '../../src/reducers';
2-
import { SUBMIT, TOGGLE, TOGGLE_JS, TOGGLE_MODE } from '../../src/static/constants/actions';
2+
import {
3+
SUBMIT,
4+
TOGGLE,
5+
TOGGLE_JS,
6+
TOGGLE_MODE,
7+
RESTART
8+
} from '../../src/static/constants/actions';
39

410
const answers = [
511
{
612
name: 'Template',
713
type: 'behavioral',
8-
codeES5: 'Code ES5',
9-
codeES6: 'Code ES6',
10-
answered: false,
11-
correct: null,
12-
answerId: null,
14+
answered: true,
15+
correct: true,
16+
answerId: 'ba2ca6b0-0c86-4573-baf0-60f33ce6e947',
1317
uuid: 'ba2ca6b0-0c86-4573-baf0-60f33ce6e947'
1418
},
1519
{
1620
name: 'Visitor',
1721
type: 'behavioral',
18-
codeES5: 'Code ES5',
19-
codeES6: 'Code ES6',
2022
answered: false,
2123
correct: null,
2224
answerId: null,
2325
uuid: 'eb9427c5-0167-4d65-a99b-a5ffadf5fd46'
26+
},
27+
{
28+
name: 'Singleton',
29+
type: 'creational',
30+
answered: false,
31+
correct: null,
32+
answerId: null,
33+
uuid: 'slearknbqarlnbqasOLdnv'
2434
}
2535
];
2636

@@ -75,22 +85,57 @@ describe('Reducers', () => {
7585
});
7686
});
7787

78-
xit('should handle SUBMIT', () => {
88+
it('should handle SUBMIT', () => {
7989
const action = {
8090
type: SUBMIT,
8191
payload: {
82-
currentIndex: 0,
83-
remainingPatterns: answers[1],
92+
currentIndex: 1,
93+
remainingPatterns: [answers[1],answers[2]],
8494
recentlyAnswered: answers[0]
8595
}
8696
};
8797

8898
expect(reducer(initialState, action)).toMatchObject({
8999
...initialState,
90100
progress: {
91-
remaining: [answers[1]],
101+
remaining: [answers[1],answers[2]],
92102
answers: [answers[0]],
93-
current: answers[1]
103+
current: answers[2]
104+
}
105+
});
106+
});
107+
108+
it('should handle the _last_ SUBMIT', () => {
109+
const action = {
110+
type: SUBMIT,
111+
payload: {
112+
currentIndex: null,
113+
remainingPatterns: [],
114+
recentlyAnswered: answers[2]
115+
}
116+
};
117+
118+
expect(reducer(initialState, action)).toMatchObject({
119+
...initialState,
120+
progress: {
121+
remaining: [],
122+
answers: [answers[2]],
123+
current: null
124+
}
125+
});
126+
});
127+
128+
it('should handle RESTART', () => {
129+
const action = {
130+
type: RESTART,
131+
payload: null
132+
};
133+
134+
expect(reducer(initialState, action)).toMatchObject({
135+
...initialState,
136+
progress: {
137+
remaining: answers,
138+
answers: []
94139
}
95140
});
96141
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /