@coorpacademy/app-review 0.1.15 → 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 +5 -7
- package/es/actions/api/fetch-skills.js +12 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +23 -18
- 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 +5 -7
- package/es/actions/api/post-progression.js +16 -8
- package/es/actions/api/test/fetch-skills.test.js +57 -0
- package/es/actions/api/test/fetch-slide.test.js +64 -0
- 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.d.ts +1 -0
- package/es/actions/api/test/post-progression.test.js +105 -0
- 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/test/create-test-store.d.ts +5 -0
- package/es/actions/test/create-test-store.js +16 -0
- package/es/actions/ui/answers.d.ts +21 -0
- package/es/actions/ui/answers.js +43 -0
- 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 +11 -19
- package/es/reducers/data/index.d.ts +2 -2
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +3 -4
- package/es/reducers/data/slides.js +5 -1
- package/es/reducers/data/test/progression.test.d.ts +1 -0
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.d.ts +1 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.d.ts +1 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.d.ts +1 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +3 -2
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/answers.js +9 -0
- package/es/reducers/ui/index.d.ts +7 -4
- package/es/reducers/ui/index.js +4 -2
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.d.ts +1 -0
- package/es/reducers/ui/test/answers.test.js +27 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +9 -1
- package/es/test/util/services.mock.d.ts +2 -1
- package/es/test/util/services.mock.js +88 -44
- package/es/types/common.d.ts +22 -33
- 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 +89 -2
- package/es/views/slides/index.js +80 -10
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +165 -0
- package/es/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/es/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +5 -7
- package/lib/actions/api/fetch-skills.js +58 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +72 -20
- 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 +5 -7
- package/lib/actions/api/post-progression.js +67 -10
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +116 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +123 -0
- 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.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +163 -0
- 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/test/create-test-store.d.ts +5 -0
- package/lib/actions/test/create-test-store.js +18 -0
- package/lib/actions/ui/answers.d.ts +21 -0
- package/lib/actions/ui/answers.js +54 -0
- 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 +22 -21
- package/lib/reducers/data/index.d.ts +2 -2
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +3 -4
- package/lib/reducers/data/slides.js +5 -1
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +3 -2
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/answers.js +10 -0
- package/lib/reducers/ui/index.d.ts +7 -4
- package/lib/reducers/ui/index.js +4 -2
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +27 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +9 -1
- package/lib/test/util/services.mock.d.ts +2 -1
- package/lib/test/util/services.mock.js +88 -44
- package/lib/types/common.d.ts +22 -33
- 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 +89 -2
- package/lib/views/slides/index.js +80 -10
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +179 -0
- package/lib/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/lib/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +19 -12
- package/src/actions/api/fetch-slide.ts +35 -29
- package/src/actions/api/post-answer.ts +39 -0
- package/src/actions/api/post-progression.ts +22 -22
- package/src/actions/api/test/fetch-skills.test.ts +73 -0
- package/src/actions/api/test/fetch-slide.test.ts +80 -0
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +122 -0
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/test/create-test-store.ts +25 -0
- package/src/actions/ui/answers.ts +63 -0
- 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 +15 -32
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +12 -4
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +15 -0
- package/src/reducers/ui/index.ts +6 -3
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +33 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +9 -1
- package/src/test/util/services.mock.ts +93 -45
- package/src/types/common.ts +34 -44
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +186 -12
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +44 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +112 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +95 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +7 -2
- package/src/views/slides/test/fixtures/select-template.ts +99 -0
- package/src/views/slides/test/fixtures/slider.ts +42 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +7 -2
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -10
- 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/es/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/es/helpers/map-api-slide-to-ui.js +0 -193
- package/es/helpers/test/fixtures/free-text.js +0 -30
- package/es/helpers/test/fixtures/qcm-drag.js +0 -112
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/es/helpers/test/fixtures/select-template.js +0 -94
- package/es/helpers/test/fixtures/slider.js +0 -33
- package/es/reducers/ui/slides.d.ts +0 -9
- package/es/reducers/ui/slides.js +0 -42
- package/es/types/views/slides.d.ts +0 -74
- package/es/types/views/slides.js +0 -6
- 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/lib/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/lib/helpers/map-api-slide-to-ui.js +0 -201
- package/lib/helpers/test/fixtures/free-text.js +0 -30
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -112
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/lib/helpers/test/fixtures/select-template.js +0 -94
- package/lib/helpers/test/fixtures/slider.js +0 -33
- package/lib/reducers/ui/slides.d.ts +0 -9
- package/lib/reducers/ui/slides.js +0 -43
- package/lib/types/views/slides.d.ts +0 -74
- package/lib/types/views/slides.js +0 -6
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
- package/src/helpers/map-api-slide-to-ui.ts +0 -279
- package/src/helpers/test/fixtures/free-text.ts +0 -33
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -115
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -79
- package/src/helpers/test/fixtures/select-template.ts +0 -97
- package/src/helpers/test/fixtures/slider.ts +0 -36
- package/src/reducers/ui/slides.ts +0 -58
- package/src/types/views/slides.ts +0 -90
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/actions/api/test/fetch-slide.test.d.ts} +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import { Options, ProgressionFromAPI } from '../../types/common';
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { Options, ProgressionFromAPI } from '../../types/common';
|
|
4
3
|
import type { StoreState } from '../../reducers';
|
|
5
4
|
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
6
5
|
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
7
6
|
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
8
|
-
export
|
|
7
|
+
export declare type ReceivedProgression = {
|
|
9
8
|
type: typeof POST_PROGRESSION_SUCCESS;
|
|
10
9
|
payload: ProgressionFromAPI;
|
|
11
|
-
}
|
|
12
|
-
export declare
|
|
13
|
-
export declare const postProgression: (skillRef: string, token: string) => PostProgressionAction;
|
|
10
|
+
};
|
|
11
|
+
export declare const postProgression: (skillRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -1,17 +1,74 @@
|
|
|
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
|
+
};
|
|
1
37
|
import buildTask from '@coorpacademy/redux-task';
|
|
38
|
+
import get from 'lodash/fp/get';
|
|
2
39
|
import { fetchSlide } from './fetch-slide';
|
|
3
40
|
export var POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST';
|
|
4
41
|
export var POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS';
|
|
5
42
|
export var POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE';
|
|
6
|
-
export var postProgression = function (skillRef
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
43
|
+
export var postProgression = function (skillRef) {
|
|
44
|
+
return function (dispatch, getState, _a) {
|
|
45
|
+
var services = _a.services;
|
|
46
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
+
var state, token, action, response, progression, slideRef;
|
|
48
|
+
return __generator(this, function (_b) {
|
|
49
|
+
switch (_b.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
state = getState();
|
|
52
|
+
token = get('data.token', state);
|
|
53
|
+
action = buildTask({
|
|
54
|
+
types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
|
|
55
|
+
task: function () {
|
|
56
|
+
return services.postProgression(skillRef, token);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return [4 /*yield*/, dispatch(action)];
|
|
60
|
+
case 1:
|
|
61
|
+
response = _b.sent();
|
|
62
|
+
if (!(response.type === POST_PROGRESSION_SUCCESS)) return [3 /*break*/, 3];
|
|
63
|
+
progression = response.payload;
|
|
64
|
+
slideRef = progression.state.nextContent.ref;
|
|
65
|
+
return [4 /*yield*/, dispatch(fetchSlide(slideRef))];
|
|
66
|
+
case 2:
|
|
67
|
+
_b.sent();
|
|
68
|
+
_b.label = 3;
|
|
69
|
+
case 3: return [2 /*return*/];
|
|
70
|
+
}
|
|
14
71
|
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
72
|
+
});
|
|
73
|
+
};
|
|
17
74
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
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 { fetchSkills, SKILLS_FETCH_FAILURE, SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS } from '../fetch-skills';
|
|
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
|
+
},
|
|
59
|
+
ui: {
|
|
60
|
+
currentSlideRef: '',
|
|
61
|
+
navigation: [],
|
|
62
|
+
answers: [],
|
|
63
|
+
slide: {
|
|
64
|
+
validateButton: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
test('should dispatch SKILLS_FETCH_SUCCESS actions when fetchSkills return a list of skills', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var services, expectedActions, dispatch;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
services = __assign(__assign({}, mockedServices), { fetchSkills: function (token) {
|
|
74
|
+
t.is(token, '1234');
|
|
75
|
+
return Promise.resolve([]);
|
|
76
|
+
} });
|
|
77
|
+
expectedActions = [
|
|
78
|
+
{ type: SKILLS_FETCH_REQUEST },
|
|
79
|
+
{
|
|
80
|
+
type: SKILLS_FETCH_SUCCESS,
|
|
81
|
+
payload: []
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
85
|
+
return [4 /*yield*/, dispatch(fetchSkills)];
|
|
86
|
+
case 1:
|
|
87
|
+
_a.sent();
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}); });
|
|
92
|
+
test('should dispatch SKILLS_FETCH_FAILURE action when fetchSkills fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var services, expectedActions, dispatch;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
switch (_a.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
services = __assign(__assign({}, mockedServices), { fetchSkills: function (token) {
|
|
98
|
+
t.is(token, '1234');
|
|
99
|
+
return Promise.reject(new Error('unexpected'));
|
|
100
|
+
} });
|
|
101
|
+
expectedActions = [
|
|
102
|
+
{ type: SKILLS_FETCH_REQUEST },
|
|
103
|
+
{
|
|
104
|
+
type: SKILLS_FETCH_FAILURE,
|
|
105
|
+
payload: new Error('unexpected'),
|
|
106
|
+
error: true
|
|
107
|
+
}
|
|
108
|
+
];
|
|
109
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
110
|
+
return [4 /*yield*/, dispatch(fetchSkills)];
|
|
111
|
+
case 1:
|
|
112
|
+
_a.sent();
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}); });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,123 @@
|
|
|
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 { fetchSlide, SLIDE_FETCH_FAILURE, SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
50
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
51
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
52
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
53
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
54
|
+
var initialState = {
|
|
55
|
+
data: {
|
|
56
|
+
progression: null,
|
|
57
|
+
slides: {},
|
|
58
|
+
skills: [],
|
|
59
|
+
token: '1234'
|
|
60
|
+
},
|
|
61
|
+
ui: {
|
|
62
|
+
currentSlideRef: '',
|
|
63
|
+
navigation: [],
|
|
64
|
+
answers: [],
|
|
65
|
+
slide: {
|
|
66
|
+
validateButton: false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
test('should dispatch FETCH_SUCCESS and SET_CURRENT_SLIDE actions when fetchSlide return a slide', 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
|
+
services = __assign(__assign({}, mockedServices), { fetchSlide: function (slideRef, token) {
|
|
76
|
+
t.is(token, '1234');
|
|
77
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
78
|
+
return Promise.resolve(freeTextSlide);
|
|
79
|
+
} });
|
|
80
|
+
expectedActions = [
|
|
81
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'sli_VJYjJnJhg' } },
|
|
82
|
+
{
|
|
83
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
84
|
+
meta: { slideRef: 'sli_VJYjJnJhg' },
|
|
85
|
+
payload: freeTextSlide
|
|
86
|
+
},
|
|
87
|
+
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
88
|
+
];
|
|
89
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
90
|
+
return [4 /*yield*/, dispatch(fetchSlide('sli_VJYjJnJhg'))];
|
|
91
|
+
case 1:
|
|
92
|
+
_a.sent();
|
|
93
|
+
return [2 /*return*/];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}); });
|
|
97
|
+
test('should dispatch SLIDE_FETCH_FAILURE action when fetchSlide fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
+
var services, expectedActions, dispatch;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
services = __assign(__assign({}, mockedServices), { fetchSlide: function (slideRef, token) {
|
|
103
|
+
t.is(token, '1234');
|
|
104
|
+
t.is(slideRef, 'slide_ref');
|
|
105
|
+
return Promise.reject(new Error('error'));
|
|
106
|
+
} });
|
|
107
|
+
expectedActions = [
|
|
108
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'slide_ref' } },
|
|
109
|
+
{
|
|
110
|
+
type: SLIDE_FETCH_FAILURE,
|
|
111
|
+
meta: { slideRef: 'slide_ref' },
|
|
112
|
+
payload: new Error('error'),
|
|
113
|
+
error: true
|
|
114
|
+
}
|
|
115
|
+
];
|
|
116
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
117
|
+
return [4 /*yield*/, dispatch(fetchSlide('slide_ref'))];
|
|
118
|
+
case 1:
|
|
119
|
+
_a.sent();
|
|
120
|
+
return [2 /*return*/];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}); });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
var _a;
|
|
49
|
+
import test from 'ava';
|
|
50
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
51
|
+
import { postAnswerResponse, services } from '../../../test/util/services.mock';
|
|
52
|
+
import { postAnswer, POST_ANSWER_FAILURE, POST_ANSWER_REQUEST, POST_ANSWER_SUCCESS } from '../post-answer';
|
|
53
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
54
|
+
import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
55
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
56
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
57
|
+
var progressionId = '123456789123';
|
|
58
|
+
var skillRef = '_skill-ref';
|
|
59
|
+
var answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
60
|
+
var initialState = {
|
|
61
|
+
data: {
|
|
62
|
+
progression: {
|
|
63
|
+
_id: progressionId,
|
|
64
|
+
content: { type: 'skill', ref: skillRef },
|
|
65
|
+
engine: {
|
|
66
|
+
ref: 'review'
|
|
67
|
+
},
|
|
68
|
+
state: {
|
|
69
|
+
allAnswers: [],
|
|
70
|
+
isCorrect: true,
|
|
71
|
+
nextContent: {
|
|
72
|
+
ref: 'sli_VJYjJnJhg',
|
|
73
|
+
type: 'slide'
|
|
74
|
+
},
|
|
75
|
+
pendingSlides: [],
|
|
76
|
+
slides: [],
|
|
77
|
+
step: {
|
|
78
|
+
current: 1
|
|
79
|
+
},
|
|
80
|
+
stars: 0
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
slides: (_a = {},
|
|
84
|
+
_a[freeTextSlide.id] = freeTextSlide,
|
|
85
|
+
_a),
|
|
86
|
+
skills: [{ skillRef: skillRef, custom: false, name: skillRef, slidesToReview: 5 }],
|
|
87
|
+
token: '1234'
|
|
88
|
+
},
|
|
89
|
+
ui: {
|
|
90
|
+
currentSlideRef: 'sli_VJYjJnJhg',
|
|
91
|
+
navigation: ['skills', 'slides'],
|
|
92
|
+
answers: answer,
|
|
93
|
+
slide: {
|
|
94
|
+
validateButton: false
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
test('should dispatch POST_ANSWER_REQUEST, then POST_ANSWER_SUCCESS when the updated progression is returned', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
+
var expectedActions, dispatch;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
expectedActions = [
|
|
104
|
+
{ type: POST_ANSWER_REQUEST },
|
|
105
|
+
{
|
|
106
|
+
type: POST_ANSWER_SUCCESS,
|
|
107
|
+
payload: postAnswerResponse
|
|
108
|
+
},
|
|
109
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'sli_VkSQroQnx' } },
|
|
110
|
+
{
|
|
111
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
112
|
+
meta: { slideRef: 'sli_VkSQroQnx' },
|
|
113
|
+
payload: qcmGraphicSlide
|
|
114
|
+
},
|
|
115
|
+
{ type: SET_CURRENT_SLIDE, payload: qcmGraphicSlide }
|
|
116
|
+
];
|
|
117
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
118
|
+
return [4 /*yield*/, dispatch(postAnswer)];
|
|
119
|
+
case 1:
|
|
120
|
+
_a.sent();
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); });
|
|
125
|
+
test('should dispatch POST_ANSWER_REQUEST, then POST_ANSWER_FAILURE on error', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
+
var expectedActions, dispatch;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0:
|
|
130
|
+
expectedActions = [
|
|
131
|
+
{ type: POST_ANSWER_REQUEST },
|
|
132
|
+
{
|
|
133
|
+
type: POST_ANSWER_FAILURE,
|
|
134
|
+
payload: new Error('unexpected'),
|
|
135
|
+
error: true
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
dispatch = createTestStore(t, initialState, __assign(__assign({}, services), { postAnswer: function () { return Promise.reject(new Error('unexpected')); } }), expectedActions).dispatch;
|
|
139
|
+
return [4 /*yield*/, dispatch(postAnswer)];
|
|
140
|
+
case 1:
|
|
141
|
+
_a.sent();
|
|
142
|
+
return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
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 { postProgression, POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE } from '../post-progression';
|
|
50
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
51
|
+
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
52
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
53
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
54
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
55
|
+
var initialState = {
|
|
56
|
+
data: {
|
|
57
|
+
progression: null,
|
|
58
|
+
slides: {},
|
|
59
|
+
skills: [],
|
|
60
|
+
token: '1234'
|
|
61
|
+
},
|
|
62
|
+
ui: {
|
|
63
|
+
currentSlideRef: '',
|
|
64
|
+
navigation: [],
|
|
65
|
+
answers: [],
|
|
66
|
+
slide: {
|
|
67
|
+
validateButton: false
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
test('should dispatch POST_PROGRESSION_SUCCESS and SLIDE_FETCH_REQUEST actions when postProgression return a progression', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var progression, services, expectedActions, dispatch;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
progression = {
|
|
77
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
78
|
+
content: {
|
|
79
|
+
ref: '_skill-ref',
|
|
80
|
+
type: 'skill'
|
|
81
|
+
},
|
|
82
|
+
engine: {
|
|
83
|
+
ref: 'review'
|
|
84
|
+
},
|
|
85
|
+
state: {
|
|
86
|
+
allAnswers: [],
|
|
87
|
+
isCorrect: true,
|
|
88
|
+
nextContent: {
|
|
89
|
+
ref: 'sli_VJYjJnJhg',
|
|
90
|
+
type: 'slide'
|
|
91
|
+
},
|
|
92
|
+
pendingSlides: [],
|
|
93
|
+
slides: [],
|
|
94
|
+
step: {
|
|
95
|
+
current: 1
|
|
96
|
+
},
|
|
97
|
+
stars: 0
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
services = __assign(__assign({}, mockedServices), { postProgression: function (skillRef, token) {
|
|
101
|
+
t.is(token, '1234');
|
|
102
|
+
t.is(skillRef, 'skill_12345');
|
|
103
|
+
return Promise.resolve(progression);
|
|
104
|
+
}, fetchSlide: function (slideRef, token) {
|
|
105
|
+
t.is(token, '1234');
|
|
106
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
107
|
+
return Promise.resolve(freeTextSlide);
|
|
108
|
+
} });
|
|
109
|
+
expectedActions = [
|
|
110
|
+
{ type: POST_PROGRESSION_REQUEST },
|
|
111
|
+
{
|
|
112
|
+
type: POST_PROGRESSION_SUCCESS,
|
|
113
|
+
payload: progression
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
type: SLIDE_FETCH_REQUEST,
|
|
117
|
+
meta: {
|
|
118
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
123
|
+
meta: {
|
|
124
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
125
|
+
},
|
|
126
|
+
payload: freeTextSlide
|
|
127
|
+
},
|
|
128
|
+
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
129
|
+
];
|
|
130
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
131
|
+
return [4 /*yield*/, dispatch(postProgression('skill_12345'))];
|
|
132
|
+
case 1:
|
|
133
|
+
_a.sent();
|
|
134
|
+
return [2 /*return*/];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}); });
|
|
138
|
+
test('should dispatch POST_PROGRESSION_FAILURE action when postProgression fails', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
139
|
+
var services, expectedActions, dispatch;
|
|
140
|
+
return __generator(this, function (_a) {
|
|
141
|
+
switch (_a.label) {
|
|
142
|
+
case 0:
|
|
143
|
+
services = __assign(__assign({}, mockedServices), { postProgression: function (skillRef, token) {
|
|
144
|
+
t.is(token, '1234');
|
|
145
|
+
t.is(skillRef, 'skill_12345');
|
|
146
|
+
return Promise.reject(new Error('error'));
|
|
147
|
+
} });
|
|
148
|
+
expectedActions = [
|
|
149
|
+
{ type: POST_PROGRESSION_REQUEST },
|
|
150
|
+
{
|
|
151
|
+
type: POST_PROGRESSION_FAILURE,
|
|
152
|
+
payload: new Error('error'),
|
|
153
|
+
error: true
|
|
154
|
+
}
|
|
155
|
+
];
|
|
156
|
+
dispatch = createTestStore(t, initialState, services, expectedActions).dispatch;
|
|
157
|
+
return [4 /*yield*/, dispatch(postProgression('skill_12345'))];
|
|
158
|
+
case 1:
|
|
159
|
+
_a.sent();
|
|
160
|
+
return [2 /*return*/];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}); });
|