@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
|
@@ -17,10 +17,5 @@ export declare type SetCurrentSlide = {
|
|
|
17
17
|
payload: SlideFromAPI;
|
|
18
18
|
};
|
|
19
19
|
export declare const setCurrentSlide: (payload: SlideFromAPI) => SetCurrentSlide;
|
|
20
|
-
export declare const VALIDATE_SLIDE = "@@slide/VALIDATE";
|
|
21
|
-
export declare type ValidateSlide = {
|
|
22
|
-
type: typeof VALIDATE_SLIDE;
|
|
23
|
-
};
|
|
24
|
-
export declare const validateSlide: () => ValidateSlide;
|
|
25
20
|
export declare type UISlidesAction = SetCurrentSlide;
|
|
26
21
|
export {};
|
package/es/actions/ui/slides.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import pipe from 'lodash/fp/pipe';
|
|
3
|
+
import set from 'lodash/fp/set';
|
|
4
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
5
|
+
import { services } from '../../../test/util/services.mock';
|
|
6
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
7
|
+
import { qcmDragSlide } from '../../../views/slides/test/fixtures/qcm-drag';
|
|
8
|
+
import { qcmSlide } from '../../../views/slides/test/fixtures/qcm';
|
|
9
|
+
import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
10
|
+
import { sliderSlide } from '../../../views/slides/test/fixtures/slider';
|
|
11
|
+
import { editAnswer, ANSWER_EDIT } from '../answers';
|
|
12
|
+
const initialState = {
|
|
13
|
+
data: {
|
|
14
|
+
progression: {
|
|
15
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
16
|
+
content: {
|
|
17
|
+
ref: '_skill-ref',
|
|
18
|
+
type: 'skill'
|
|
19
|
+
},
|
|
20
|
+
engine: {
|
|
21
|
+
ref: 'review'
|
|
22
|
+
},
|
|
23
|
+
state: {
|
|
24
|
+
allAnswers: [],
|
|
25
|
+
isCorrect: true,
|
|
26
|
+
nextContent: {
|
|
27
|
+
ref: '',
|
|
28
|
+
type: 'slide'
|
|
29
|
+
},
|
|
30
|
+
pendingSlides: [],
|
|
31
|
+
slides: [],
|
|
32
|
+
step: {
|
|
33
|
+
current: 1
|
|
34
|
+
},
|
|
35
|
+
stars: 0
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
slides: {},
|
|
39
|
+
skills: [],
|
|
40
|
+
token: '1234'
|
|
41
|
+
},
|
|
42
|
+
ui: {
|
|
43
|
+
currentSlideRef: '',
|
|
44
|
+
navigation: [],
|
|
45
|
+
answers: [],
|
|
46
|
+
slide: {
|
|
47
|
+
validateButton: false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const buildInitialState = (state, question) => {
|
|
52
|
+
return pipe(set(['data', 'progression', 'state', 'nextContent', 'ref'], question.id), set(['data', 'slides', question.id], question), set(['ui', 'currentSlideRef'], question.id))(state);
|
|
53
|
+
};
|
|
54
|
+
test('should dispatch EDIT_BASIC action when editAnswer is called', async (t) => {
|
|
55
|
+
const state = buildInitialState(initialState, freeTextSlide);
|
|
56
|
+
const expectedActions = [{ type: ANSWER_EDIT.basic, payload: ['My Answer'] }];
|
|
57
|
+
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
58
|
+
await dispatch(editAnswer('My Answer'));
|
|
59
|
+
});
|
|
60
|
+
test('should dispatch EDIT_QCM action when editAnswer is called', async (t) => {
|
|
61
|
+
let state = buildInitialState(initialState, qcmSlide);
|
|
62
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
63
|
+
const expectedActions = [{ type: ANSWER_EDIT.qcm, payload: ['My First Answer'] }];
|
|
64
|
+
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
65
|
+
await dispatch(editAnswer('My Second Answer'));
|
|
66
|
+
});
|
|
67
|
+
test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', async (t) => {
|
|
68
|
+
let state = buildInitialState(initialState, qcmGraphicSlide);
|
|
69
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer', 'My Third Answer'], state);
|
|
70
|
+
const expectedActions = [
|
|
71
|
+
{ type: ANSWER_EDIT.qcmGraphic, payload: ['My First Answer', 'My Third Answer'] }
|
|
72
|
+
];
|
|
73
|
+
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
74
|
+
await dispatch(editAnswer('My Second Answer'));
|
|
75
|
+
});
|
|
76
|
+
test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', async (t) => {
|
|
77
|
+
let state = buildInitialState(initialState, qcmDragSlide);
|
|
78
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
79
|
+
const expectedActions = [
|
|
80
|
+
{ type: ANSWER_EDIT.qcmDrag, payload: ['My First Answer', 'My Second Answer', 'My Third Answer'] }
|
|
81
|
+
];
|
|
82
|
+
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
83
|
+
await dispatch(editAnswer('My Third Answer'));
|
|
84
|
+
});
|
|
85
|
+
test('should dispatch EDIT_SLIDER action when editAnswer is called', async (t) => {
|
|
86
|
+
const state = buildInitialState(initialState, sliderSlide);
|
|
87
|
+
const expectedActions = [{ type: ANSWER_EDIT.slider, payload: ['5'] }];
|
|
88
|
+
const { dispatch } = createTestStore(t, state, services, expectedActions);
|
|
89
|
+
await dispatch(editAnswer('5'));
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
3
|
+
import { services } from '../../../test/util/services.mock';
|
|
4
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
+
import { setCurrentSlide, SET_CURRENT_SLIDE } from '../slides';
|
|
6
|
+
const initialState = {
|
|
7
|
+
data: {
|
|
8
|
+
progression: null,
|
|
9
|
+
slides: {},
|
|
10
|
+
skills: [],
|
|
11
|
+
token: '1234'
|
|
12
|
+
},
|
|
13
|
+
ui: {
|
|
14
|
+
currentSlideRef: '',
|
|
15
|
+
navigation: [],
|
|
16
|
+
answers: [],
|
|
17
|
+
slide: {
|
|
18
|
+
validateButton: false
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
test('should dispatch SET_CURRENT_SLIDE action when setCurrentSlide is called', async (t) => {
|
|
23
|
+
const expectedActions = [{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }];
|
|
24
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
25
|
+
await dispatch(setCurrentSlide(freeTextSlide));
|
|
26
|
+
});
|
package/es/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/es/common/index.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import _toString from 'lodash/fp/toString';
|
|
2
|
-
export const TOTAL_SLIDES_STACK = 5;
|
|
3
|
-
export const HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
4
1
|
export const VIEWS = {
|
|
5
2
|
skills: 'skills',
|
|
6
3
|
onboarding: 'onboarding',
|
|
7
4
|
slides: 'slides'
|
|
8
5
|
};
|
|
9
6
|
export const slideIndexes = ['0', '1', '2', '3', '4'];
|
|
10
|
-
export const indexToString = (index) => _toString(index);
|
package/es/index.js
CHANGED
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
3
3
|
import AppReviewTemplate from '@coorpacademy/components/es/template/app-review';
|
|
4
4
|
import { TemplateContext } from '@coorpacademy/components/es/template/app-review/template-context';
|
|
5
5
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
6
6
|
import get from 'lodash/fp/get';
|
|
7
7
|
import configureStore from './configure-store';
|
|
8
|
-
import {
|
|
9
|
-
import { navigateTo, navigateBack } from './actions/ui/navigation';
|
|
8
|
+
import { navigateTo } from './actions/ui/navigation';
|
|
10
9
|
import { storeToken } from './actions/data/token';
|
|
11
10
|
import { fetchSkills } from './actions/api/fetch-skills';
|
|
12
11
|
import { postProgression } from './actions/api/post-progression';
|
|
13
12
|
import { VIEWS } from './common';
|
|
14
13
|
import { mapStateToSlidesProps } from './views/slides';
|
|
15
14
|
import { mapStateToSkillsProps } from './views/skills';
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const mapStateToProps = (state) => {
|
|
23
|
-
return {
|
|
24
|
-
viewName: getCurrentViewName(state),
|
|
25
|
-
slides: mapStateToSlidesProps(state),
|
|
26
|
-
skills: mapStateToSkillsProps(state)
|
|
15
|
+
const ConnectedApp = () => {
|
|
16
|
+
const dispatch = useDispatch();
|
|
17
|
+
const props = {
|
|
18
|
+
viewName: useSelector((state) => state.ui.navigation[state.ui.navigation.length - 1]),
|
|
19
|
+
slides: useSelector((state) => mapStateToSlidesProps(state, dispatch)),
|
|
20
|
+
skills: useSelector((state) => mapStateToSkillsProps(state))
|
|
27
21
|
};
|
|
22
|
+
return React.createElement(AppReviewTemplate, { ...props });
|
|
28
23
|
};
|
|
29
|
-
const App = connect(mapStateToProps, mapDispatchToProps)(AppReviewTemplate);
|
|
30
24
|
const AppReview = ({ options }) => {
|
|
31
25
|
const [store, setStore] = useState(null);
|
|
32
26
|
const [isProgressionCreated, setIsProgressionCreated] = useState(false);
|
|
@@ -57,9 +51,7 @@ const AppReview = ({ options }) => {
|
|
|
57
51
|
const skillRef = get('skillRef', options);
|
|
58
52
|
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
59
53
|
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
60
|
-
skillRef
|
|
61
|
-
? store.dispatch(postProgression(skillRef, token))
|
|
62
|
-
: store.dispatch(fetchSkills(token));
|
|
54
|
+
skillRef ? store.dispatch(postProgression(skillRef)) : store.dispatch(fetchSkills);
|
|
63
55
|
}, [options, store]);
|
|
64
56
|
useEffect(() => {
|
|
65
57
|
if (store === null)
|
|
@@ -77,6 +69,6 @@ const AppReview = ({ options }) => {
|
|
|
77
69
|
const { templateContext: values } = options;
|
|
78
70
|
return (React.createElement(Provider, { store: store },
|
|
79
71
|
React.createElement(TemplateContext, { values: values },
|
|
80
|
-
React.createElement(
|
|
72
|
+
React.createElement(ConnectedApp, null))));
|
|
81
73
|
};
|
|
82
74
|
export default AppReview;
|
|
@@ -4,7 +4,7 @@ import { SlidesState } from './slides';
|
|
|
4
4
|
import { TokenState } from './token';
|
|
5
5
|
export declare type DataState = {
|
|
6
6
|
isFetching?: boolean;
|
|
7
|
-
progression
|
|
7
|
+
progression: ProgressionState;
|
|
8
8
|
skills: SkillsState;
|
|
9
9
|
slides: SlidesState;
|
|
10
10
|
token?: TokenState;
|
|
@@ -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,13 +1,8 @@
|
|
|
1
|
-
import { VALIDATE_SLIDE } from '../../actions/ui/slides';
|
|
2
1
|
import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
|
|
3
2
|
const reducer = (
|
|
4
3
|
// eslint-disable-next-line default-param-last
|
|
5
4
|
state = null, action) => {
|
|
6
5
|
switch (action.type) {
|
|
7
|
-
case VALIDATE_SLIDE: {
|
|
8
|
-
// TODO: fix on VALIDATE ticket -> launch a POST PROGRESSION
|
|
9
|
-
return state;
|
|
10
|
-
}
|
|
11
6
|
case POST_PROGRESSION_SUCCESS: {
|
|
12
7
|
const progression = action.payload;
|
|
13
8
|
return progression;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReceivedSlide } from '../../actions/api/fetch-slide';
|
|
1
|
+
import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
|
|
3
2
|
import { SlideFromAPI } from '../../types/common';
|
|
4
|
-
export declare type SlidesAction =
|
|
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,9 +1,13 @@
|
|
|
1
1
|
import set from 'lodash/fp/set';
|
|
2
|
-
import { SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
|
|
2
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../../actions/api/fetch-slide';
|
|
3
3
|
export const initialState = {};
|
|
4
4
|
// eslint-disable-next-line default-param-last
|
|
5
5
|
const reducer = (state = initialState, action) => {
|
|
6
6
|
switch (action.type) {
|
|
7
|
+
case SLIDE_FETCH_REQUEST: {
|
|
8
|
+
const { meta } = action;
|
|
9
|
+
return set(meta.slideRef, null, state);
|
|
10
|
+
}
|
|
7
11
|
case SLIDE_FETCH_SUCCESS: {
|
|
8
12
|
const slide = action.payload;
|
|
9
13
|
return set(slide.id, slide, state);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../progression';
|
|
3
|
+
import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
|
|
4
|
+
test('should have initial value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.is(state, null);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
|
|
9
|
+
const progression = {
|
|
10
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
11
|
+
content: {
|
|
12
|
+
ref: '_skill-ref',
|
|
13
|
+
type: 'skill'
|
|
14
|
+
},
|
|
15
|
+
engine: {
|
|
16
|
+
ref: 'review'
|
|
17
|
+
},
|
|
18
|
+
state: {
|
|
19
|
+
allAnswers: [],
|
|
20
|
+
isCorrect: true,
|
|
21
|
+
nextContent: {
|
|
22
|
+
ref: 'sli_N1XACJobn',
|
|
23
|
+
type: 'slide'
|
|
24
|
+
},
|
|
25
|
+
pendingSlides: [],
|
|
26
|
+
slides: [],
|
|
27
|
+
step: {
|
|
28
|
+
current: 1
|
|
29
|
+
},
|
|
30
|
+
stars: 0
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const state = reducer(null, {
|
|
34
|
+
type: POST_PROGRESSION_SUCCESS,
|
|
35
|
+
payload: progression
|
|
36
|
+
});
|
|
37
|
+
t.deepEqual(state, progression);
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../skills';
|
|
3
|
+
import { SKILLS_FETCH_SUCCESS } from '../../../actions/api/fetch-skills';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of SKILLS_FETCH_SUCCESS action', t => {
|
|
9
|
+
const skills = [{ skillRef: 'skill', name: 'skill name', slidesToReview: 5, custom: false }];
|
|
10
|
+
const state = reducer([], { type: SKILLS_FETCH_SUCCESS, payload: skills });
|
|
11
|
+
t.deepEqual(state, skills);
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../slides';
|
|
3
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../../../actions/api/fetch-slide';
|
|
4
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
+
test('should have inital value', t => {
|
|
6
|
+
const state = reducer(undefined, {});
|
|
7
|
+
t.deepEqual(state, {});
|
|
8
|
+
});
|
|
9
|
+
test('should set the value of SLIDE_FETCH_REQUEST action', t => {
|
|
10
|
+
const state = reducer({}, { type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'slideRef' } });
|
|
11
|
+
t.deepEqual(state, {
|
|
12
|
+
slideRef: null
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
test('should set the value of SLIDE_FETCH_SUCCESS action', t => {
|
|
16
|
+
const state = reducer({}, { type: SLIDE_FETCH_SUCCESS, payload: freeTextSlide, meta: { slideRef: 'sli_VJYjJnJhg' } });
|
|
17
|
+
t.deepEqual(state, {
|
|
18
|
+
sli_VJYjJnJhg: freeTextSlide
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../token';
|
|
3
|
+
import { STORE_TOKEN } from '../../../actions/data/token';
|
|
4
|
+
test('should have inital value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.is(state, null);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of STORE_TOKEN action', t => {
|
|
9
|
+
const state = reducer(null, { type: STORE_TOKEN, payload: 'token' });
|
|
10
|
+
t.is(state, 'token');
|
|
11
|
+
});
|
package/es/reducers/index.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
|
|
|
14
14
|
ui: 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;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { includes, values } from 'lodash/fp';
|
|
2
|
+
import { ANSWER_EDIT } from '../../actions/ui/answers';
|
|
3
|
+
const ANSWER_EDIT_ACTIONS = values(ANSWER_EDIT);
|
|
4
|
+
const reducer = (
|
|
5
|
+
// eslint-disable-next-line default-param-last
|
|
6
|
+
state = [], action) => {
|
|
7
|
+
return includes(action.type, ANSWER_EDIT_ACTIONS) ? action.payload : state;
|
|
8
|
+
};
|
|
9
|
+
export default reducer;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { CurrentSlideRefState } from './current-slide-ref';
|
|
2
2
|
import { NavigationState } from './navigation';
|
|
3
|
-
import {
|
|
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
|
-
|
|
13
|
-
|
|
14
|
+
answers: AnswerState;
|
|
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/es/reducers/ui/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { combineReducers } from 'redux';
|
|
2
2
|
import currentSlideRef from './current-slide-ref';
|
|
3
3
|
import navigation from './navigation';
|
|
4
|
-
import
|
|
4
|
+
import answers from './answers';
|
|
5
|
+
import slide from './slide';
|
|
5
6
|
export default combineReducers({
|
|
6
7
|
currentSlideRef,
|
|
7
8
|
navigation,
|
|
8
|
-
|
|
9
|
+
answers,
|
|
10
|
+
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,26 @@
|
|
|
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 const initialState = { validateButton: false };
|
|
7
|
+
const reducer = (
|
|
8
|
+
// eslint-disable-next-line default-param-last
|
|
9
|
+
state = initialState, action) => {
|
|
10
|
+
switch (action.type) {
|
|
11
|
+
case EDIT_QCM:
|
|
12
|
+
case EDIT_QCM_GRAPHIC:
|
|
13
|
+
case EDIT_QCM_DRAG:
|
|
14
|
+
case EDIT_TEMPLATE:
|
|
15
|
+
case EDIT_BASIC:
|
|
16
|
+
case EDIT_SLIDER: {
|
|
17
|
+
return pipe(compact, isEmpty)(action.payload) ? initialState : { validateButton: true };
|
|
18
|
+
}
|
|
19
|
+
case POST_ANSWER_REQUEST: {
|
|
20
|
+
return initialState;
|
|
21
|
+
}
|
|
22
|
+
default:
|
|
23
|
+
return state;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export default reducer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../answers';
|
|
3
|
+
import { ANSWER_EDIT } from '../../../actions/ui/answers';
|
|
4
|
+
test('should have initial value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of EDIT_BASIC action', t => {
|
|
9
|
+
const state = reducer([], { type: ANSWER_EDIT.basic, payload: ['value'] });
|
|
10
|
+
t.deepEqual(state, ['value']);
|
|
11
|
+
});
|
|
12
|
+
test('should set the value of EDIT_QCM action', t => {
|
|
13
|
+
const 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', t => {
|
|
17
|
+
const 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', t => {
|
|
21
|
+
const 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', t => {
|
|
25
|
+
const state = reducer([], { type: ANSWER_EDIT.slider, payload: ['5'] });
|
|
26
|
+
t.deepEqual(state, ['5']);
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../current-slide-ref';
|
|
3
|
+
import { SET_CURRENT_SLIDE } from '../../../actions/ui/slides';
|
|
4
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
5
|
+
test('should have initial value', t => {
|
|
6
|
+
const state = reducer(undefined, {});
|
|
7
|
+
t.is(state, '');
|
|
8
|
+
});
|
|
9
|
+
test('should set the value of SET_CURRENT_SLIDE action', t => {
|
|
10
|
+
const state = reducer('', { type: SET_CURRENT_SLIDE, payload: freeTextSlide });
|
|
11
|
+
t.is(state, 'sli_VJYjJnJhg');
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer from '../navigation';
|
|
3
|
+
import { navigateBack, navigateTo } from '../../../actions/ui/navigation';
|
|
4
|
+
test('should have initial value', t => {
|
|
5
|
+
const state = reducer(undefined, {});
|
|
6
|
+
t.deepEqual(state, []);
|
|
7
|
+
});
|
|
8
|
+
test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
|
|
9
|
+
const state = reducer([], navigateTo('loader'));
|
|
10
|
+
t.deepEqual(state, ['loader']);
|
|
11
|
+
const updatedState = reducer(state, navigateTo('skills'));
|
|
12
|
+
t.deepEqual(updatedState, ['loader', 'skills']);
|
|
13
|
+
const _updatedState = reducer(updatedState, navigateBack());
|
|
14
|
+
t.deepEqual(_updatedState, ['loader']);
|
|
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', t => {
|
|
5
|
+
const 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', t => {
|
|
10
|
+
const state = reducer(undefined, { type: 'NOPE' });
|
|
11
|
+
t.deepEqual(state, initialState);
|
|
12
|
+
});
|
|
@@ -3,7 +3,7 @@ import decode from 'jwt-decode';
|
|
|
3
3
|
import { toJSON } from './tools/fetch-responses';
|
|
4
4
|
export const fetchSlide = async (slideRef, token) => {
|
|
5
5
|
const { host } = decode(token);
|
|
6
|
-
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}`, {
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/slide/${slideRef}/parentContentTitle`, {
|
|
7
7
|
headers: { authorization: token }
|
|
8
8
|
});
|
|
9
9
|
const slide = (await toJSON(response));
|
package/es/services/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { fetchSkills } from './fetch-skills';
|
|
2
2
|
import { postProgression } from './post-progression';
|
|
3
3
|
import { fetchSlide } from './fetch-slide';
|
|
4
|
+
import { postAnswer } from './post-answer';
|
|
4
5
|
export const getServices = () => ({
|
|
5
6
|
fetchSkills,
|
|
6
7
|
fetchSlide,
|
|
7
|
-
postProgression
|
|
8
|
+
postProgression,
|
|
9
|
+
postAnswer
|
|
8
10
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import crossFetch from 'cross-fetch';
|
|
2
|
+
import decode from 'jwt-decode';
|
|
3
|
+
import { toJSON } from './tools/fetch-responses';
|
|
4
|
+
export const postAnswer = async (skillRef, token, progressionId, answer) => {
|
|
5
|
+
const { host } = decode(token);
|
|
6
|
+
const response = await crossFetch(`${host}/api/v2/progressions/${progressionId}/answers`, {
|
|
7
|
+
method: 'post',
|
|
8
|
+
headers: { authorization: token },
|
|
9
|
+
body: JSON.stringify({
|
|
10
|
+
content: {
|
|
11
|
+
ref: skillRef,
|
|
12
|
+
type: 'slide'
|
|
13
|
+
},
|
|
14
|
+
answer
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
return toJSON(response);
|
|
18
|
+
};
|