@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
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import type {Services} from '../../../types/common';
|
|
3
|
+
import {
|
|
4
|
+
fetchSlide,
|
|
5
|
+
SLIDE_FETCH_FAILURE,
|
|
6
|
+
SLIDE_FETCH_REQUEST,
|
|
7
|
+
SLIDE_FETCH_SUCCESS
|
|
8
|
+
} from '../fetch-slide';
|
|
9
|
+
import {freeTextSlide} from '../../../views/slides/test/fixtures/free-text';
|
|
10
|
+
import {services as mockedServices} from '../../../test/util/services.mock';
|
|
11
|
+
import type {StoreState} from '../../../reducers';
|
|
12
|
+
import {SET_CURRENT_SLIDE} from '../../ui/slides';
|
|
13
|
+
import {createTestStore} from '../../test/create-test-store';
|
|
14
|
+
|
|
15
|
+
const initialState: StoreState = {
|
|
16
|
+
data: {
|
|
17
|
+
progression: null,
|
|
18
|
+
slides: {},
|
|
19
|
+
skills: [],
|
|
20
|
+
token: '1234'
|
|
21
|
+
},
|
|
22
|
+
ui: {
|
|
23
|
+
currentSlideRef: '',
|
|
24
|
+
navigation: [],
|
|
25
|
+
answers: [],
|
|
26
|
+
slide: {
|
|
27
|
+
validateButton: false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
test('should dispatch FETCH_SUCCESS and SET_CURRENT_SLIDE actions when fetchSlide return a slide', async t => {
|
|
33
|
+
const services: Services = {
|
|
34
|
+
...mockedServices,
|
|
35
|
+
fetchSlide: (slideRef, token) => {
|
|
36
|
+
t.is(token, '1234');
|
|
37
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
38
|
+
return Promise.resolve(freeTextSlide);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const expectedActions = [
|
|
43
|
+
{type: SLIDE_FETCH_REQUEST, meta: {slideRef: 'sli_VJYjJnJhg'}},
|
|
44
|
+
{
|
|
45
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
46
|
+
meta: {slideRef: 'sli_VJYjJnJhg'},
|
|
47
|
+
payload: freeTextSlide
|
|
48
|
+
},
|
|
49
|
+
{type: SET_CURRENT_SLIDE, payload: freeTextSlide}
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
53
|
+
|
|
54
|
+
await dispatch(fetchSlide('sli_VJYjJnJhg'));
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('should dispatch SLIDE_FETCH_FAILURE action when fetchSlide fails', async t => {
|
|
58
|
+
const services: Services = {
|
|
59
|
+
...mockedServices,
|
|
60
|
+
fetchSlide: (slideRef, token) => {
|
|
61
|
+
t.is(token, '1234');
|
|
62
|
+
t.is(slideRef, 'slide_ref');
|
|
63
|
+
return Promise.reject(new Error('error'));
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const expectedActions = [
|
|
68
|
+
{type: SLIDE_FETCH_REQUEST, meta: {slideRef: 'slide_ref'}},
|
|
69
|
+
{
|
|
70
|
+
type: SLIDE_FETCH_FAILURE,
|
|
71
|
+
meta: {slideRef: 'slide_ref'},
|
|
72
|
+
payload: new Error('error'),
|
|
73
|
+
error: true
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
78
|
+
|
|
79
|
+
await dispatch(fetchSlide('slide_ref'));
|
|
80
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import {createTestStore} from '../../test/create-test-store';
|
|
3
|
+
import {postAnswerResponse, services} from '../../../test/util/services.mock';
|
|
4
|
+
import {
|
|
5
|
+
postAnswer,
|
|
6
|
+
POST_ANSWER_FAILURE,
|
|
7
|
+
POST_ANSWER_REQUEST,
|
|
8
|
+
POST_ANSWER_SUCCESS
|
|
9
|
+
} from '../post-answer';
|
|
10
|
+
import type {StoreState} from '../../../reducers';
|
|
11
|
+
import {SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS} from '../fetch-slide';
|
|
12
|
+
import {qcmGraphicSlide} from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
13
|
+
import {freeTextSlide} from '../../../views/slides/test/fixtures/free-text';
|
|
14
|
+
import {SET_CURRENT_SLIDE} from '../../ui/slides';
|
|
15
|
+
|
|
16
|
+
const progressionId = '123456789123';
|
|
17
|
+
const skillRef = '_skill-ref';
|
|
18
|
+
const answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
19
|
+
|
|
20
|
+
const initialState: StoreState = {
|
|
21
|
+
data: {
|
|
22
|
+
progression: {
|
|
23
|
+
_id: progressionId,
|
|
24
|
+
content: {type: 'skill', ref: skillRef},
|
|
25
|
+
engine: {
|
|
26
|
+
ref: 'review'
|
|
27
|
+
},
|
|
28
|
+
state: {
|
|
29
|
+
allAnswers: [],
|
|
30
|
+
isCorrect: true,
|
|
31
|
+
nextContent: {
|
|
32
|
+
ref: 'sli_VJYjJnJhg',
|
|
33
|
+
type: 'slide'
|
|
34
|
+
},
|
|
35
|
+
pendingSlides: [],
|
|
36
|
+
slides: [],
|
|
37
|
+
step: {
|
|
38
|
+
current: 1
|
|
39
|
+
},
|
|
40
|
+
stars: 0
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
slides: {
|
|
44
|
+
[freeTextSlide.id]: freeTextSlide
|
|
45
|
+
},
|
|
46
|
+
skills: [{skillRef, custom: false, name: skillRef, slidesToReview: 5}],
|
|
47
|
+
token: '1234'
|
|
48
|
+
},
|
|
49
|
+
ui: {
|
|
50
|
+
currentSlideRef: 'sli_VJYjJnJhg',
|
|
51
|
+
navigation: ['skills', 'slides'],
|
|
52
|
+
answers: answer,
|
|
53
|
+
slide: {
|
|
54
|
+
validateButton: false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
test('should dispatch POST_ANSWER_REQUEST, then POST_ANSWER_SUCCESS when the updated progression is returned', async t => {
|
|
60
|
+
const expectedActions = [
|
|
61
|
+
{type: POST_ANSWER_REQUEST},
|
|
62
|
+
{
|
|
63
|
+
type: POST_ANSWER_SUCCESS,
|
|
64
|
+
payload: postAnswerResponse
|
|
65
|
+
},
|
|
66
|
+
{type: SLIDE_FETCH_REQUEST, meta: {slideRef: 'sli_VkSQroQnx'}},
|
|
67
|
+
{
|
|
68
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
69
|
+
meta: {slideRef: 'sli_VkSQroQnx'},
|
|
70
|
+
payload: qcmGraphicSlide
|
|
71
|
+
},
|
|
72
|
+
{type: SET_CURRENT_SLIDE, payload: qcmGraphicSlide}
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
76
|
+
|
|
77
|
+
await dispatch(postAnswer);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('should dispatch POST_ANSWER_REQUEST, then POST_ANSWER_FAILURE on error', async t => {
|
|
81
|
+
const expectedActions = [
|
|
82
|
+
{type: POST_ANSWER_REQUEST},
|
|
83
|
+
{
|
|
84
|
+
type: POST_ANSWER_FAILURE,
|
|
85
|
+
payload: new Error('unexpected'),
|
|
86
|
+
error: true
|
|
87
|
+
}
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
const {dispatch} = createTestStore(
|
|
91
|
+
t,
|
|
92
|
+
initialState,
|
|
93
|
+
{
|
|
94
|
+
...services,
|
|
95
|
+
postAnswer: () => Promise.reject(new Error('unexpected'))
|
|
96
|
+
},
|
|
97
|
+
expectedActions
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
await dispatch(postAnswer);
|
|
101
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import type {ProgressionFromAPI, Services} from '../../../types/common';
|
|
3
|
+
import {
|
|
4
|
+
postProgression,
|
|
5
|
+
POST_PROGRESSION_REQUEST,
|
|
6
|
+
POST_PROGRESSION_SUCCESS,
|
|
7
|
+
POST_PROGRESSION_FAILURE
|
|
8
|
+
} from '../post-progression';
|
|
9
|
+
import {freeTextSlide} from '../../../views/slides/test/fixtures/free-text';
|
|
10
|
+
import {services as mockedServices} from '../../../test/util/services.mock';
|
|
11
|
+
import type {StoreState} from '../../../reducers';
|
|
12
|
+
import {SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS} from '../fetch-slide';
|
|
13
|
+
import {SET_CURRENT_SLIDE} from '../../ui/slides';
|
|
14
|
+
import {createTestStore} from '../../test/create-test-store';
|
|
15
|
+
|
|
16
|
+
const initialState: StoreState = {
|
|
17
|
+
data: {
|
|
18
|
+
progression: null,
|
|
19
|
+
slides: {},
|
|
20
|
+
skills: [],
|
|
21
|
+
token: '1234'
|
|
22
|
+
},
|
|
23
|
+
ui: {
|
|
24
|
+
currentSlideRef: '',
|
|
25
|
+
navigation: [],
|
|
26
|
+
answers: [],
|
|
27
|
+
slide: {
|
|
28
|
+
validateButton: false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
test('should dispatch POST_PROGRESSION_SUCCESS and SLIDE_FETCH_REQUEST actions when postProgression return a progression', async t => {
|
|
34
|
+
const progression: ProgressionFromAPI = {
|
|
35
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
36
|
+
content: {
|
|
37
|
+
ref: '_skill-ref',
|
|
38
|
+
type: 'skill'
|
|
39
|
+
},
|
|
40
|
+
engine: {
|
|
41
|
+
ref: 'review'
|
|
42
|
+
},
|
|
43
|
+
state: {
|
|
44
|
+
allAnswers: [],
|
|
45
|
+
isCorrect: true,
|
|
46
|
+
nextContent: {
|
|
47
|
+
ref: 'sli_VJYjJnJhg',
|
|
48
|
+
type: 'slide'
|
|
49
|
+
},
|
|
50
|
+
pendingSlides: [],
|
|
51
|
+
slides: [],
|
|
52
|
+
step: {
|
|
53
|
+
current: 1
|
|
54
|
+
},
|
|
55
|
+
stars: 0
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const services: Services = {
|
|
60
|
+
...mockedServices,
|
|
61
|
+
postProgression: (skillRef, token) => {
|
|
62
|
+
t.is(token, '1234');
|
|
63
|
+
t.is(skillRef, 'skill_12345');
|
|
64
|
+
return Promise.resolve(progression);
|
|
65
|
+
},
|
|
66
|
+
fetchSlide: (slideRef, token) => {
|
|
67
|
+
t.is(token, '1234');
|
|
68
|
+
t.is(slideRef, 'sli_VJYjJnJhg');
|
|
69
|
+
return Promise.resolve(freeTextSlide);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const expectedActions = [
|
|
74
|
+
{type: POST_PROGRESSION_REQUEST},
|
|
75
|
+
{
|
|
76
|
+
type: POST_PROGRESSION_SUCCESS,
|
|
77
|
+
payload: progression
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: SLIDE_FETCH_REQUEST,
|
|
81
|
+
meta: {
|
|
82
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
87
|
+
meta: {
|
|
88
|
+
slideRef: 'sli_VJYjJnJhg'
|
|
89
|
+
},
|
|
90
|
+
payload: freeTextSlide
|
|
91
|
+
},
|
|
92
|
+
{type: SET_CURRENT_SLIDE, payload: freeTextSlide}
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
96
|
+
|
|
97
|
+
await dispatch(postProgression('skill_12345'));
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('should dispatch POST_PROGRESSION_FAILURE action when postProgression fails', async t => {
|
|
101
|
+
const services: Services = {
|
|
102
|
+
...mockedServices,
|
|
103
|
+
postProgression: (skillRef, token) => {
|
|
104
|
+
t.is(token, '1234');
|
|
105
|
+
t.is(skillRef, 'skill_12345');
|
|
106
|
+
return Promise.reject(new Error('error'));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const expectedActions = [
|
|
111
|
+
{type: POST_PROGRESSION_REQUEST},
|
|
112
|
+
{
|
|
113
|
+
type: POST_PROGRESSION_FAILURE,
|
|
114
|
+
payload: new Error('error'),
|
|
115
|
+
error: true
|
|
116
|
+
}
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
120
|
+
|
|
121
|
+
await dispatch(postProgression('skill_12345'));
|
|
122
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import {createTestStore} from '../../test/create-test-store';
|
|
3
|
+
import {services} from '../../../test/util/services.mock';
|
|
4
|
+
import {StoreState} from '../../../reducers';
|
|
5
|
+
import {storeToken, STORE_TOKEN} from '../token';
|
|
6
|
+
|
|
7
|
+
const initialState: StoreState = {
|
|
8
|
+
data: {
|
|
9
|
+
progression: null,
|
|
10
|
+
slides: {},
|
|
11
|
+
skills: [],
|
|
12
|
+
token: '1234'
|
|
13
|
+
},
|
|
14
|
+
ui: {
|
|
15
|
+
currentSlideRef: '',
|
|
16
|
+
navigation: [],
|
|
17
|
+
answers: [],
|
|
18
|
+
slide: {
|
|
19
|
+
validateButton: false
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
test('should dispatch STORE_TOKEN action when storeToken is called', async t => {
|
|
25
|
+
const expectedActions = [{type: STORE_TOKEN, payload: 'JWT.token'}];
|
|
26
|
+
|
|
27
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
28
|
+
await dispatch(storeToken('JWT.token'));
|
|
29
|
+
});
|
package/src/actions/index.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp} from './ui/navigation';
|
|
4
|
-
import {ReceivedSlide} from './api/fetch-slide';
|
|
5
|
-
import {ReceiveProgression} from './api/post-progression';
|
|
6
|
-
import {ReceivedSkills} from './api/fetch-skills';
|
|
7
|
-
import {validateSlide} from './ui/slides';
|
|
8
|
-
|
|
9
|
-
export type Action =
|
|
10
|
-
| NavigateBack
|
|
11
|
-
| NavigateTo
|
|
12
|
-
| ReceivedSkills
|
|
13
|
-
| StartApp
|
|
14
|
-
| ReceivedSlide
|
|
15
|
-
| StoreToken
|
|
16
|
-
| ReceiveProgression;
|
|
1
|
+
import {navigateBack, navigateTo} from './ui/navigation';
|
|
17
2
|
|
|
18
3
|
export type Dispatchers = {
|
|
19
4
|
navigateTo: typeof navigateTo;
|
|
20
5
|
navigateBack: typeof navigateBack;
|
|
21
|
-
validateSlide: typeof validateSlide;
|
|
22
6
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type {ExecutionContext} from 'ava';
|
|
2
|
+
import constant from 'lodash/fp/constant';
|
|
3
|
+
import {AnyAction, applyMiddleware, compose, createStore, Dispatch, Middleware, Store} from 'redux';
|
|
4
|
+
import thunk from 'redux-thunk';
|
|
5
|
+
import rootReducer, {StoreState} from '../../reducers';
|
|
6
|
+
import {Services} from '../../types/common';
|
|
7
|
+
|
|
8
|
+
const assertActionsMiddleware = (t: ExecutionContext, ACTIONS: AnyAction[]): Middleware =>
|
|
9
|
+
constant((next: Dispatch) => (action: AnyAction): unknown => {
|
|
10
|
+
const expectedAction = ACTIONS.shift();
|
|
11
|
+
if (!expectedAction) throw new Error(`Missing {type: "${action.type}"} action`);
|
|
12
|
+
t.deepEqual(action, expectedAction);
|
|
13
|
+
return next(action);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const createTestStore = (
|
|
17
|
+
t: ExecutionContext,
|
|
18
|
+
initialState: StoreState,
|
|
19
|
+
services: Services,
|
|
20
|
+
actions: AnyAction[]
|
|
21
|
+
): Store => {
|
|
22
|
+
const thunkMiddleware = thunk.withExtraArgument({services});
|
|
23
|
+
const enhancer = compose(applyMiddleware(thunkMiddleware, assertActionsMiddleware(t, actions)));
|
|
24
|
+
return createStore(rootReducer, initialState, enhancer);
|
|
25
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {Dispatch} from 'redux';
|
|
2
|
+
import {flatten, get, includes, pull} from 'lodash/fp';
|
|
3
|
+
import type {StoreState} from '../../reducers';
|
|
4
|
+
|
|
5
|
+
export const EDIT_QCM = '@@answer/EDIT_QCM' as const;
|
|
6
|
+
export const EDIT_QCM_GRAPHIC = '@@answer/EDIT_QCM_GRAPHIC' as const;
|
|
7
|
+
export const EDIT_QCM_DRAG = '@@answer/EDIT_QCM_DRAG' as const;
|
|
8
|
+
export const EDIT_TEMPLATE = '@@answer/EDIT_TEMPLATE' as const;
|
|
9
|
+
export const EDIT_BASIC = '@@answer/EDIT_BASIC' as const;
|
|
10
|
+
export const EDIT_SLIDER = '@@answer/EDIT_SLIDER' as const;
|
|
11
|
+
|
|
12
|
+
export const ANSWER_EDIT = {
|
|
13
|
+
qcm: EDIT_QCM,
|
|
14
|
+
qcmGraphic: EDIT_QCM_GRAPHIC,
|
|
15
|
+
qcmDrag: EDIT_QCM_DRAG,
|
|
16
|
+
template: EDIT_TEMPLATE,
|
|
17
|
+
basic: EDIT_BASIC,
|
|
18
|
+
slider: EDIT_SLIDER
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
export type EditAnswerAction = {
|
|
22
|
+
type:
|
|
23
|
+
| typeof EDIT_QCM
|
|
24
|
+
| typeof EDIT_QCM_GRAPHIC
|
|
25
|
+
| typeof EDIT_QCM_DRAG
|
|
26
|
+
| typeof EDIT_TEMPLATE
|
|
27
|
+
| typeof EDIT_BASIC
|
|
28
|
+
| typeof EDIT_SLIDER;
|
|
29
|
+
payload: string[];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const buildAnswer = (userAnswers: string[], questionType: string, newValue: string): string[] => {
|
|
33
|
+
switch (questionType) {
|
|
34
|
+
case 'qcm':
|
|
35
|
+
case 'qcmGraphic':
|
|
36
|
+
case 'qcmDrag': {
|
|
37
|
+
return includes(newValue, userAnswers)
|
|
38
|
+
? pull(newValue, userAnswers)
|
|
39
|
+
: flatten([...userAnswers, newValue]);
|
|
40
|
+
}
|
|
41
|
+
case 'basic':
|
|
42
|
+
case 'slider':
|
|
43
|
+
return [newValue];
|
|
44
|
+
default:
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const editAnswer =
|
|
50
|
+
(answer: string) =>
|
|
51
|
+
(dispatch: Dispatch, getState: () => StoreState): EditAnswerAction => {
|
|
52
|
+
const state = getState();
|
|
53
|
+
const currentSlideRef = get(['ui', 'currentSlideRef'])(state);
|
|
54
|
+
const userAnswers = get(['ui', 'answers'])(state);
|
|
55
|
+
const slide = get(['data', 'slides', currentSlideRef])(state);
|
|
56
|
+
const questionType = get(['question', 'type'])(slide);
|
|
57
|
+
const type = get(questionType, ANSWER_EDIT);
|
|
58
|
+
|
|
59
|
+
return dispatch({
|
|
60
|
+
type,
|
|
61
|
+
payload: buildAnswer(userAnswers, questionType, answer)
|
|
62
|
+
});
|
|
63
|
+
};
|
package/src/actions/ui/slides.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type Slide = {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export const SET_CURRENT_SLIDE = '@@slide/SET_CURRENT_SLIDE' as const;
|
|
18
|
+
|
|
18
19
|
export type SetCurrentSlide = {
|
|
19
20
|
type: typeof SET_CURRENT_SLIDE;
|
|
20
21
|
payload: SlideFromAPI;
|
|
@@ -24,12 +25,4 @@ export const setCurrentSlide = (payload: SlideFromAPI): SetCurrentSlide => ({
|
|
|
24
25
|
payload
|
|
25
26
|
});
|
|
26
27
|
|
|
27
|
-
export const VALIDATE_SLIDE = '@@slide/VALIDATE';
|
|
28
|
-
export type ValidateSlide = {
|
|
29
|
-
type: typeof VALIDATE_SLIDE;
|
|
30
|
-
};
|
|
31
|
-
export const validateSlide = (): ValidateSlide => ({
|
|
32
|
-
type: VALIDATE_SLIDE
|
|
33
|
-
});
|
|
34
|
-
|
|
35
28
|
export type UISlidesAction = SetCurrentSlide;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import pipe from 'lodash/fp/pipe';
|
|
3
|
+
import set from 'lodash/fp/set';
|
|
4
|
+
import {SlideFromAPI} from '../../../types/common';
|
|
5
|
+
import {createTestStore} from '../../test/create-test-store';
|
|
6
|
+
import {services} from '../../../test/util/services.mock';
|
|
7
|
+
import {freeTextSlide} from '../../../views/slides/test/fixtures/free-text';
|
|
8
|
+
import {qcmDragSlide} from '../../../views/slides/test/fixtures/qcm-drag';
|
|
9
|
+
import {qcmSlide} from '../../../views/slides/test/fixtures/qcm';
|
|
10
|
+
import {qcmGraphicSlide} from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
11
|
+
import {sliderSlide} from '../../../views/slides/test/fixtures/slider';
|
|
12
|
+
import {StoreState} from '../../../reducers';
|
|
13
|
+
import {editAnswer, ANSWER_EDIT} from '../answers';
|
|
14
|
+
|
|
15
|
+
const initialState: StoreState = {
|
|
16
|
+
data: {
|
|
17
|
+
progression: {
|
|
18
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
19
|
+
content: {
|
|
20
|
+
ref: '_skill-ref',
|
|
21
|
+
type: 'skill'
|
|
22
|
+
},
|
|
23
|
+
engine: {
|
|
24
|
+
ref: 'review'
|
|
25
|
+
},
|
|
26
|
+
state: {
|
|
27
|
+
allAnswers: [],
|
|
28
|
+
isCorrect: true,
|
|
29
|
+
nextContent: {
|
|
30
|
+
ref: '',
|
|
31
|
+
type: 'slide'
|
|
32
|
+
},
|
|
33
|
+
pendingSlides: [],
|
|
34
|
+
slides: [],
|
|
35
|
+
step: {
|
|
36
|
+
current: 1
|
|
37
|
+
},
|
|
38
|
+
stars: 0
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
slides: {},
|
|
42
|
+
skills: [],
|
|
43
|
+
token: '1234'
|
|
44
|
+
},
|
|
45
|
+
ui: {
|
|
46
|
+
currentSlideRef: '',
|
|
47
|
+
navigation: [],
|
|
48
|
+
answers: [],
|
|
49
|
+
slide: {
|
|
50
|
+
validateButton: false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const buildInitialState = (state: StoreState, question: SlideFromAPI): StoreState => {
|
|
56
|
+
return pipe(
|
|
57
|
+
set(['data', 'progression', 'state', 'nextContent', 'ref'], question.id),
|
|
58
|
+
set(['data', 'slides', question.id], question),
|
|
59
|
+
set(['ui', 'currentSlideRef'], question.id)
|
|
60
|
+
)(state);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
test('should dispatch EDIT_BASIC action when editAnswer is called', async t => {
|
|
64
|
+
const state = buildInitialState(initialState, freeTextSlide);
|
|
65
|
+
const expectedActions = [{type: ANSWER_EDIT.basic, payload: ['My Answer']}];
|
|
66
|
+
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
67
|
+
await dispatch(editAnswer('My Answer'));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('should dispatch EDIT_QCM action when editAnswer is called', async t => {
|
|
71
|
+
let state = buildInitialState(initialState, qcmSlide);
|
|
72
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
73
|
+
const expectedActions = [{type: ANSWER_EDIT.qcm, payload: ['My First Answer']}];
|
|
74
|
+
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
75
|
+
await dispatch(editAnswer('My Second Answer'));
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', async t => {
|
|
79
|
+
let state = buildInitialState(initialState, qcmGraphicSlide);
|
|
80
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer', 'My Third Answer'], state);
|
|
81
|
+
const expectedActions = [
|
|
82
|
+
{type: ANSWER_EDIT.qcmGraphic, payload: ['My First Answer', 'My Third Answer']}
|
|
83
|
+
];
|
|
84
|
+
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
85
|
+
await dispatch(editAnswer('My Second Answer'));
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', async t => {
|
|
89
|
+
let state = buildInitialState(initialState, qcmDragSlide);
|
|
90
|
+
state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
|
|
91
|
+
const expectedActions = [
|
|
92
|
+
{type: ANSWER_EDIT.qcmDrag, payload: ['My First Answer', 'My Second Answer', 'My Third Answer']}
|
|
93
|
+
];
|
|
94
|
+
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
95
|
+
await dispatch(editAnswer('My Third Answer'));
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('should dispatch EDIT_SLIDER action when editAnswer is called', async t => {
|
|
99
|
+
const state = buildInitialState(initialState, sliderSlide);
|
|
100
|
+
const expectedActions = [{type: ANSWER_EDIT.slider, payload: ['5']}];
|
|
101
|
+
const {dispatch} = createTestStore(t, state, services, expectedActions);
|
|
102
|
+
await dispatch(editAnswer('5'));
|
|
103
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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 {StoreState} from '../../../reducers';
|
|
6
|
+
import {setCurrentSlide, SET_CURRENT_SLIDE} from '../slides';
|
|
7
|
+
|
|
8
|
+
const initialState: StoreState = {
|
|
9
|
+
data: {
|
|
10
|
+
progression: null,
|
|
11
|
+
slides: {},
|
|
12
|
+
skills: [],
|
|
13
|
+
token: '1234'
|
|
14
|
+
},
|
|
15
|
+
ui: {
|
|
16
|
+
currentSlideRef: '',
|
|
17
|
+
navigation: [],
|
|
18
|
+
answers: [],
|
|
19
|
+
slide: {
|
|
20
|
+
validateButton: false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
test('should dispatch SET_CURRENT_SLIDE action when setCurrentSlide is called', async t => {
|
|
26
|
+
const expectedActions = [{type: SET_CURRENT_SLIDE, payload: freeTextSlide}];
|
|
27
|
+
|
|
28
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
29
|
+
await dispatch(setCurrentSlide(freeTextSlide));
|
|
30
|
+
});
|
package/src/common/index.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import _toString from 'lodash/fp/toString';
|
|
2
|
-
|
|
3
|
-
export const TOTAL_SLIDES_STACK = 5;
|
|
4
|
-
export const HIGHEST_INDEX = TOTAL_SLIDES_STACK - 1;
|
|
5
|
-
|
|
6
1
|
export const VIEWS: {
|
|
7
2
|
readonly skills: 'skills';
|
|
8
3
|
readonly onboarding: 'onboarding';
|
|
@@ -16,5 +11,3 @@ export const VIEWS: {
|
|
|
16
11
|
export const slideIndexes = ['0', '1', '2', '3', '4'] as const;
|
|
17
12
|
|
|
18
13
|
export type SlideIndexes = typeof slideIndexes[number];
|
|
19
|
-
|
|
20
|
-
export const indexToString = (index: number): SlideIndexes => _toString(index) as SlideIndexes;
|