@coorpacademy/app-review 0.1.16 → 0.1.17
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-skills.d.ts +3 -3
- package/es/actions/api/fetch-skills.js +7 -2
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +3 -1
- package/es/actions/api/post-answer.d.ts +10 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +3 -3
- package/es/actions/api/post-progression.js +5 -2
- package/es/actions/api/test/fetch-skills.test.js +7 -4
- package/es/actions/api/test/fetch-slide.test.js +7 -4
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.js +7 -4
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/es/actions/{api/test → test}/create-test-store.js +1 -1
- package/es/actions/ui/answers.d.ts +17 -3
- package/es/actions/ui/answers.js +39 -3
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +90 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +1 -1
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/answers.js +4 -8
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.js +19 -3
- package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/es/reducers/ui/test/navigation.test.js +5 -5
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/test/util/services.mock.d.ts +2 -1
- package/es/test/util/services.mock.js +86 -72
- package/es/types/common.d.ts +0 -25
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +13 -2
- package/es/views/slides/index.js +18 -14
- package/es/views/slides/map-api-slide-to-ui.js +44 -51
- package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/es/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -0
- package/lib/actions/api/fetch-skills.d.ts +3 -3
- package/lib/actions/api/fetch-skills.js +22 -19
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +3 -1
- package/lib/actions/api/post-answer.d.ts +10 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +3 -3
- package/lib/actions/api/post-progression.js +6 -3
- package/lib/actions/api/test/fetch-skills.test.js +7 -4
- package/lib/actions/api/test/fetch-slide.test.js +7 -4
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.js +7 -4
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/lib/actions/{api/test → test}/create-test-store.js +1 -1
- package/lib/actions/ui/answers.d.ts +17 -3
- package/lib/actions/ui/answers.js +48 -3
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +171 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +1 -1
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/answers.js +4 -8
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.js +19 -3
- package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/lib/reducers/ui/test/navigation.test.js +5 -5
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/test/util/services.mock.d.ts +2 -1
- package/lib/test/util/services.mock.js +86 -72
- package/lib/types/common.d.ts +0 -25
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +13 -2
- package/lib/views/slides/index.js +18 -14
- package/lib/views/slides/map-api-slide-to-ui.js +77 -76
- package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/lib/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -0
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +18 -11
- package/src/actions/api/fetch-slide.ts +3 -1
- package/src/actions/api/post-answer.ts +39 -0
- package/src/actions/api/post-progression.ts +7 -4
- package/src/actions/api/test/fetch-skills.test.ts +9 -6
- package/src/actions/api/test/fetch-slide.test.ts +9 -6
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +9 -6
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/{api/test → test}/create-test-store.ts +2 -2
- package/src/actions/ui/answers.ts +52 -5
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +103 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +1 -3
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +3 -3
- package/src/reducers/ui/answers.ts +5 -9
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +24 -4
- package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
- package/src/reducers/ui/test/navigation.test.ts +5 -5
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/test/util/services.mock.ts +91 -73
- package/src/types/common.ts +0 -30
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +37 -22
- package/src/views/slides/map-api-slide-to-ui.ts +89 -89
- package/src/views/slides/test/fixtures/free-text.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
- package/src/views/slides/test/fixtures/qcm.ts +2 -1
- package/src/views/slides/test/fixtures/select-template.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/text-template.ts +2 -1
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +2 -1
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import test from 'ava';
|
|
38
|
+
import pipe from 'lodash/fp/pipe';
|
|
39
|
+
import set from 'lodash/fp/set';
|
|
40
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
41
|
+
import { services } from '../../../test/util/services.mock';
|
|
42
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
43
|
+
import { qcmDragSlide } from '../../../views/slides/test/fixtures/qcm-drag';
|
|
44
|
+
import { qcmSlide } from '../../../views/slides/test/fixtures/qcm';
|
|
45
|
+
import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
46
|
+
import { sliderSlide } from '../../../views/slides/test/fixtures/slider';
|
|
47
|
+
import { editAnswer, ANSWER_EDIT } from '../answers';
|
|
48
|
+
var initialState = {
|
|
49
|
+
data: {
|
|
50
|
+
progression: {
|
|
51
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
52
|
+
content: {
|
|
53
|
+
ref: '_skill-ref',
|
|
54
|
+
type: 'skill'
|
|
55
|
+
},
|
|
56
|
+
engine: {
|
|
57
|
+
ref: 'review'
|
|
58
|
+
},
|
|
59
|
+
state: {
|
|
60
|
+
allAnswers: [],
|
|
61
|
+
isCorrect: true,
|
|
62
|
+
nextContent: {
|
|
63
|
+
ref: '',
|
|
64
|
+
type: 'slide'
|
|
65
|
+
},
|
|
66
|
+
pendingSlides: [],
|
|
67
|
+
slides: [],
|
|
68
|
+
step: {
|
|
69
|
+
current: 1
|
|
70
|
+
},
|
|
71
|
+
stars: 0
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
slides: {},
|
|
75
|
+
skills: [],
|
|
76
|
+
token: '1234'
|
|
77
|
+
},
|
|
78
|
+
ui: {
|
|
79
|
+
currentSlideRef: '',
|
|
80
|
+
navigation: [],
|
|
81
|
+
answers: [],
|
|
82
|
+
slide: {
|
|
83
|
+
validateButton: false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var buildInitialState = function (state, question) {
|
|
88
|
+
return pipe(set(['data', 'progression', 'state', 'nextContent', 'ref'], question.id), set(['data', 'slides', question.id], question), set(['ui', 'currentSlideRef'], question.id))(state);
|
|
89
|
+
};
|
|
90
|
+
test('should dispatch EDIT_BASIC action when editAnswer is called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
var state, expectedActions, dispatch;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
state = buildInitialState(initialState, freeTextSlide);
|
|
96
|
+
expectedActions = [{ type: ANSWER_EDIT.basic, payload: ['My Answer'] }];
|
|
97
|
+
dispatch = createTestStore(t, state, services, expectedActions).dispatch;
|
|
98
|
+
return [4 /*yield*/, dispatch(editAnswer('My Answer'))];
|
|
99
|
+
case 1:
|
|
100
|
+
_a.sent();
|
|
101
|
+
return [2 /*return*/];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}); });
|
|
105
|
+
test('should dispatch EDIT_QCM action when editAnswer is called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
+
var state, expectedActions, dispatch;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
switch (_a.label) {
|
|
109
|
+
case 0:
|
|
110
|
+
state = buildInitialState(initialState, qcmSlide);
|
|
111
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
112
|
+
expectedActions = [{ type: ANSWER_EDIT.qcm, payload: ['My First Answer'] }];
|
|
113
|
+
dispatch = createTestStore(t, state, services, expectedActions).dispatch;
|
|
114
|
+
return [4 /*yield*/, dispatch(editAnswer('My Second Answer'))];
|
|
115
|
+
case 1:
|
|
116
|
+
_a.sent();
|
|
117
|
+
return [2 /*return*/];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}); });
|
|
121
|
+
test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
var state, expectedActions, dispatch;
|
|
123
|
+
return __generator(this, function (_a) {
|
|
124
|
+
switch (_a.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
state = buildInitialState(initialState, qcmGraphicSlide);
|
|
127
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer', 'My Third Answer'], state);
|
|
128
|
+
expectedActions = [
|
|
129
|
+
{ type: ANSWER_EDIT.qcmGraphic, payload: ['My First Answer', 'My Third Answer'] }
|
|
130
|
+
];
|
|
131
|
+
dispatch = createTestStore(t, state, services, expectedActions).dispatch;
|
|
132
|
+
return [4 /*yield*/, dispatch(editAnswer('My Second Answer'))];
|
|
133
|
+
case 1:
|
|
134
|
+
_a.sent();
|
|
135
|
+
return [2 /*return*/];
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}); });
|
|
139
|
+
test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
140
|
+
var state, expectedActions, dispatch;
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
state = buildInitialState(initialState, qcmDragSlide);
|
|
145
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
146
|
+
expectedActions = [
|
|
147
|
+
{ type: ANSWER_EDIT.qcmDrag, payload: ['My First Answer', 'My Second Answer', 'My Third Answer'] }
|
|
148
|
+
];
|
|
149
|
+
dispatch = createTestStore(t, state, services, expectedActions).dispatch;
|
|
150
|
+
return [4 /*yield*/, dispatch(editAnswer('My Third Answer'))];
|
|
151
|
+
case 1:
|
|
152
|
+
_a.sent();
|
|
153
|
+
return [2 /*return*/];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}); });
|
|
157
|
+
test('should dispatch EDIT_SLIDER action when editAnswer is called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
+
var state, expectedActions, dispatch;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
switch (_a.label) {
|
|
161
|
+
case 0:
|
|
162
|
+
state = buildInitialState(initialState, sliderSlide);
|
|
163
|
+
expectedActions = [{ type: ANSWER_EDIT.slider, payload: ['5'] }];
|
|
164
|
+
dispatch = createTestStore(t, state, services, expectedActions).dispatch;
|
|
165
|
+
return [4 /*yield*/, dispatch(editAnswer('5'))];
|
|
166
|
+
case 1:
|
|
167
|
+
_a.sent();
|
|
168
|
+
return [2 /*return*/];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}); });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (_) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import test from 'ava';
|
|
38
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
39
|
+
import { services } from '../../../test/util/services.mock';
|
|
40
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
41
|
+
import { setCurrentSlide, SET_CURRENT_SLIDE } from '../slides';
|
|
42
|
+
var initialState = {
|
|
43
|
+
data: {
|
|
44
|
+
progression: null,
|
|
45
|
+
slides: {},
|
|
46
|
+
skills: [],
|
|
47
|
+
token: '1234'
|
|
48
|
+
},
|
|
49
|
+
ui: {
|
|
50
|
+
currentSlideRef: '',
|
|
51
|
+
navigation: [],
|
|
52
|
+
answers: [],
|
|
53
|
+
slide: {
|
|
54
|
+
validateButton: false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
test('should dispatch SET_CURRENT_SLIDE action when setCurrentSlide is called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
+
var expectedActions, dispatch;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
expectedActions = [{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }];
|
|
64
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
65
|
+
return [4 /*yield*/, dispatch(setCurrentSlide(freeTextSlide))];
|
|
66
|
+
case 1:
|
|
67
|
+
_a.sent();
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}); });
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export declare const TOTAL_SLIDES_STACK = 5;
|
|
2
|
-
export declare const HIGHEST_INDEX: number;
|
|
3
1
|
export declare const VIEWS: {
|
|
4
2
|
readonly skills: 'skills';
|
|
5
3
|
readonly onboarding: 'onboarding';
|
|
@@ -7,4 +5,3 @@ export declare const VIEWS: {
|
|
|
7
5
|
};
|
|
8
6
|
export declare const slideIndexes: readonly ["0", "1", "2", "3", "4"];
|
|
9
7
|
export declare type SlideIndexes = typeof slideIndexes[number];
|
|
10
|
-
export declare const indexToString: (index: number) => SlideIndexes;
|
package/lib/common/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import _toString from 'lodash/fp/toString';
|
|
2
|
-
export var TOTAL_SLIDES_STACK = 5;
|
|
3
|
-
export var HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
4
1
|
export var VIEWS = {
|
|
5
2
|
skills: 'skills',
|
|
6
3
|
onboarding: 'onboarding',
|
|
7
4
|
slides: 'slides'
|
|
8
5
|
};
|
|
9
6
|
export var slideIndexes = ['0', '1', '2', '3', '4'];
|
|
10
|
-
export var indexToString = function (index) { return _toString(index); };
|
package/lib/index.js
CHANGED
|
@@ -63,9 +63,7 @@ var AppReview = function (_a) {
|
|
|
63
63
|
var skillRef = get('skillRef', options);
|
|
64
64
|
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
65
65
|
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
66
|
-
skillRef
|
|
67
|
-
? store.dispatch(postProgression(skillRef, token))
|
|
68
|
-
: store.dispatch(fetchSkills(token));
|
|
66
|
+
skillRef ? store.dispatch(postProgression(skillRef)) : store.dispatch(fetchSkills);
|
|
69
67
|
}, [options, store]);
|
|
70
68
|
useEffect(function () {
|
|
71
69
|
if (store === null)
|
|
@@ -14,5 +14,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
14
14
|
skills: SkillsState;
|
|
15
15
|
slides: SlidesState;
|
|
16
16
|
token: TokenState;
|
|
17
|
-
}>, import("../../actions/api/post-progression").
|
|
17
|
+
}>, import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
|
|
18
18
|
export default _default;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReceiveProgression } from '../../actions/api/post-progression';
|
|
1
|
+
import { ReceivedProgression } from '../../actions/api/post-progression';
|
|
3
2
|
import { ProgressionFromAPI } from '../../types/common';
|
|
4
3
|
export declare type ProgressionState = ProgressionFromAPI | null;
|
|
5
|
-
declare const reducer: (state: ProgressionState | undefined, action:
|
|
4
|
+
declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression) => ProgressionState;
|
|
6
5
|
export default reducer;
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import { VALIDATE_SLIDE } from '../../actions/ui/slides';
|
|
2
1
|
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
3
2
|
var reducer = function (
|
|
4
3
|
// eslint-disable-next-line default-param-last
|
|
5
4
|
state, action) {
|
|
6
5
|
if (state === void 0) { state = null; }
|
|
7
6
|
switch (action.type) {
|
|
8
|
-
case VALIDATE_SLIDE: {
|
|
9
|
-
// TODO: fix on VALIDATE ticket -> launch a POST PROGRESSION
|
|
10
|
-
return state;
|
|
11
|
-
}
|
|
12
7
|
case POST_PROGRESSION_SUCCESS: {
|
|
13
8
|
var progression = action.payload;
|
|
14
9
|
return progression;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ValidateSlide } from '../../actions/ui/slides';
|
|
2
1
|
import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
|
|
3
2
|
import { SlideFromAPI } from '../../types/common';
|
|
4
|
-
export declare type SlidesAction = FetchSlide | ReceivedSlide
|
|
5
|
-
export declare type SlidesState = Record<string, SlideFromAPI>;
|
|
3
|
+
export declare type SlidesAction = FetchSlide | ReceivedSlide;
|
|
4
|
+
export declare type SlidesState = Record<string, SlideFromAPI | null>;
|
|
6
5
|
export declare const initialState: SlidesState;
|
|
7
6
|
declare const reducer: (state: SlidesState | undefined, action: SlidesAction) => SlidesState;
|
|
8
7
|
export default reducer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../progression';
|
|
3
3
|
import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
|
|
4
|
-
test('should have
|
|
4
|
+
test('should have initial value', function (t) {
|
|
5
5
|
var state = reducer(undefined, {});
|
|
6
6
|
t.is(state, null);
|
|
7
7
|
});
|
package/lib/reducers/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
15
15
|
currentSlideRef: string;
|
|
16
16
|
navigation: import("./ui/navigation").NavigationState;
|
|
17
17
|
answers: import("./ui/answers").AnswerState;
|
|
18
|
+
slide: import("./ui/slide").UISlideState;
|
|
18
19
|
}>;
|
|
19
|
-
}>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-progression").
|
|
20
|
+
}>, import("../actions/ui/slides").SetCurrentSlide | 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 | import("../actions/api/post-answer").PostAnswerRequestAction>;
|
|
20
21
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
2
|
export declare type AnswerState = string[];
|
|
3
|
-
declare const reducer: (state: AnswerState | undefined, action:
|
|
3
|
+
declare const reducer: (state: AnswerState | undefined, action: EditAnswerAction) => AnswerState;
|
|
4
4
|
export default reducer;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { includes, values } from 'lodash/fp';
|
|
2
|
+
import { ANSWER_EDIT } from '../../actions/ui/answers';
|
|
3
|
+
var ANSWER_EDIT_ACTIONS = values(ANSWER_EDIT);
|
|
2
4
|
var reducer = function (
|
|
3
5
|
// eslint-disable-next-line default-param-last
|
|
4
6
|
state, action) {
|
|
5
7
|
if (state === void 0) { state = []; }
|
|
6
|
-
|
|
7
|
-
case EDIT_BASIC: {
|
|
8
|
-
return action.payload;
|
|
9
|
-
}
|
|
10
|
-
default:
|
|
11
|
-
return state;
|
|
12
|
-
}
|
|
8
|
+
return includes(action.type, ANSWER_EDIT_ACTIONS) ? action.payload : state;
|
|
13
9
|
};
|
|
14
10
|
export default reducer;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { CurrentSlideRefState } from './current-slide-ref';
|
|
2
2
|
import { NavigationState } from './navigation';
|
|
3
3
|
import { AnswerState } from './answers';
|
|
4
|
+
import { UISlideState } from './slide';
|
|
4
5
|
export declare type UIState = {
|
|
5
6
|
currentSlideRef: CurrentSlideRefState;
|
|
6
7
|
navigation: NavigationState;
|
|
7
8
|
answers: AnswerState;
|
|
9
|
+
slide: UISlideState;
|
|
8
10
|
};
|
|
9
11
|
declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
10
12
|
currentSlideRef: string;
|
|
11
13
|
navigation: NavigationState;
|
|
12
14
|
answers: AnswerState;
|
|
13
|
-
|
|
15
|
+
slide: UISlideState;
|
|
16
|
+
}>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction | import("../../actions/api/post-answer").PostAnswerRequestAction>;
|
|
14
17
|
export default _default;
|
package/lib/reducers/ui/index.js
CHANGED
|
@@ -2,8 +2,10 @@ import { combineReducers } from 'redux';
|
|
|
2
2
|
import currentSlideRef from './current-slide-ref';
|
|
3
3
|
import navigation from './navigation';
|
|
4
4
|
import answers from './answers';
|
|
5
|
+
import slide from './slide';
|
|
5
6
|
export default combineReducers({
|
|
6
7
|
currentSlideRef: currentSlideRef,
|
|
7
8
|
navigation: navigation,
|
|
8
|
-
answers: answers
|
|
9
|
+
answers: answers,
|
|
10
|
+
slide: slide
|
|
9
11
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EditAnswerAction } from '../../actions/ui/answers';
|
|
2
|
+
import { PostAnswerRequestAction } from '../../actions/api/post-answer';
|
|
3
|
+
export declare type UISlideState = {
|
|
4
|
+
validateButton: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const initialState: UISlideState;
|
|
7
|
+
declare const reducer: (state: UISlideState | undefined, action: PostAnswerRequestAction | EditAnswerAction) => UISlideState;
|
|
8
|
+
export default reducer;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import compact from 'lodash/fp/compact';
|
|
2
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
3
|
+
import pipe from 'lodash/fp/pipe';
|
|
4
|
+
import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
|
|
5
|
+
import { POST_ANSWER_REQUEST } from '../../actions/api/post-answer';
|
|
6
|
+
export var initialState = { validateButton: false };
|
|
7
|
+
var reducer = function (
|
|
8
|
+
// eslint-disable-next-line default-param-last
|
|
9
|
+
state, action) {
|
|
10
|
+
if (state === void 0) { state = initialState; }
|
|
11
|
+
switch (action.type) {
|
|
12
|
+
case EDIT_QCM:
|
|
13
|
+
case EDIT_QCM_GRAPHIC:
|
|
14
|
+
case EDIT_QCM_DRAG:
|
|
15
|
+
case EDIT_TEMPLATE:
|
|
16
|
+
case EDIT_BASIC:
|
|
17
|
+
case EDIT_SLIDER: {
|
|
18
|
+
return pipe(compact, isEmpty)(action.payload) ? initialState : { validateButton: true };
|
|
19
|
+
}
|
|
20
|
+
case POST_ANSWER_REQUEST: {
|
|
21
|
+
return initialState;
|
|
22
|
+
}
|
|
23
|
+
default:
|
|
24
|
+
return state;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export default reducer;
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../answers';
|
|
3
|
-
import {
|
|
4
|
-
test('should have
|
|
3
|
+
import { ANSWER_EDIT } from '../../../actions/ui/answers';
|
|
4
|
+
test('should have initial value', function (t) {
|
|
5
5
|
var state = reducer(undefined, {});
|
|
6
6
|
t.deepEqual(state, []);
|
|
7
7
|
});
|
|
8
8
|
test('should set the value of EDIT_BASIC action', function (t) {
|
|
9
|
-
var state = reducer([], { type:
|
|
9
|
+
var state = reducer([], { type: ANSWER_EDIT.basic, payload: ['value'] });
|
|
10
10
|
t.deepEqual(state, ['value']);
|
|
11
11
|
});
|
|
12
|
+
test('should set the value of EDIT_QCM action', function (t) {
|
|
13
|
+
var state = reducer([], { type: ANSWER_EDIT.qcm, payload: ['value1', 'value2'] });
|
|
14
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
15
|
+
});
|
|
16
|
+
test('should set the value of EDIT_QCM_GRAPHIC action', function (t) {
|
|
17
|
+
var state = reducer([], { type: ANSWER_EDIT.qcmGraphic, payload: ['True', 'False'] });
|
|
18
|
+
t.deepEqual(state, ['True', 'False']);
|
|
19
|
+
});
|
|
20
|
+
test('should set the value of EDIT_QCM_DRAG action', function (t) {
|
|
21
|
+
var state = reducer([], { type: ANSWER_EDIT.qcmDrag, payload: ['value1', 'value2'] });
|
|
22
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
23
|
+
});
|
|
24
|
+
test('should set the value of EDIT_SLIDER action', function (t) {
|
|
25
|
+
var state = reducer([], { type: ANSWER_EDIT.slider, payload: ['5'] });
|
|
26
|
+
t.deepEqual(state, ['5']);
|
|
27
|
+
});
|
|
@@ -2,7 +2,7 @@ import test from 'ava';
|
|
|
2
2
|
import reducer from '../current-slide-ref';
|
|
3
3
|
import { SET_CURRENT_SLIDE } from '../../../actions/ui/slides';
|
|
4
4
|
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
-
test('should have
|
|
5
|
+
test('should have initial value', function (t) {
|
|
6
6
|
var state = reducer(undefined, {});
|
|
7
7
|
t.is(state, '');
|
|
8
8
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../navigation';
|
|
3
|
-
import {
|
|
4
|
-
test('should have
|
|
3
|
+
import { navigateBack, navigateTo } from '../../../actions/ui/navigation';
|
|
4
|
+
test('should have initial value', function (t) {
|
|
5
5
|
var state = reducer(undefined, {});
|
|
6
6
|
t.deepEqual(state, []);
|
|
7
7
|
});
|
|
8
8
|
test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', function (t) {
|
|
9
|
-
var state = reducer([],
|
|
9
|
+
var state = reducer([], navigateTo('loader'));
|
|
10
10
|
t.deepEqual(state, ['loader']);
|
|
11
|
-
var updatedState = reducer(state,
|
|
11
|
+
var updatedState = reducer(state, navigateTo('skills'));
|
|
12
12
|
t.deepEqual(updatedState, ['loader', 'skills']);
|
|
13
|
-
var _updatedState = reducer(updatedState,
|
|
13
|
+
var _updatedState = reducer(updatedState, navigateBack());
|
|
14
14
|
t.deepEqual(_updatedState, ['loader']);
|
|
15
15
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer, { initialState } from '../slide';
|
|
3
|
+
import { EDIT_BASIC } from '../../../actions/ui/answers';
|
|
4
|
+
test('should use initial state if no answers are found when an EditAnswerAction is received', function (t) {
|
|
5
|
+
var state = reducer(undefined, { type: EDIT_BASIC, payload: [''] });
|
|
6
|
+
t.truthy(state);
|
|
7
|
+
t.false(state.validateButton);
|
|
8
|
+
});
|
|
9
|
+
test('should return state directly when there is no corresponding action handler + have an initial state', function (t) {
|
|
10
|
+
var state = reducer(undefined, { type: 'NOPE' });
|
|
11
|
+
t.deepEqual(state, initialState);
|
|
12
|
+
});
|