@coorpacademy/app-review 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/api/fetch-rank.js +5 -1
- package/es/actions/ui/quit-popin.d.ts +8 -0
- package/es/actions/ui/quit-popin.js +8 -0
- package/es/index.d.ts +0 -1
- package/es/reducers/data/rank.d.ts +4 -3
- package/es/reducers/data/rank.js +9 -18
- package/es/reducers/index.d.ts +7 -1
- package/es/reducers/ui/index.d.ts +11 -1
- package/es/reducers/ui/index.js +5 -1
- package/es/reducers/ui/navigation.js +0 -1
- package/es/reducers/ui/positions.js +3 -1
- package/es/reducers/ui/quit-popin.d.ts +4 -0
- package/es/reducers/ui/quit-popin.js +16 -0
- package/es/reducers/ui/show-congrats.d.ts +5 -0
- package/es/reducers/ui/show-congrats.js +20 -0
- package/es/reducers/ui/slide.js +4 -1
- package/es/types/common.d.ts +10 -8
- package/es/views/slides/index.d.ts +67 -19
- package/es/views/slides/index.js +122 -6
- package/lib/actions/api/fetch-rank.js +7 -1
- package/lib/actions/ui/quit-popin.d.ts +8 -0
- package/lib/actions/ui/quit-popin.js +8 -0
- package/lib/index.d.ts +0 -1
- package/lib/reducers/data/rank.d.ts +4 -3
- package/lib/reducers/data/rank.js +9 -18
- package/lib/reducers/index.d.ts +7 -1
- package/lib/reducers/ui/index.d.ts +11 -1
- package/lib/reducers/ui/index.js +5 -1
- package/lib/reducers/ui/navigation.js +0 -1
- package/lib/reducers/ui/positions.js +3 -1
- package/lib/reducers/ui/quit-popin.d.ts +4 -0
- package/lib/reducers/ui/quit-popin.js +17 -0
- package/lib/reducers/ui/show-congrats.d.ts +5 -0
- package/lib/reducers/ui/show-congrats.js +21 -0
- package/lib/reducers/ui/slide.js +4 -1
- package/lib/types/common.d.ts +10 -8
- package/lib/views/slides/index.d.ts +67 -19
- package/lib/views/slides/index.js +124 -6
- package/package.json +3 -3
- package/src/actions/api/fetch-rank.ts +8 -1
- package/src/actions/api/test/fetch-correction.test.ts +4 -2
- package/src/actions/api/test/fetch-rank.test.ts +17 -8
- package/src/actions/api/test/fetch-skills.test.ts +4 -2
- package/src/actions/api/test/fetch-slide.test.ts +4 -2
- package/src/actions/api/test/post-answer.test.ts +9 -10
- package/src/actions/api/test/post-progression.test.ts +4 -2
- package/src/actions/data/test/token.test.ts +4 -2
- package/src/actions/ui/quit-popin.ts +10 -0
- package/src/actions/ui/test/answers.test.ts +4 -2
- package/src/actions/ui/test/next-slide.test.ts +5 -2
- package/src/actions/ui/test/quit-popin.test.ts +39 -0
- package/src/actions/ui/test/slides.test.ts +4 -2
- package/src/reducers/data/rank.ts +15 -31
- package/src/reducers/data/test/rank.test.ts +33 -52
- package/src/reducers/ui/index.ts +7 -1
- package/src/reducers/ui/navigation.ts +0 -2
- package/src/reducers/ui/positions.ts +3 -1
- package/src/reducers/ui/quit-popin.ts +22 -0
- package/src/reducers/ui/show-congrats.ts +26 -0
- package/src/reducers/ui/slide.ts +4 -2
- package/src/reducers/ui/test/positions.test.ts +14 -0
- package/src/reducers/ui/test/quit-popin.test.ts +24 -0
- package/src/reducers/ui/test/show-congrats.test.ts +40 -0
- package/src/reducers/ui/test/slide.test.ts +21 -0
- package/src/types/common.ts +12 -8
- package/src/views/skills/test/skills.test.ts +8 -4
- package/src/views/slides/index.ts +207 -27
- package/src/views/slides/test/header.on-click.test.ts +46 -0
- package/src/views/slides/test/index.test.ts +335 -25
- package/src/views/slides/test/on-quit-popin.on-click.test.ts +65 -0
- package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -2
- package/src/views/slides/test/slide.next-slide.on-click.test.ts +107 -2
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +4 -2
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +4 -2
- package/src/views/slides/test/slide.qcm.on-click.test.ts +4 -2
- package/src/views/slides/test/slide.slider.on-change.test.ts +4 -2
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +4 -2
- package/src/views/slides/test/slide.template.on-change.test.ts +4 -2
|
@@ -17,14 +17,16 @@ const initialState: StoreState = {
|
|
|
17
17
|
skills: [],
|
|
18
18
|
token: '1234',
|
|
19
19
|
corrections: {},
|
|
20
|
-
rank: {}
|
|
20
|
+
rank: {start: 10, end: Number.NaN}
|
|
21
21
|
},
|
|
22
22
|
ui: {
|
|
23
|
+
showCongrats: false,
|
|
23
24
|
positions: [0, 1, 2, 3, 4],
|
|
24
25
|
currentSlideRef: '',
|
|
25
26
|
navigation: [],
|
|
26
27
|
answers: {},
|
|
27
|
-
slide: {}
|
|
28
|
+
slide: {},
|
|
29
|
+
showQuitPopin: false
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
32
|
|
|
@@ -19,14 +19,16 @@ const initialState: StoreState = {
|
|
|
19
19
|
skills: [],
|
|
20
20
|
token: '1234',
|
|
21
21
|
corrections: {},
|
|
22
|
-
rank: {}
|
|
22
|
+
rank: {start: 10, end: Number.NaN}
|
|
23
23
|
},
|
|
24
24
|
ui: {
|
|
25
|
+
showCongrats: false,
|
|
25
26
|
positions: [0, 1, 2, 3, 4],
|
|
26
27
|
currentSlideRef: '',
|
|
27
28
|
navigation: [],
|
|
28
29
|
answers: {},
|
|
29
|
-
slide: {}
|
|
30
|
+
slide: {},
|
|
31
|
+
showQuitPopin: false
|
|
30
32
|
}
|
|
31
33
|
};
|
|
32
34
|
|
|
@@ -22,7 +22,6 @@ import {templateSlide} from '../../../views/slides/test/fixtures/template';
|
|
|
22
22
|
import {sliderSlide} from '../../../views/slides/test/fixtures/slider';
|
|
23
23
|
import {
|
|
24
24
|
RANK_FETCH_START_REQUEST,
|
|
25
|
-
RANK_FETCH_START_SUCCESS,
|
|
26
25
|
RANK_FETCH_END_REQUEST,
|
|
27
26
|
RANK_FETCH_END_SUCCESS
|
|
28
27
|
} from '../fetch-rank';
|
|
@@ -60,9 +59,10 @@ const initialState: StoreState = {
|
|
|
60
59
|
skills: [{skillRef, custom: false, name: skillRef, slidesToReview: 5}],
|
|
61
60
|
token: '1234',
|
|
62
61
|
corrections: {},
|
|
63
|
-
rank: {}
|
|
62
|
+
rank: {start: 10, end: Number.NaN}
|
|
64
63
|
},
|
|
65
64
|
ui: {
|
|
65
|
+
showCongrats: false,
|
|
66
66
|
currentSlideRef: freeTextSlide._id,
|
|
67
67
|
navigation: ['skills', 'slides'],
|
|
68
68
|
positions: [0, 1, 2, 3, 4],
|
|
@@ -75,12 +75,13 @@ const initialState: StoreState = {
|
|
|
75
75
|
animateCorrectionPopin: false,
|
|
76
76
|
showCorrectionPopin: false
|
|
77
77
|
}
|
|
78
|
-
}
|
|
78
|
+
},
|
|
79
|
+
showQuitPopin: false
|
|
79
80
|
}
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
test('should dispatch post-answer, fetch-slide and fetch-correction and fetch-start-rank actions when the answer is submitted and when the slide ref is not "successExitNode"', async t => {
|
|
83
|
-
t.plan(
|
|
84
|
+
t.plan(8);
|
|
84
85
|
const expectedActions = [
|
|
85
86
|
{type: POST_ANSWER_REQUEST, meta: {slideRef: freeTextSlide._id}},
|
|
86
87
|
{
|
|
@@ -109,10 +110,6 @@ test('should dispatch post-answer, fetch-slide and fetch-correction and fetch-st
|
|
|
109
110
|
},
|
|
110
111
|
{
|
|
111
112
|
type: RANK_FETCH_START_REQUEST
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
type: RANK_FETCH_START_SUCCESS,
|
|
115
|
-
payload: {rank: 93}
|
|
116
113
|
}
|
|
117
114
|
];
|
|
118
115
|
|
|
@@ -144,9 +141,10 @@ test('should dispatch post-answer, fetch-correction and fetch-end-rank actions w
|
|
|
144
141
|
skills: [{skillRef, custom: false, name: skillRef, slidesToReview: 5}],
|
|
145
142
|
token: '1234',
|
|
146
143
|
corrections: {},
|
|
147
|
-
rank: {}
|
|
144
|
+
rank: {start: 10, end: Number.NaN}
|
|
148
145
|
},
|
|
149
146
|
ui: {
|
|
147
|
+
showCongrats: false,
|
|
150
148
|
currentSlideRef: templateSlide._id,
|
|
151
149
|
navigation: ['skills', 'slides'],
|
|
152
150
|
positions: [-1, -1, -1, -1, 0],
|
|
@@ -177,7 +175,8 @@ test('should dispatch post-answer, fetch-correction and fetch-end-rank actions w
|
|
|
177
175
|
animateCorrectionPopin: false,
|
|
178
176
|
showCorrectionPopin: false
|
|
179
177
|
}
|
|
180
|
-
}
|
|
178
|
+
},
|
|
179
|
+
showQuitPopin: false
|
|
181
180
|
}
|
|
182
181
|
};
|
|
183
182
|
|
|
@@ -20,14 +20,16 @@ const initialState: StoreState = {
|
|
|
20
20
|
skills: [],
|
|
21
21
|
token: '1234',
|
|
22
22
|
corrections: {},
|
|
23
|
-
rank: {}
|
|
23
|
+
rank: {start: 10, end: Number.NaN}
|
|
24
24
|
},
|
|
25
25
|
ui: {
|
|
26
|
+
showCongrats: false,
|
|
26
27
|
positions: [0, 1, 2, 3, 4],
|
|
27
28
|
currentSlideRef: '',
|
|
28
29
|
navigation: [],
|
|
29
30
|
answers: {},
|
|
30
|
-
slide: {}
|
|
31
|
+
slide: {},
|
|
32
|
+
showQuitPopin: false
|
|
31
33
|
}
|
|
32
34
|
};
|
|
33
35
|
|
|
@@ -11,14 +11,16 @@ const initialState: StoreState = {
|
|
|
11
11
|
skills: [],
|
|
12
12
|
token: '1234',
|
|
13
13
|
corrections: {},
|
|
14
|
-
rank: {}
|
|
14
|
+
rank: {start: Number.NaN, end: Number.NaN}
|
|
15
15
|
},
|
|
16
16
|
ui: {
|
|
17
|
+
showCongrats: false,
|
|
17
18
|
positions: [0, 1, 2, 3, 4],
|
|
18
19
|
currentSlideRef: '',
|
|
19
20
|
navigation: [],
|
|
20
21
|
answers: {},
|
|
21
|
-
slide: {}
|
|
22
|
+
slide: {},
|
|
23
|
+
showQuitPopin: false
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
|
|
@@ -46,14 +46,16 @@ const initialState: StoreState = {
|
|
|
46
46
|
skills: [],
|
|
47
47
|
token: '1234',
|
|
48
48
|
corrections: {},
|
|
49
|
-
rank: {}
|
|
49
|
+
rank: {start: 10, end: Number.NaN}
|
|
50
50
|
},
|
|
51
51
|
ui: {
|
|
52
|
+
showCongrats: false,
|
|
52
53
|
positions: [0, 1, 2, 3, 4],
|
|
53
54
|
currentSlideRef: '',
|
|
54
55
|
navigation: [],
|
|
55
56
|
answers: {},
|
|
56
|
-
slide: {}
|
|
57
|
+
slide: {},
|
|
58
|
+
showQuitPopin: false
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
61
|
|
|
@@ -26,9 +26,10 @@ const state: StoreState = {
|
|
|
26
26
|
skills: [{skillRef, custom: false, name: skillRef, slidesToReview: 5}],
|
|
27
27
|
token: '1234',
|
|
28
28
|
corrections: {[freeTextSlide.universalRef]: getChoicesCorrection(freeTextSlide.universalRef)},
|
|
29
|
-
rank: {start: 93}
|
|
29
|
+
rank: {start: 93, end: Number.NaN}
|
|
30
30
|
},
|
|
31
31
|
ui: {
|
|
32
|
+
showCongrats: false,
|
|
32
33
|
currentSlideRef: freeTextSlide._id,
|
|
33
34
|
navigation: ['loader', 'slides'],
|
|
34
35
|
positions: [0, 1, 2, 3, 4],
|
|
@@ -41,9 +42,11 @@ const state: StoreState = {
|
|
|
41
42
|
animateCorrectionPopin: true,
|
|
42
43
|
showCorrectionPopin: true
|
|
43
44
|
}
|
|
44
|
-
}
|
|
45
|
+
},
|
|
46
|
+
showQuitPopin: false
|
|
45
47
|
}
|
|
46
48
|
};
|
|
49
|
+
|
|
47
50
|
test('should dispatch NEXT_SLIDE action when nextSlide is called and the progression state is correct', t => {
|
|
48
51
|
const expectedActions = [
|
|
49
52
|
{
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import {createTestStore} from '../../test/create-test-store';
|
|
3
|
+
import type {StoreState} from '../../../reducers';
|
|
4
|
+
import {closeQuitPopin, CLOSE_POPIN, openQuitPopin, OPEN_POPIN} from '../quit-popin';
|
|
5
|
+
import {services} from '../../../test/util/services.mock';
|
|
6
|
+
|
|
7
|
+
const initialState: StoreState = {
|
|
8
|
+
data: {
|
|
9
|
+
progression: null,
|
|
10
|
+
slides: {},
|
|
11
|
+
skills: [],
|
|
12
|
+
token: '1234',
|
|
13
|
+
corrections: {},
|
|
14
|
+
rank: {start: Number.NaN, end: Number.NaN}
|
|
15
|
+
},
|
|
16
|
+
ui: {
|
|
17
|
+
showCongrats: false,
|
|
18
|
+
currentSlideRef: '',
|
|
19
|
+
navigation: [],
|
|
20
|
+
answers: {},
|
|
21
|
+
slide: {},
|
|
22
|
+
positions: [],
|
|
23
|
+
showQuitPopin: false
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
test('should dispatch OPEN_POPIN when openQuitPopin action is called', async t => {
|
|
28
|
+
const expectedAction = [{type: OPEN_POPIN}];
|
|
29
|
+
|
|
30
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedAction);
|
|
31
|
+
await dispatch(openQuitPopin);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('should dispatch CLOSE_POPIN when closeQuitPopin action is called', async t => {
|
|
35
|
+
const expectedAction = [{type: CLOSE_POPIN}];
|
|
36
|
+
|
|
37
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedAction);
|
|
38
|
+
await dispatch(closeQuitPopin);
|
|
39
|
+
});
|
|
@@ -12,14 +12,16 @@ const initialState: StoreState = {
|
|
|
12
12
|
skills: [],
|
|
13
13
|
token: '1234',
|
|
14
14
|
corrections: {},
|
|
15
|
-
rank: {}
|
|
15
|
+
rank: {start: Number.NaN, end: Number.NaN}
|
|
16
16
|
},
|
|
17
17
|
ui: {
|
|
18
|
+
showCongrats: false,
|
|
18
19
|
currentSlideRef: '',
|
|
19
20
|
navigation: [],
|
|
20
21
|
positions: [0, 1, 2, 3, 4],
|
|
21
22
|
answers: {},
|
|
22
|
-
slide: {}
|
|
23
|
+
slide: {},
|
|
24
|
+
showQuitPopin: false
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
27
|
|
|
@@ -1,57 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import set from 'lodash/fp/set';
|
|
2
|
+
import {
|
|
3
|
+
POST_PROGRESSION_SUCCESS,
|
|
4
|
+
type ReceivedProgression
|
|
5
|
+
} from '../../actions/api/post-progression';
|
|
2
6
|
import {
|
|
3
7
|
RankAction,
|
|
4
|
-
RANK_FETCH_START_REQUEST,
|
|
5
8
|
RANK_FETCH_START_SUCCESS,
|
|
6
|
-
|
|
7
|
-
RANK_FETCH_END_REQUEST,
|
|
8
|
-
RANK_FETCH_END_SUCCESS,
|
|
9
|
-
RANK_FETCH_END_FAILURE
|
|
9
|
+
RANK_FETCH_END_SUCCESS
|
|
10
10
|
} from '../../actions/api/fetch-rank';
|
|
11
11
|
|
|
12
12
|
export type RankState = {
|
|
13
|
-
start
|
|
14
|
-
end
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const initialState: RankState = {
|
|
17
|
+
const initialState: RankState = {
|
|
18
|
+
start: Number.NaN,
|
|
19
|
+
end: Number.NaN
|
|
20
|
+
};
|
|
18
21
|
|
|
19
22
|
const reducer = (
|
|
20
23
|
// eslint-disable-next-line default-param-last
|
|
21
24
|
state: RankState = initialState,
|
|
22
|
-
action: RankAction
|
|
25
|
+
action: RankAction | ReceivedProgression
|
|
23
26
|
): RankState => {
|
|
24
27
|
switch (action.type) {
|
|
25
|
-
case
|
|
26
|
-
return
|
|
27
|
-
'start',
|
|
28
|
-
(startRank: RankState['start']) => (isUndefined(startRank) ? null : startRank),
|
|
29
|
-
state
|
|
30
|
-
);
|
|
28
|
+
case POST_PROGRESSION_SUCCESS: {
|
|
29
|
+
return initialState;
|
|
31
30
|
}
|
|
32
31
|
case RANK_FETCH_START_SUCCESS: {
|
|
33
32
|
const {payload} = action;
|
|
34
33
|
return set('start', payload.rank, state);
|
|
35
34
|
}
|
|
36
|
-
case RANK_FETCH_START_FAILURE: {
|
|
37
|
-
if (pipe(get('start'), isNull)(state)) return unset('start', state);
|
|
38
|
-
return state;
|
|
39
|
-
}
|
|
40
|
-
case RANK_FETCH_END_REQUEST: {
|
|
41
|
-
return update(
|
|
42
|
-
'end',
|
|
43
|
-
(endRank: RankState['end']) => (isUndefined(endRank) ? null : endRank),
|
|
44
|
-
state
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
35
|
case RANK_FETCH_END_SUCCESS: {
|
|
48
36
|
const {payload} = action;
|
|
49
37
|
return set('end', payload.rank, state);
|
|
50
38
|
}
|
|
51
|
-
case RANK_FETCH_END_FAILURE: {
|
|
52
|
-
if (pipe(get('end'), isNull)(state)) return unset('end', state);
|
|
53
|
-
return state;
|
|
54
|
-
}
|
|
55
39
|
default:
|
|
56
40
|
return state;
|
|
57
41
|
}
|
|
@@ -2,77 +2,58 @@ import test from 'ava';
|
|
|
2
2
|
import reducer from '../rank';
|
|
3
3
|
import {
|
|
4
4
|
RankAction,
|
|
5
|
-
RANK_FETCH_START_REQUEST,
|
|
6
5
|
RANK_FETCH_START_SUCCESS,
|
|
7
|
-
|
|
8
|
-
RANK_FETCH_END_REQUEST,
|
|
9
|
-
RANK_FETCH_END_SUCCESS,
|
|
10
|
-
RANK_FETCH_END_FAILURE
|
|
6
|
+
RANK_FETCH_END_SUCCESS
|
|
11
7
|
} from '../../../actions/api/fetch-rank';
|
|
8
|
+
import {POST_PROGRESSION_SUCCESS} from '../../../actions/api/post-progression';
|
|
9
|
+
import {postProgressionResponse} from '../../../test/util/services.mock';
|
|
12
10
|
|
|
13
11
|
test('should have initial value', t => {
|
|
14
12
|
const state = reducer(undefined, {} as RankAction);
|
|
15
|
-
t.deepEqual(state, {});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("should set the start value to null if the value doesn't exist of FETCH_START_REQUEST action", t => {
|
|
19
|
-
const state = reducer({}, {type: RANK_FETCH_START_REQUEST});
|
|
20
|
-
t.deepEqual(state, {
|
|
21
|
-
start: null
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('should do nothing if a start value already exists of FETCH_START_REQUEST action', t => {
|
|
26
|
-
const state = reducer({start: 93}, {type: RANK_FETCH_START_REQUEST});
|
|
27
13
|
t.deepEqual(state, {
|
|
28
|
-
start:
|
|
14
|
+
start: Number.NaN,
|
|
15
|
+
end: Number.NaN
|
|
29
16
|
});
|
|
30
17
|
});
|
|
31
18
|
|
|
32
19
|
test('should set the start value of FETCH_START_SUCCESS action', t => {
|
|
33
|
-
const state = reducer(
|
|
20
|
+
const state = reducer(
|
|
21
|
+
{
|
|
22
|
+
start: Number.NaN,
|
|
23
|
+
end: Number.NaN
|
|
24
|
+
},
|
|
25
|
+
{type: RANK_FETCH_START_SUCCESS, payload: {rank: 93}}
|
|
26
|
+
);
|
|
34
27
|
t.deepEqual(state, {
|
|
35
|
-
start: 93
|
|
28
|
+
start: 93,
|
|
29
|
+
end: Number.NaN
|
|
36
30
|
});
|
|
37
31
|
});
|
|
38
32
|
|
|
39
|
-
test('should
|
|
40
|
-
const state = reducer(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("should set the end value to null if the value doesn't exist of FETCH_END_REQUEST action", t => {
|
|
50
|
-
const state = reducer({}, {type: RANK_FETCH_END_REQUEST});
|
|
51
|
-
t.deepEqual(state, {
|
|
52
|
-
end: null
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('should do nothing if an end value already exists of FETCH_END_REQUEST action', t => {
|
|
57
|
-
const state = reducer({end: 94}, {type: RANK_FETCH_END_REQUEST});
|
|
33
|
+
test('should set the end value of FETCH_END_SUCCESS action', t => {
|
|
34
|
+
const state = reducer(
|
|
35
|
+
{
|
|
36
|
+
start: 93,
|
|
37
|
+
end: Number.NaN
|
|
38
|
+
},
|
|
39
|
+
{type: RANK_FETCH_END_SUCCESS, payload: {rank: 94}}
|
|
40
|
+
);
|
|
58
41
|
t.deepEqual(state, {
|
|
42
|
+
start: 93,
|
|
59
43
|
end: 94
|
|
60
44
|
});
|
|
61
45
|
});
|
|
62
46
|
|
|
63
|
-
test('should
|
|
64
|
-
const state = reducer(
|
|
47
|
+
test('should unset the start and end value if the action is POST_PROGRESSION_SUCCESS', t => {
|
|
48
|
+
const state = reducer(
|
|
49
|
+
{
|
|
50
|
+
start: 93,
|
|
51
|
+
end: 94
|
|
52
|
+
},
|
|
53
|
+
{type: POST_PROGRESSION_SUCCESS, payload: postProgressionResponse}
|
|
54
|
+
);
|
|
65
55
|
t.deepEqual(state, {
|
|
66
|
-
|
|
56
|
+
start: Number.NaN,
|
|
57
|
+
end: Number.NaN
|
|
67
58
|
});
|
|
68
59
|
});
|
|
69
|
-
|
|
70
|
-
test('should unset the end value if the value is null of FETCH_END_FAILURE action', t => {
|
|
71
|
-
const state = reducer({end: null}, {type: RANK_FETCH_END_FAILURE});
|
|
72
|
-
t.deepEqual(state, {});
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('should do nothing if the end value already exists of FETCH_END_FAILURE action', t => {
|
|
76
|
-
const state = reducer({end: 94}, {type: RANK_FETCH_END_FAILURE});
|
|
77
|
-
t.deepEqual(state, {end: 94});
|
|
78
|
-
});
|
package/src/reducers/ui/index.ts
CHANGED
|
@@ -5,6 +5,8 @@ import navigation, {NavigationState} from './navigation';
|
|
|
5
5
|
import answers, {UIAnswerState} from './answers';
|
|
6
6
|
import positions, {UIPositionState} from './positions';
|
|
7
7
|
import slide, {UISlideState} from './slide';
|
|
8
|
+
import showQuitPopin, {type ShowQuitPopinState} from './quit-popin';
|
|
9
|
+
import showCongrats, {UIShowCongratsState} from './show-congrats';
|
|
8
10
|
|
|
9
11
|
export type UIState = {
|
|
10
12
|
currentSlideRef: CurrentSlideRefState;
|
|
@@ -12,6 +14,8 @@ export type UIState = {
|
|
|
12
14
|
answers: UIAnswerState;
|
|
13
15
|
slide: UISlideState;
|
|
14
16
|
positions: UIPositionState;
|
|
17
|
+
showQuitPopin: ShowQuitPopinState;
|
|
18
|
+
showCongrats: UIShowCongratsState;
|
|
15
19
|
};
|
|
16
20
|
|
|
17
21
|
export default combineReducers({
|
|
@@ -19,5 +23,7 @@ export default combineReducers({
|
|
|
19
23
|
navigation,
|
|
20
24
|
answers,
|
|
21
25
|
slide,
|
|
22
|
-
positions
|
|
26
|
+
positions,
|
|
27
|
+
showQuitPopin,
|
|
28
|
+
showCongrats
|
|
23
29
|
});
|
|
@@ -17,7 +17,9 @@ const reducer = (
|
|
|
17
17
|
return initialState;
|
|
18
18
|
}
|
|
19
19
|
case NEXT_SLIDE: {
|
|
20
|
-
const {totalCorrectAnswers, answeredSlides, currentSlideRef, animationType} =
|
|
20
|
+
const {totalCorrectAnswers, answeredSlides, currentSlideRef, animationType, nextSlideRef} =
|
|
21
|
+
action.payload;
|
|
22
|
+
if (nextSlideRef === 'successExitNode') return state;
|
|
21
23
|
|
|
22
24
|
const nextCurrentSlidePosition = animationType === 'unstack' ? -1 : 4 - totalCorrectAnswers;
|
|
23
25
|
const currentSlideIndex = findIndex(ref => ref === currentSlideRef, answeredSlides);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {closeQuitPopin, CLOSE_POPIN, openQuitPopin, OPEN_POPIN} from '../../actions/ui/quit-popin';
|
|
2
|
+
|
|
3
|
+
export type ShowQuitPopinState = boolean;
|
|
4
|
+
|
|
5
|
+
const reducer = (
|
|
6
|
+
// eslint-disable-next-line default-param-last
|
|
7
|
+
state: ShowQuitPopinState = false,
|
|
8
|
+
action: typeof openQuitPopin | typeof closeQuitPopin
|
|
9
|
+
): ShowQuitPopinState => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case OPEN_POPIN: {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
case CLOSE_POPIN: {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
default:
|
|
18
|
+
return state;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default reducer;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {NextSlideAction, NEXT_SLIDE} from '../../actions/ui/next-slide';
|
|
2
|
+
import {ReceivedProgression, POST_PROGRESSION_SUCCESS} from '../../actions/api/post-progression';
|
|
3
|
+
|
|
4
|
+
export type UIShowCongratsState = boolean;
|
|
5
|
+
|
|
6
|
+
const reducer = (
|
|
7
|
+
// eslint-disable-next-line default-param-last
|
|
8
|
+
state: UIShowCongratsState = false,
|
|
9
|
+
action: NextSlideAction | ReceivedProgression
|
|
10
|
+
): UIShowCongratsState => {
|
|
11
|
+
switch (action.type) {
|
|
12
|
+
case POST_PROGRESSION_SUCCESS: {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
case NEXT_SLIDE: {
|
|
16
|
+
const {nextSlideRef} = action.payload;
|
|
17
|
+
if (nextSlideRef === 'successExitNode') return true;
|
|
18
|
+
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
default:
|
|
22
|
+
return state;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default reducer;
|
package/src/reducers/ui/slide.ts
CHANGED
|
@@ -72,9 +72,11 @@ const reducer = (
|
|
|
72
72
|
)(state);
|
|
73
73
|
}
|
|
74
74
|
case NEXT_SLIDE: {
|
|
75
|
+
const {currentSlideRef, nextSlideRef} = action.payload;
|
|
76
|
+
if (nextSlideRef === 'successExitNode') return state;
|
|
75
77
|
return pipe(
|
|
76
|
-
set([
|
|
77
|
-
set([
|
|
78
|
+
set([currentSlideRef, 'animateCorrectionPopin'], false),
|
|
79
|
+
set([currentSlideRef, 'animationType'], action.payload.animationType)
|
|
78
80
|
)(state);
|
|
79
81
|
}
|
|
80
82
|
default:
|
|
@@ -66,3 +66,17 @@ test('should set position for currentSlide according to the animationType and th
|
|
|
66
66
|
});
|
|
67
67
|
t.deepEqual(_state, [-1, 0, -1, 1, -1]);
|
|
68
68
|
});
|
|
69
|
+
|
|
70
|
+
test('should return same state when nextContent is successExitNode', t => {
|
|
71
|
+
const state = reducer([-1, 0, -1, 1, -1], {
|
|
72
|
+
type: NEXT_SLIDE,
|
|
73
|
+
payload: {
|
|
74
|
+
totalCorrectAnswers: 2,
|
|
75
|
+
answeredSlides: ['sli_1', 'sli_2', 'sli_3', 'sli_4', 'sli_5', 'sli_1'],
|
|
76
|
+
currentSlideRef: 'sli_1',
|
|
77
|
+
nextSlideRef: 'successExitNode',
|
|
78
|
+
animationType: 'unstack'
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
t.deepEqual(state, [-1, 0, -1, 1, -1]);
|
|
82
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import {CLOSE_POPIN, OPEN_POPIN} from '../../../actions/ui/quit-popin';
|
|
3
|
+
import reducer from '../quit-popin';
|
|
4
|
+
|
|
5
|
+
test('should have showQuitPopin intial value to false', t => {
|
|
6
|
+
const state = reducer(undefined, {
|
|
7
|
+
type: '@@ui/CLOSE_POPIN'
|
|
8
|
+
});
|
|
9
|
+
t.is(state, false);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('should set showQuitPopin to true if OPEN_POPIN is received', t => {
|
|
13
|
+
const state = reducer(false, {
|
|
14
|
+
type: OPEN_POPIN
|
|
15
|
+
});
|
|
16
|
+
t.is(state, true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('should set showQuitPopin to false if CLOSE_POPIN is received', t => {
|
|
20
|
+
const state = reducer(true, {
|
|
21
|
+
type: CLOSE_POPIN
|
|
22
|
+
});
|
|
23
|
+
t.is(state, false);
|
|
24
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../show-congrats';
|
|
3
|
+
import {
|
|
4
|
+
POST_PROGRESSION_SUCCESS,
|
|
5
|
+
type ReceivedProgression
|
|
6
|
+
} from '../../../actions/api/post-progression';
|
|
7
|
+
import {NEXT_SLIDE} from '../../../actions/ui/next-slide';
|
|
8
|
+
|
|
9
|
+
test('should set state to false when received action is POST_ANSWER_REQUEST', t => {
|
|
10
|
+
const state = reducer(true, {type: POST_PROGRESSION_SUCCESS} as ReceivedProgression);
|
|
11
|
+
t.is(state, false);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('should set state to false when received action is NEXT_SLIDE with nextSlideRef other than successExitNode', t => {
|
|
15
|
+
const state = reducer(undefined, {
|
|
16
|
+
type: NEXT_SLIDE,
|
|
17
|
+
payload: {
|
|
18
|
+
currentSlideRef: '1234',
|
|
19
|
+
nextSlideRef: '5678',
|
|
20
|
+
animationType: 'unstack',
|
|
21
|
+
totalCorrectAnswers: 1,
|
|
22
|
+
answeredSlides: ['1234']
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
t.is(state, false);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('should set state to false when received action is NEXT_SLIDE with nextSlideRef successExitNode', t => {
|
|
29
|
+
const state = reducer(false, {
|
|
30
|
+
type: NEXT_SLIDE,
|
|
31
|
+
payload: {
|
|
32
|
+
currentSlideRef: '1234',
|
|
33
|
+
nextSlideRef: 'successExitNode',
|
|
34
|
+
animationType: 'unstack',
|
|
35
|
+
totalCorrectAnswers: 1,
|
|
36
|
+
answeredSlides: ['1234']
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
t.is(state, true);
|
|
40
|
+
});
|
|
@@ -87,3 +87,24 @@ test('should return state directly when there is no corresponding action handler
|
|
|
87
87
|
const state = reducer(undefined, {type: 'NOPE'} as unknown as PostAnswerRequestAction);
|
|
88
88
|
t.deepEqual(state, initialState);
|
|
89
89
|
});
|
|
90
|
+
|
|
91
|
+
test('should return same state when nextContent is successExitNode', t => {
|
|
92
|
+
const _initialState = {
|
|
93
|
+
'1234': {
|
|
94
|
+
validateButton: false,
|
|
95
|
+
animateCorrectionPopin: true,
|
|
96
|
+
showCorrectionPopin: true
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const state = reducer(_initialState, {
|
|
100
|
+
type: NEXT_SLIDE,
|
|
101
|
+
payload: {
|
|
102
|
+
currentSlideRef: '1234',
|
|
103
|
+
nextSlideRef: 'successExitNode',
|
|
104
|
+
animationType: 'unstack',
|
|
105
|
+
totalCorrectAnswers: 5,
|
|
106
|
+
answeredSlides: ['1234']
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
t.deepEqual(state, _initialState);
|
|
110
|
+
});
|