@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.
Files changed (98) hide show
  1. package/es/actions/api/fetch-rank.d.ts +32 -0
  2. package/es/actions/api/fetch-rank.js +30 -0
  3. package/es/actions/api/test/fetch-correction.test.js +2 -1
  4. package/es/actions/api/test/fetch-rank.test.d.ts +1 -0
  5. package/es/actions/api/test/fetch-rank.test.js +100 -0
  6. package/es/actions/api/test/fetch-skills.test.js +2 -1
  7. package/es/actions/api/test/fetch-slide.test.js +2 -1
  8. package/es/actions/api/test/post-answer.test.js +2 -1
  9. package/es/actions/api/test/post-progression.test.js +2 -1
  10. package/es/actions/data/test/token.test.js +2 -1
  11. package/es/actions/ui/test/answers.test.js +2 -1
  12. package/es/actions/ui/test/slides.test.js +2 -1
  13. package/es/reducers/data/corrections.d.ts +1 -1
  14. package/es/reducers/data/index.d.ts +4 -1
  15. package/es/reducers/data/index.js +2 -1
  16. package/es/reducers/data/rank.d.ts +7 -0
  17. package/es/reducers/data/rank.js +36 -0
  18. package/es/reducers/data/test/rank.test.d.ts +1 -0
  19. package/es/reducers/data/test/rank.test.js +59 -0
  20. package/es/reducers/index.d.ts +4 -3
  21. package/es/reducers/ui/slide.d.ts +1 -0
  22. package/es/reducers/ui/slide.js +1 -1
  23. package/es/test/util/services.mock.d.ts +1 -0
  24. package/es/test/util/services.mock.js +16 -0
  25. package/es/views/skills/test/skills.test.js +4 -2
  26. package/es/views/slides/index.d.ts +21 -19
  27. package/es/views/slides/index.js +29 -3
  28. package/es/views/slides/test/fixtures/qcm-graphic.js +190 -28
  29. package/es/views/slides/test/index.test.js +200 -19
  30. package/es/views/slides/test/slide.free-text.on-change.test.js +4 -1
  31. package/es/views/slides/test/slide.qcm-drag.on-click.test.js +4 -1
  32. package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +6 -3
  33. package/es/views/slides/test/slide.qcm.on-click.test.js +4 -1
  34. package/es/views/slides/test/slide.slider.on-change.test.js +4 -1
  35. package/es/views/slides/test/slide.template.on-change.test.js +6 -1
  36. package/lib/actions/api/fetch-rank.d.ts +32 -0
  37. package/lib/actions/api/fetch-rank.js +32 -0
  38. package/lib/actions/api/test/fetch-correction.test.js +2 -1
  39. package/lib/actions/api/test/fetch-rank.test.d.ts +1 -0
  40. package/lib/actions/api/test/fetch-rank.test.js +171 -0
  41. package/lib/actions/api/test/fetch-skills.test.js +2 -1
  42. package/lib/actions/api/test/fetch-slide.test.js +2 -1
  43. package/lib/actions/api/test/post-answer.test.js +2 -1
  44. package/lib/actions/api/test/post-progression.test.js +2 -1
  45. package/lib/actions/data/test/token.test.js +2 -1
  46. package/lib/actions/ui/test/answers.test.js +2 -1
  47. package/lib/actions/ui/test/slides.test.js +2 -1
  48. package/lib/reducers/data/corrections.d.ts +1 -1
  49. package/lib/reducers/data/index.d.ts +4 -1
  50. package/lib/reducers/data/index.js +2 -1
  51. package/lib/reducers/data/rank.d.ts +7 -0
  52. package/lib/reducers/data/rank.js +37 -0
  53. package/lib/reducers/data/test/rank.test.d.ts +1 -0
  54. package/lib/reducers/data/test/rank.test.js +59 -0
  55. package/lib/reducers/index.d.ts +4 -3
  56. package/lib/reducers/ui/slide.d.ts +1 -0
  57. package/lib/reducers/ui/slide.js +1 -1
  58. package/lib/test/util/services.mock.d.ts +1 -0
  59. package/lib/test/util/services.mock.js +7 -0
  60. package/lib/views/skills/test/skills.test.js +4 -2
  61. package/lib/views/slides/index.d.ts +21 -19
  62. package/lib/views/slides/index.js +29 -3
  63. package/lib/views/slides/test/fixtures/qcm-graphic.js +190 -28
  64. package/lib/views/slides/test/index.test.js +211 -22
  65. package/lib/views/slides/test/slide.free-text.on-change.test.js +4 -1
  66. package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +4 -1
  67. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +6 -3
  68. package/lib/views/slides/test/slide.qcm.on-click.test.js +4 -1
  69. package/lib/views/slides/test/slide.slider.on-change.test.js +4 -1
  70. package/lib/views/slides/test/slide.template.on-change.test.js +6 -1
  71. package/package.json +3 -3
  72. package/src/actions/api/fetch-rank.ts +84 -0
  73. package/src/actions/api/test/fetch-correction.test.ts +2 -1
  74. package/src/actions/api/test/fetch-rank.test.ts +130 -0
  75. package/src/actions/api/test/fetch-skills.test.ts +2 -1
  76. package/src/actions/api/test/fetch-slide.test.ts +2 -1
  77. package/src/actions/api/test/post-answer.test.ts +2 -1
  78. package/src/actions/api/test/post-progression.test.ts +2 -1
  79. package/src/actions/data/test/token.test.ts +2 -1
  80. package/src/actions/ui/test/answers.test.ts +2 -1
  81. package/src/actions/ui/test/slides.test.ts +2 -1
  82. package/src/reducers/data/corrections.ts +1 -1
  83. package/src/reducers/data/index.ts +3 -1
  84. package/src/reducers/data/rank.ts +60 -0
  85. package/src/reducers/data/test/rank.test.ts +78 -0
  86. package/src/reducers/index.ts +2 -2
  87. package/src/reducers/ui/slide.ts +2 -1
  88. package/src/test/util/services.mock.ts +17 -0
  89. package/src/views/skills/test/skills.test.ts +4 -2
  90. package/src/views/slides/index.ts +65 -22
  91. package/src/views/slides/test/fixtures/qcm-graphic.ts +196 -29
  92. package/src/views/slides/test/index.test.ts +210 -21
  93. package/src/views/slides/test/slide.free-text.on-change.test.ts +4 -1
  94. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +4 -1
  95. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +6 -4
  96. package/src/views/slides/test/slide.qcm.on-click.test.ts +4 -1
  97. package/src/views/slides/test/slide.slider.on-change.test.ts +4 -1
  98. 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: ['Faux']
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: 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?'
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
+ };
@@ -64,7 +64,8 @@ var initialState = {
64
64
  _a),
