@coorpacademy/app-review 0.2.8 → 0.2.9
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.d.ts +32 -0
- package/es/actions/api/fetch-rank.js +30 -0
- package/es/actions/api/test/fetch-correction.test.js +2 -1
- package/es/actions/api/test/fetch-rank.test.d.ts +1 -0
- package/es/actions/api/test/fetch-rank.test.js +100 -0
- package/es/actions/api/test/fetch-skills.test.js +2 -1
- package/es/actions/api/test/fetch-slide.test.js +2 -1
- package/es/actions/api/test/post-answer.test.js +2 -1
- package/es/actions/api/test/post-progression.test.js +2 -1
- package/es/actions/data/test/token.test.js +2 -1
- package/es/actions/ui/test/answers.test.js +2 -1
- package/es/actions/ui/test/slides.test.js +2 -1
- package/es/reducers/data/corrections.d.ts +1 -1
- package/es/reducers/data/index.d.ts +4 -1
- package/es/reducers/data/index.js +2 -1
- package/es/reducers/data/rank.d.ts +7 -0
- package/es/reducers/data/rank.js +36 -0
- package/es/reducers/data/test/rank.test.d.ts +1 -0
- package/es/reducers/data/test/rank.test.js +59 -0
- package/es/reducers/index.d.ts +4 -3
- package/es/reducers/ui/slide.d.ts +1 -0
- package/es/reducers/ui/slide.js +1 -1
- package/es/test/util/services.mock.d.ts +1 -0
- package/es/test/util/services.mock.js +16 -0
- package/es/views/skills/test/skills.test.js +4 -2
- package/es/views/slides/index.d.ts +21 -19
- package/es/views/slides/index.js +29 -3
- package/es/views/slides/test/fixtures/qcm-graphic.js +190 -28
- package/es/views/slides/test/index.test.js +200 -19
- package/es/views/slides/test/slide.free-text.on-change.test.js +4 -1
- package/es/views/slides/test/slide.qcm-drag.on-click.test.js +4 -1
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +6 -3
- package/es/views/slides/test/slide.qcm.on-click.test.js +4 -1
- package/es/views/slides/test/slide.slider.on-change.test.js +4 -1
- package/es/views/slides/test/slide.template.on-change.test.js +6 -1
- package/lib/actions/api/fetch-rank.d.ts +32 -0
- package/lib/actions/api/fetch-rank.js +32 -0
- package/lib/actions/api/test/fetch-correction.test.js +2 -1
- package/lib/actions/api/test/fetch-rank.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-rank.test.js +171 -0
- package/lib/actions/api/test/fetch-skills.test.js +2 -1
- package/lib/actions/api/test/fetch-slide.test.js +2 -1
- package/lib/actions/api/test/post-answer.test.js +2 -1
- package/lib/actions/api/test/post-progression.test.js +2 -1
- package/lib/actions/data/test/token.test.js +2 -1
- package/lib/actions/ui/test/answers.test.js +2 -1
- package/lib/actions/ui/test/slides.test.js +2 -1
- package/lib/reducers/data/corrections.d.ts +1 -1
- package/lib/reducers/data/index.d.ts +4 -1
- package/lib/reducers/data/index.js +2 -1
- package/lib/reducers/data/rank.d.ts +7 -0
- package/lib/reducers/data/rank.js +37 -0
- package/lib/reducers/data/test/rank.test.d.ts +1 -0
- package/lib/reducers/data/test/rank.test.js +59 -0
- package/lib/reducers/index.d.ts +4 -3
- package/lib/reducers/ui/slide.d.ts +1 -0
- package/lib/reducers/ui/slide.js +1 -1
- package/lib/test/util/services.mock.d.ts +1 -0
- package/lib/test/util/services.mock.js +7 -0
- package/lib/views/skills/test/skills.test.js +4 -2
- package/lib/views/slides/index.d.ts +21 -19
- package/lib/views/slides/index.js +29 -3
- package/lib/views/slides/test/fixtures/qcm-graphic.js +190 -28
- package/lib/views/slides/test/index.test.js +211 -22
- package/lib/views/slides/test/slide.free-text.on-change.test.js +4 -1
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +4 -1
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +6 -3
- package/lib/views/slides/test/slide.qcm.on-click.test.js +4 -1
- package/lib/views/slides/test/slide.slider.on-change.test.js +4 -1
- package/lib/views/slides/test/slide.template.on-change.test.js +6 -1
- package/package.json +3 -3
- package/src/actions/api/fetch-rank.ts +84 -0
- package/src/actions/api/test/fetch-correction.test.ts +2 -1
- package/src/actions/api/test/fetch-rank.test.ts +130 -0
- package/src/actions/api/test/fetch-skills.test.ts +2 -1
- package/src/actions/api/test/fetch-slide.test.ts +2 -1
- package/src/actions/api/test/post-answer.test.ts +2 -1
- package/src/actions/api/test/post-progression.test.ts +2 -1
- package/src/actions/data/test/token.test.ts +2 -1
- package/src/actions/ui/test/answers.test.ts +2 -1
- package/src/actions/ui/test/slides.test.ts +2 -1
- package/src/reducers/data/corrections.ts +1 -1
- package/src/reducers/data/index.ts +3 -1
- package/src/reducers/data/rank.ts +60 -0
- package/src/reducers/data/test/rank.test.ts +78 -0
- package/src/reducers/index.ts +2 -2
- package/src/reducers/ui/slide.ts +2 -1
- package/src/test/util/services.mock.ts +17 -0
- package/src/views/skills/test/skills.test.ts +4 -2
- package/src/views/slides/index.ts +65 -22
- package/src/views/slides/test/fixtures/qcm-graphic.ts +196 -29
- package/src/views/slides/test/index.test.ts +210 -21
- package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -1
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +4 -1
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +6 -4
- package/src/views/slides/test/slide.qcm.on-click.test.ts +4 -1
- package/src/views/slides/test/slide.slider.on-change.test.ts +4 -1
- package/src/views/slides/test/slide.template.on-change.test.ts +6 -1
|
@@ -35,7 +35,8 @@ const initialState = {
|
|
|
35
35
|
},
|
|
36
36
|
skills: [],
|
|
37
37
|
token: '1234',
|
|
38
|
-
corrections: {}
|
|
38
|
+
corrections: {},
|
|
39
|
+
rank: {}
|
|
39
40
|
},
|
|
40
41
|
ui: {
|
|
41
42
|
currentSlideRef: qcmDragSlide._id,
|
|
@@ -57,6 +58,8 @@ test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Dra
|
|
|
57
58
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
59
|
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
60
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
61
|
+
animateCorrectionPopin: false,
|
|
62
|
+
showCorrectionPopin: false,
|
|
60
63
|
hidden: false,
|
|
61
64
|
position: 0,
|
|
62
65
|
loading: false,
|
|
@@ -35,7 +35,8 @@ const initialState = {
|
|
|
35
35
|
},
|
|
36
36
|
skills: [],
|
|
37
37
|
token: '1234',
|
|
38
|
-
corrections: {}
|
|
38
|
+
corrections: {},
|
|
39
|
+
rank: {}
|
|
39
40
|
},
|
|
40
41
|
ui: {
|
|
41
42
|
currentSlideRef: qcmGraphicSlide._id,
|
|
@@ -51,17 +52,19 @@ test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM
|
|
|
51
52
|
const expectedActions = [
|
|
52
53
|
{
|
|
53
54
|
type: EDIT_QCM_GRAPHIC,
|
|
54
|
-
payload: ['
|
|
55
|
+
payload: ['Le retour d’information']
|
|
55
56
|
}
|
|
56
57
|
];
|
|
57
58
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
59
|
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
60
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
61
|
+
animateCorrectionPopin: false,
|
|
62
|
+
showCorrectionPopin: false,
|
|
60
63
|
hidden: false,
|
|
61
64
|
position: 0,
|
|
62
65
|
loading: false,
|
|
63
66
|
parentContentTitle: 'From "Developing the review app" course',
|
|
64
|
-
questionText: '
|
|
67
|
+
questionText: 'Quels sont les 4 piliers de l’apprentissage ?'
|
|
65
68
|
});
|
|
66
69
|
const SlideProps = props.stack.slides['0'].answerUI?.model;
|
|
67
70
|
const onClick = get(['1', 'onClick'], SlideProps.answers);
|
|
@@ -35,7 +35,8 @@ const initialState = {
|
|
|
35
35
|
},
|
|
36
36
|
skills: [],
|
|
37
37
|
token: '1234',
|
|
38
|
-
corrections: {}
|
|
38
|
+
corrections: {},
|
|
39
|
+
rank: {}
|
|
39
40
|
},
|
|
40
41
|
ui: {
|
|
41
42
|
currentSlideRef: qcmSlide._id,
|
|
@@ -59,6 +60,8 @@ test('should dispatch EDIT_QCM action via the property onClick of a QCM slide',
|
|
|
59
60
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
60
61
|
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
61
62
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
63
|
+
animateCorrectionPopin: false,
|
|
64
|
+
showCorrectionPopin: false,
|
|
62
65
|
hidden: false,
|
|
63
66
|
position: 0,
|
|
64
67
|
loading: false,
|
|
@@ -35,7 +35,8 @@ const initialState = {
|
|
|
35
35
|
},
|
|
36
36
|
skills: [],
|
|
37
37
|
token: '1234',
|
|
38
|
-
corrections: {}
|
|
38
|
+
corrections: {},
|
|
39
|
+
rank: {}
|
|
39
40
|
},
|
|
40
41
|
ui: {
|
|
41
42
|
currentSlideRef: sliderSlide._id,
|
|
@@ -57,6 +58,8 @@ test('should dispatch EDIT_SLIDER action via the property onChange of a Slider s
|
|
|
57
58
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
59
|
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
60
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
61
|
+
animateCorrectionPopin: false,
|
|
62
|
+
showCorrectionPopin: false,
|
|
60
63
|
hidden: false,
|
|
61
64
|
position: 0,
|
|
62
65
|
loading: false,
|
|
@@ -35,7 +35,8 @@ const initialState = {
|
|
|
35
35
|
},
|
|
36
36
|
skills: [],
|
|
37
37
|
token: '1234',
|
|
38
|
-
corrections: {}
|
|
38
|
+
corrections: {},
|
|
39
|
+
rank: {}
|
|
39
40
|
},
|
|
40
41
|
ui: {
|
|
41
42
|
currentSlideRef: templateSlide._id,
|
|
@@ -52,6 +53,8 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
52
53
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
53
54
|
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
54
55
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
56
|
+
animateCorrectionPopin: false,
|
|
57
|
+
showCorrectionPopin: false,
|
|
55
58
|
hidden: false,
|
|
56
59
|
position: 0,
|
|
57
60
|
loading: false,
|
|
@@ -68,6 +71,8 @@ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Templa
|
|
|
68
71
|
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
69
72
|
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
70
73
|
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
74
|
+
animateCorrectionPopin: false,
|
|
75
|
+
showCorrectionPopin: false,
|
|
71
76
|
hidden: false,
|
|
72
77
|
position: 0,
|
|
73
78
|
loading: false,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { StoreState } from '../../reducers';
|
|
3
|
+
import type { Rank, Services, Options } from '../../types/common';
|
|
4
|
+
export declare const RANK_FETCH_START_REQUEST: "@@rank/FETCH_START_REQUEST";
|
|
5
|
+
export declare const RANK_FETCH_START_SUCCESS: "@@rank/FETCH_START_SUCCESS";
|
|
6
|
+
export declare const RANK_FETCH_START_FAILURE: "@@rank/FETCH_START_FAILURE";
|
|
7
|
+
export declare const RANK_FETCH_END_REQUEST: "@@rank/FETCH_END_REQUEST";
|
|
8
|
+
export declare const RANK_FETCH_END_SUCCESS: "@@rank/FETCH_END_SUCCESS";
|
|
9
|
+
export declare const RANK_FETCH_END_FAILURE: "@@rank/FETCH_END_FAILURE";
|
|
10
|
+
declare type RankFetchStartRequestType = typeof RANK_FETCH_START_REQUEST;
|
|
11
|
+
declare type RankFetchStartSuccessType = typeof RANK_FETCH_START_SUCCESS;
|
|
12
|
+
declare type RankFetchStartFailureType = typeof RANK_FETCH_START_FAILURE;
|
|
13
|
+
declare type RankFetchEndRequestType = typeof RANK_FETCH_END_REQUEST;
|
|
14
|
+
declare type RankFetchEndSuccessType = typeof RANK_FETCH_END_SUCCESS;
|
|
15
|
+
declare type RankFetchEndFailureType = typeof RANK_FETCH_END_FAILURE;
|
|
16
|
+
export declare type RankRequestAction = {
|
|
17
|
+
type: RankFetchStartRequestType | RankFetchEndRequestType;
|
|
18
|
+
};
|
|
19
|
+
export declare type RankSuccessAction = {
|
|
20
|
+
type: RankFetchStartSuccessType | RankFetchEndSuccessType;
|
|
21
|
+
payload: Rank;
|
|
22
|
+
};
|
|
23
|
+
export declare type RankFailureAction = {
|
|
24
|
+
type: RankFetchStartFailureType | RankFetchEndFailureType;
|
|
25
|
+
};
|
|
26
|
+
export declare type RankAction = RankRequestAction | RankSuccessAction | RankFailureAction;
|
|
27
|
+
declare type RankStart = [RankFetchStartRequestType, RankFetchStartSuccessType, RankFetchStartFailureType];
|
|
28
|
+
declare type RankEnd = [RankFetchEndRequestType, RankFetchEndSuccessType, RankFetchEndFailureType];
|
|
29
|
+
export declare const fetchRank: (dispatch: Dispatch, getState: () => StoreState, services: Services, types: RankStart | RankEnd, path?: string) => RankAction;
|
|
30
|
+
export declare const fetchStartRank: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => RankAction;
|
|
31
|
+
export declare const fetchEndRank: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => RankAction;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
3
|
+
export var RANK_FETCH_START_REQUEST = '@@rank/FETCH_START_REQUEST';
|
|
4
|
+
export var RANK_FETCH_START_SUCCESS = '@@rank/FETCH_START_SUCCESS';
|
|
5
|
+
export var RANK_FETCH_START_FAILURE = '@@rank/FETCH_START_FAILURE';
|
|
6
|
+
export var RANK_FETCH_END_REQUEST = '@@rank/FETCH_END_REQUEST';
|
|
7
|
+
export var RANK_FETCH_END_SUCCESS = '@@rank/FETCH_END_SUCCESS';
|
|
8
|
+
export var RANK_FETCH_END_FAILURE = '@@rank/FETCH_END_FAILURE';
|
|
9
|
+
export var fetchRank = function (dispatch, getState, services, types, path) {
|
|
10
|
+
var action = buildTask({
|
|
11
|
+
types: types,
|
|
12
|
+
task: function () {
|
|
13
|
+
var state = getState();
|
|
14
|
+
var token = get(['data', 'token'], state);
|
|
15
|
+
return services.fetchRank(token);
|
|
16
|
+
},
|
|
17
|
+
bailout: path ? function (state) { return !!get(path, state); } : undefined
|
|
18
|
+
});
|
|
19
|
+
return dispatch(action);
|
|
20
|
+
};
|
|
21
|
+
export var fetchStartRank = function (dispatch, getState, _a) {
|
|
22
|
+
var services = _a.services;
|
|
23
|
+
return fetchRank(dispatch, getState, services, [RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE], 'data.rank.start');
|
|
24
|
+
};
|
|
25
|
+
export var fetchEndRank = function (dispatch, getState, _a) {
|
|
26
|
+
var services = _a.services;
|
|
27
|
+
return fetchRank(dispatch, getState, services, [
|
|
28
|
+
RANK_FETCH_END_REQUEST,
|
|
29
|
+
RANK_FETCH_END_SUCCESS,
|
|
30
|
+
RANK_FETCH_END_FAILURE
|
|
31
|
+
]);
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import test from 'ava';
|
|
49
|
+
import { fetchStartRank, fetchEndRank, RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../fetch-rank';
|
|
50
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
51
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
52
|
+
var initialState = {
|
|
53
|
+
data: {
|
|
54
|
+
progression: null,
|
|
55
|
+
slides: {},
|
|
56
|
+
skills: [],
|
|
57
|
+
token: '1234',
|
|
58
|
+
corrections: {},
|
|
59
|
+
rank: {}
|
|
60
|
+
},
|
|
61
|
+
ui: {
|
|
62
|
+
currentSlideRef: '',
|
|
63
|
+
navigation: [],
|
|
64
|
+
answers: [],
|
|
65
|
+
slide: {
|
|
66
|
+
validateButton: false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
test('should dispatch FETCH_START_SUCCESS action when fetchStartRank returns the start rank', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
+
var services, expectedActions, dispatch;
|
|
72
|
+
return __generator(this, function (_a) {
|
|
73
|
+
switch (_a.label) {
|
|
74
|
+
case 0:
|
|
75
|
+
t.plan(3);
|
|
76
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
77
|
+
t.is(token, '1234');
|
|
78
|
+
return Promise.resolve({ rank: 93 });
|
|
79
|
+
} });
|
|
80
|
+
expectedActions = [
|
|
81
|
+
{ type: RANK_FETCH_START_REQUEST },
|
|
82
|
+
{
|
|
83
|
+
type: RANK_FETCH_START_SUCCESS,
|
|
84
|
+
payload: { rank: 93 }
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
88
|
+
return [4 /*yield*/, dispatch(fetchStartRank)];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}); });
|
|
95
|
+
test('should dispatch FETCH_START_FAILURE action when fetchStartRank fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
+
var services, expectedActions, dispatch;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
t.plan(3);
|
|
101
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
102
|
+
t.is(token, '1234');
|
|
103
|
+
return Promise.reject(new Error('unexpected'));
|
|
104
|
+
} });
|
|
105
|
+
expectedActions = [
|
|
106
|
+
{ type: RANK_FETCH_START_REQUEST },
|
|
107
|
+
{
|
|
108
|
+
type: RANK_FETCH_START_FAILURE,
|
|
109
|
+
payload: new Error('unexpected'),
|
|
110
|
+
error: true
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
114
|
+
return [4 /*yield*/, dispatch(fetchStartRank)];
|
|
115
|
+
case 1:
|
|
116
|
+
_a.sent();
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); });
|
|
121
|
+
test('should dispatch FETCH_END_SUCCESS action when fetchEndRank returns the end rank', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
var services, expectedActions, dispatch;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
t.plan(3);
|
|
127
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
128
|
+
t.is(token, '1234');
|
|
129
|
+
return Promise.resolve({ rank: 93 });
|
|
130
|
+
} });
|
|
131
|
+
expectedActions = [
|
|
132
|
+
{ type: RANK_FETCH_END_REQUEST },
|
|
133
|
+
{
|
|
134
|
+
type: RANK_FETCH_END_SUCCESS,
|
|
135
|
+
payload: { rank: 93 }
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
139
|
+
return [4 /*yield*/, dispatch(fetchEndRank)];
|
|
140
|
+
case 1:
|
|
141
|
+
_a.sent();
|
|
142
|
+
return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); });
|
|
146
|
+
test('should dispatch FETCH_END_FAILURE action when fetchEndRank fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
|
+
var services, expectedActions, dispatch;
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
switch (_a.label) {
|
|
150
|
+
case 0:
|
|
151
|
+
t.plan(3);
|
|
152
|
+
services = __assign(__assign({}, mockedServices), { fetchRank: function (token) {
|
|
153
|
+
t.is(token, '1234');
|
|
154
|
+
return Promise.reject(new Error('unexpected'));
|
|
155
|
+
} });
|
|
156
|
+
expectedActions = [
|
|
157
|
+
{ type: RANK_FETCH_END_REQUEST },
|
|
158
|
+
{
|
|
159
|
+
type: RANK_FETCH_END_FAILURE,
|
|
160
|
+
payload: new Error('unexpected'),
|
|
161
|
+
error: true
|
|
162
|
+
}
|
|
163
|
+
];
|
|
164
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
165
|
+
return [4 /*yield*/, dispatch(fetchEndRank)];
|
|
166
|
+
case 1:
|
|
167
|
+
_a.sent();
|
|
168
|
+
return [2 /*return*/];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}); });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CorrectionFromAPI } from '../../types/common';
|
|
1
|
+
import type { CorrectionFromAPI } from '../../types/common';
|
|
2
2
|
import { ReceivedCorrection, FetchCorrection } from '../../actions/api/fetch-correction';
|
|
3
3
|
export declare type CorrectionsState = Record<string, CorrectionFromAPI>;
|
|
4
4
|
export declare type CorrectionsAction = ReceivedCorrection | FetchCorrection;
|
|
@@ -3,12 +3,14 @@ import { ProgressionState } from './progression';
|
|
|
3
3
|
import { SkillsState } from './skills';
|
|
4
4
|
import { SlidesState } from './slides';
|
|
5
5
|
import { TokenState } from './token';
|
|
6
|
+
import { RankState } from './rank';
|
|
6
7
|
export declare type DataState = {
|
|
7
8
|
corrections: CorrectionsState;
|
|
8
9
|
progression: ProgressionState;
|
|
9
10
|
skills: SkillsState;
|
|
10
11
|
slides: SlidesState;
|
|
11
12
|
token: TokenState;
|
|
13
|
+
rank: RankState;
|
|
12
14
|
};
|
|
13
15
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
14
16
|
corrections: CorrectionsState;
|
|
@@ -16,5 +18,6 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
16
18
|
skills: SkillsState;
|
|
17
19
|
slides: SlidesState;
|
|
18
20
|
token: string;
|
|
19
|
-
|
|
21
|
+
rank: RankState;
|
|
22
|
+
}>, import("./corrections").CorrectionsAction | import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken | import("../../actions/api/fetch-rank").RankAction>;
|
|
20
23
|
export default _default;
|
|
@@ -4,4 +4,5 @@ import progression from './progression';
|
|
|
4
4
|
import skills from './skills';
|
|
5
5
|
import slides from './slides';
|
|
6
6
|
import token from './token';
|
|
7
|
-
|
|
7
|
+
import rank from './rank';
|
|
8
|
+
export default combineReducers({ corrections: corrections, progression: progression, skills: skills, slides: slides, token: token, rank: rank });
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { get, isNull, isUndefined, pipe, set, unset, update } from 'lodash/fp';
|
|
2
|
+
import { RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../../actions/api/fetch-rank';
|
|
3
|
+
var initialState = {};
|
|
4
|
+
var reducer = function (
|
|
5
|
+
// eslint-disable-next-line default-param-last
|
|
6
|
+
state, action) {
|
|
7
|
+
if (state === void 0) { state = initialState; }
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case RANK_FETCH_START_REQUEST: {
|
|
10
|
+
return update('start', function (startRank) { return (isUndefined(startRank) ? null : startRank); }, state);
|
|
11
|
+
}
|
|
12
|
+
case RANK_FETCH_START_SUCCESS: {
|
|
13
|
+
var payload = action.payload;
|
|
14
|
+
return set('start', payload.rank, state);
|
|
15
|
+
}
|
|
16
|
+
case RANK_FETCH_START_FAILURE: {
|
|
17
|
+
if (pipe(get('start'), isNull)(state))
|
|
18
|
+
return unset('start', state);
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
21
|
+
case RANK_FETCH_END_REQUEST: {
|
|
22
|
+
return update('end', function (endRank) { return (isUndefined(endRank) ? null : endRank); }, state);
|
|
23
|
+
}
|
|
24
|
+
case RANK_FETCH_END_SUCCESS: {
|
|
25
|
+
var payload = action.payload;
|
|
26
|
+
return set('end', payload.rank, state);
|
|
27
|
+
}
|
|
28
|
+
case RANK_FETCH_END_FAILURE: {
|
|
29
|
+
if (pipe(get('end'), isNull)(state))
|
|
30
|
+
return unset('end', state);
|
|
31
|
+
return state;
|
|
32
|
+
}
|
|
33
|
+
default:
|
|
34
|
+
return state;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export default reducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../rank';
|
|
3
|
+
import { RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../../../actions/api/fetch-rank';
|
|
4
|
+
test('should have initial value', function (t) {
|
|
5
|
+
var state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, {});
|
|
7
|
+
});
|
|
8
|
+
test("should set the start value to null if the value doesn't exist of FETCH_START_REQUEST action", function (t) {
|
|
9
|
+
var state = reducer({}, { type: RANK_FETCH_START_REQUEST });
|
|
10
|
+
t.deepEqual(state, {
|
|
11
|
+
start: null
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
test('should do nothing if a start value already exists of FETCH_START_REQUEST action', function (t) {
|
|
15
|
+
var state = reducer({ start: 93 }, { type: RANK_FETCH_START_REQUEST });
|
|
16
|
+
t.deepEqual(state, {
|
|
17
|
+
start: 93
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
test('should set the start value of FETCH_START_SUCCESS action', function (t) {
|
|
21
|
+
var state = reducer({}, { type: RANK_FETCH_START_SUCCESS, payload: { rank: 93 } });
|
|
22
|
+
t.deepEqual(state, {
|
|
23
|
+
start: 93
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
test('should unset the start value if the value is null of FETCH_START_FAILURE action', function (t) {
|
|
27
|
+
var state = reducer({ start: null }, { type: RANK_FETCH_START_FAILURE });
|
|
28
|
+
t.deepEqual(state, {});
|
|
29
|
+
});
|
|
30
|
+
test('should do nothing if the start value already exists of FETCH_START_FAILURE action', function (t) {
|
|
31
|
+
var state = reducer({ start: 93 }, { type: RANK_FETCH_START_FAILURE });
|
|
32
|
+
t.deepEqual(state, { start: 93 });
|
|
33
|
+
});
|
|
34
|
+
test("should set the end value to null if the value doesn't exist of FETCH_END_REQUEST action", function (t) {
|
|
35
|
+
var state = reducer({}, { type: RANK_FETCH_END_REQUEST });
|
|
36
|
+
t.deepEqual(state, {
|
|
37
|
+
end: null
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
test('should do nothing if an end value already exists of FETCH_END_REQUEST action', function (t) {
|
|
41
|
+
var state = reducer({ end: 94 }, { type: RANK_FETCH_END_REQUEST });
|
|
42
|
+
t.deepEqual(state, {
|
|
43
|
+
end: 94
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
test('should set the end value of FETCH_END_SUCCESS action', function (t) {
|
|
47
|
+
var state = reducer({}, { type: RANK_FETCH_END_SUCCESS, payload: { rank: 94 } });
|
|
48
|
+
t.deepEqual(state, {
|
|
49
|
+
end: 94
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
test('should unset the end value if the value is null of FETCH_END_FAILURE action', function (t) {
|
|
53
|
+
var state = reducer({ end: null }, { type: RANK_FETCH_END_FAILURE });
|
|
54
|
+
t.deepEqual(state, {});
|
|
55
|
+
});
|
|
56
|
+
test('should do nothing if the end value already exists of FETCH_END_FAILURE action', function (t) {
|
|
57
|
+
var state = reducer({ end: 94 }, { type: RANK_FETCH_END_FAILURE });
|
|
58
|
+
t.deepEqual(state, { end: 94 });
|
|
59
|
+
});
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataState } from './data';
|
|
2
|
-
import { UIState } from './ui';
|
|
1
|
+
import { type DataState } from './data';
|
|
2
|
+
import { type UIState } from './ui';
|
|
3
3
|
export declare type StoreState = {
|
|
4
4
|
ui: UIState;
|
|
5
5
|
data: DataState;
|
|
@@ -11,6 +11,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
11
11
|
skills: import("./data/skills").SkillsState;
|
|
12
12
|
slides: import("./data/slides").SlidesState;
|
|
13
13
|
token: string;
|
|
14
|
+
rank: import("./data/rank").RankState;
|
|
14
15
|
}>;
|
|
15
16
|
ui: import("redux").CombinedState<{
|
|
16
17
|
currentSlideRef: string;
|
|
@@ -18,5 +19,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
18
19
|
answers: import("./ui/answers").AnswerState;
|
|
19
20
|
slide: import("./ui/slide").UISlideState;
|
|
20
21
|
}>;
|
|
21
|
-
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
22
|
+
}>, import("./data/corrections").CorrectionsAction | import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/api/fetch-rank").RankAction | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
|
|
22
23
|
export default _default;
|
|
@@ -4,6 +4,7 @@ import { ReceivedCorrection } from '../../actions/api/fetch-correction';
|
|
|
4
4
|
export declare type UISlideState = {
|
|
5
5
|
validateButton: boolean;
|
|
6
6
|
animateCorrectionPopin?: boolean;
|
|
7
|
+
showCorrectionPopin?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const initialState: UISlideState;
|
|
9
10
|
declare const reducer: (state: UISlideState | undefined, action: PostAnswerRequestAction | EditAnswerAction | ReceivedCorrection) => UISlideState;
|
package/lib/reducers/ui/slide.js
CHANGED
|
@@ -23,7 +23,7 @@ state, action) {
|
|
|
23
23
|
return initialState;
|
|
24
24
|
}
|
|
25
25
|
case CORRECTION_FETCH_SUCCESS: {
|
|
26
|
-
return set(['animateCorrectionPopin'], true, state);
|
|
26
|
+
return pipe(set(['animateCorrectionPopin'], true), set(['showCorrectionPopin'], true))(state);
|
|
27
27
|
}
|
|
28
28
|
default:
|
|
29
29
|
return state;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CorrectionFromAPI, ProgressionFromAPI, Services } from '../../types/common';
|
|
2
2
|
export declare const postProgressionResponse: ProgressionFromAPI;
|
|
3
3
|
export declare const postAnswerResponses: Record<string, ProgressionFromAPI>;
|
|
4
|
+
export declare const incorrectFreeTextPostAnswerResponse: ProgressionFromAPI;
|
|
4
5
|
export declare const progressionSlideWithPendingSlide: ProgressionFromAPI;
|
|
5
6
|
export declare const getChoicesCorrection: (ref: string, wrongChoice?: boolean) => CorrectionFromAPI;
|
|
6
7
|
export declare const services: Services;
|