65
65
  skills: [{ skillRef: skillRef, custom: false, name: skillRef, slidesToReview: 5 }],
66
66
  token: '1234',
67
- corrections: {}
67
+ corrections: {},
68
+ rank: {}
68
69
  },
69
70
  ui: {
70
71
  currentSlideRef: freeTextSlide._id,
@@ -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
+ }); });
@@ -55,7 +55,8 @@ var initialState = {
55
55
  slides: {},
56
56
  skills: [],
57
57
  token: '1234',
58
- corrections: {}
58
+ corrections: {},
59
+ rank: {}
59
60
  },
60
61
  ui: {
61
62
  currentSlideRef: '',
@@ -57,7 +57,8 @@ var initialState = {
57
57
  slides: {},
58
58
  skills: [],
59
59
  token: '1234',
60
- corrections: {}
60
+ corrections: {},
61
+ rank: {}
61
62
  },
62
63
  ui: {
63
64
  currentSlideRef: '',
@@ -85,7 +85,8 @@ var initialState = {
85
85
  _a),
86
86
  skills: [{ skillRef: skillRef, custom: false, name: skillRef, slidesToReview: 5 }],
87
87
  token: '1234',
88
- corrections: {}
88
+ corrections: {},
89
+ rank: {}
89
90
  },
90
91
  ui: {
91
92
  currentSlideRef: freeTextSlide._id,
@@ -58,7 +58,8 @@ var initialState = {
58
58
  slides: {},
59
59
  skills: [],
60
60
  token: '1234',
61
- corrections: {}
61
+ corrections: {},
62
+ rank: {}
62
63
  },
63
64
  ui: {
64
65
  currentSlideRef: '',
@@ -44,7 +44,8 @@ var initialState = {
44
44
  slides: {},
45
45
  skills: [],
46
46
  token: '1234',
47
- corrections: {}
47
+ corrections: {},
48
+ rank: {}
48
49
  },
49
50
  ui: {
50
51
  currentSlideRef: '',
@@ -87,7 +87,8 @@ var initialState = {
87
87
  slides: {},
88
88
  skills: [],
89
89
  token: '1234',
90
- corrections: {}
90
+ corrections: {},
91
+ rank: {}
91
92
  },
92
93
  ui: {
93
94
  currentSlideRef: '',
@@ -45,7 +45,8 @@ var initialState = {
45
45
  slides: {},
46
46
  skills: [],
47
47
  token: '1234',
48
- corrections: {}
48
+ corrections: {},
49
+ rank: {}
49
50
  },
50
51
  ui: {
51
52
  currentSlideRef: '',
@@ -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
- }>, 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>;
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
- export default combineReducers({ corrections: corrections, progression: progression, skills: skills, slides: slides, token: token });
7
+ import rank from './rank';
8
+ export default combineReducers({ corrections: corrections, progression: progression, skills: skills, slides: slides, token: token, rank: rank });
@@ -0,0 +1,7 @@
1
+ import { RankAction } from '../../actions/api/fetch-rank';
2
+ export declare type RankState = {
3
+ start?: number | null;
4
+ end?: number | null;
5
+ };
6
+ declare const reducer: (state: RankState | undefined, action: RankAction) => RankState;
7
+ export default reducer;
@@ -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
+ });
@@ -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;
@@ -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;