@coorpacademy/app-review 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/api/fetch-skills.d.ts +3 -3
- package/es/actions/api/fetch-skills.js +7 -2
- package/es/actions/api/fetch-slide.d.ts +1 -1
- package/es/actions/api/fetch-slide.js +3 -1
- package/es/actions/api/post-answer.d.ts +10 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +3 -3
- package/es/actions/api/post-progression.js +5 -2
- package/es/actions/api/test/fetch-skills.test.js +7 -4
- package/es/actions/api/test/fetch-slide.test.js +7 -4
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.js +7 -4
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/es/actions/{api/test → test}/create-test-store.js +1 -1
- package/es/actions/ui/answers.d.ts +17 -3
- package/es/actions/ui/answers.js +39 -3
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +90 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +1 -3
- package/es/reducers/data/index.d.ts +1 -1
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +1 -1
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/answers.d.ts +2 -2
- package/es/reducers/ui/answers.js +4 -8
- package/es/reducers/ui/index.d.ts +4 -1
- package/es/reducers/ui/index.js +3 -1
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.js +19 -3
- package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/es/reducers/ui/test/navigation.test.js +5 -5
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/test/util/services.mock.d.ts +2 -1
- package/es/test/util/services.mock.js +86 -72
- package/es/types/common.d.ts +0 -25
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +13 -2
- package/es/views/slides/index.js +18 -14
- package/es/views/slides/map-api-slide-to-ui.js +44 -51
- package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/es/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -0
- package/lib/actions/api/fetch-skills.d.ts +3 -3
- package/lib/actions/api/fetch-skills.js +22 -19
- package/lib/actions/api/fetch-slide.d.ts +1 -1
- package/lib/actions/api/fetch-slide.js +3 -1
- package/lib/actions/api/post-answer.d.ts +10 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +3 -3
- package/lib/actions/api/post-progression.js +6 -3
- package/lib/actions/api/test/fetch-skills.test.js +7 -4
- package/lib/actions/api/test/fetch-slide.test.js +7 -4
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.js +7 -4
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
- package/lib/actions/{api/test → test}/create-test-store.js +1 -1
- package/lib/actions/ui/answers.d.ts +17 -3
- package/lib/actions/ui/answers.js +48 -3
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +171 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +1 -3
- package/lib/reducers/data/index.d.ts +1 -1
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +1 -1
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/answers.d.ts +2 -2
- package/lib/reducers/ui/answers.js +4 -8
- package/lib/reducers/ui/index.d.ts +4 -1
- package/lib/reducers/ui/index.js +3 -1
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.js +19 -3
- package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
- package/lib/reducers/ui/test/navigation.test.js +5 -5
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/test/util/services.mock.d.ts +2 -1
- package/lib/test/util/services.mock.js +86 -72
- package/lib/types/common.d.ts +0 -25
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +13 -2
- package/lib/views/slides/index.js +18 -14
- package/lib/views/slides/map-api-slide-to-ui.js +77 -76
- package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
- package/lib/views/slides/test/fixtures/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/text-template.d.ts +2 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -0
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +18 -11
- package/src/actions/api/fetch-slide.ts +3 -1
- package/src/actions/api/post-answer.ts +39 -0
- package/src/actions/api/post-progression.ts +7 -4
- package/src/actions/api/test/fetch-skills.test.ts +9 -6
- package/src/actions/api/test/fetch-slide.test.ts +9 -6
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +9 -6
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/{api/test → test}/create-test-store.ts +2 -2
- package/src/actions/ui/answers.ts +52 -5
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +103 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +1 -3
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +3 -3
- package/src/reducers/ui/answers.ts +5 -9
- package/src/reducers/ui/index.ts +4 -1
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +24 -4
- package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
- package/src/reducers/ui/test/navigation.test.ts +5 -5
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/test/util/services.mock.ts +91 -73
- package/src/types/common.ts +0 -30
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +37 -22
- package/src/views/slides/map-api-slide-to-ui.ts +89 -89
- package/src/views/slides/test/fixtures/free-text.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
- package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
- package/src/views/slides/test/fixtures/qcm.ts +2 -1
- package/src/views/slides/test/fixtures/select-template.ts +2 -1
- package/src/views/slides/test/fixtures/slider.ts +2 -1
- package/src/views/slides/test/fixtures/text-template.ts +2 -1
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +2 -1
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Dispatch } from 'redux';
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
2
|
import type { StoreState } from '../../reducers';
|
|
3
|
-
import { Options, Skill } from '../../types/common';
|
|
3
|
+
import type { Options, Skill } from '../../types/common';
|
|
4
4
|
export declare const SKILLS_FETCH_REQUEST: "@@skills/FETCH_REQUEST";
|
|
5
5
|
export declare const SKILLS_FETCH_SUCCESS: "@@skills/FETCH_SUCCESS";
|
|
6
6
|
export declare const SKILLS_FETCH_FAILURE: "@@skills/FETCH_FAILURE";
|
|
@@ -8,4 +8,4 @@ export declare type ReceivedSkills = {
|
|
|
8
8
|
type: '@@skills/FETCH_SUCCESS';
|
|
9
9
|
payload: Skill[];
|
|
10
10
|
};
|
|
11
|
-
export declare const fetchSkills: (
|
|
11
|
+
export declare const fetchSkills: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
2
3
|
export const SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST';
|
|
3
4
|
export const SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS';
|
|
4
5
|
export const SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE';
|
|
5
|
-
export const fetchSkills =
|
|
6
|
+
export const fetchSkills = async (dispatch, getState, { services }) => {
|
|
6
7
|
const action = buildTask({
|
|
7
8
|
types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
|
|
8
|
-
task: () =>
|
|
9
|
+
task: () => {
|
|
10
|
+
const state = getState();
|
|
11
|
+
const token = get('data.token', state);
|
|
12
|
+
return services.fetchSkills(token);
|
|
13
|
+
}
|
|
9
14
|
});
|
|
10
15
|
await dispatch(action);
|
|
11
16
|
};
|
|
@@ -17,4 +17,4 @@ export declare type ReceivedSlide = {
|
|
|
17
17
|
slideRef: string;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export declare const fetchSlide: (slideRef: string
|
|
20
|
+
export declare const fetchSlide: (slideRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -6,13 +6,15 @@ import { setCurrentSlide } from '../ui/slides';
|
|
|
6
6
|
export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST';
|
|
7
7
|
export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS';
|
|
8
8
|
export const SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE';
|
|
9
|
-
export const fetchSlide = (slideRef
|
|
9
|
+
export const fetchSlide = (slideRef) => async (dispatch, getState, { services }) => {
|
|
10
10
|
const action = buildTask({
|
|
11
11
|
types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
|
|
12
12
|
bailout: (state) => {
|
|
13
13
|
return has(`data.slide.${slideRef}`, state);
|
|
14
14
|
},
|
|
15
15
|
task: () => {
|
|
16
|
+
const state = getState();
|
|
17
|
+
const token = get('data.token', state);
|
|
16
18
|
return services.fetchSlide(slideRef, token);
|
|
17
19
|
},
|
|
18
20
|
meta: { slideRef }
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Dispatch } from 'redux';
|
|
2
|
+
import type { Options } from '../../types/common';
|
|
3
|
+
import type { StoreState } from '../../reducers';
|
|
4
|
+
export declare const POST_ANSWER_REQUEST: "@@answer/POST_REQUEST";
|
|
5
|
+
export declare const POST_ANSWER_SUCCESS: "@@answer/POST_SUCCESS";
|
|
6
|
+
export declare const POST_ANSWER_FAILURE: "@@answer/POST_FAILURE";
|
|
7
|
+
export declare type PostAnswerRequestAction = {
|
|
8
|
+
type: typeof POST_ANSWER_REQUEST;
|
|
9
|
+
};
|
|
10
|
+
export declare const postAnswer: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
3
|
+
import { fetchSlide } from './fetch-slide';
|
|
4
|
+
export const POST_ANSWER_REQUEST = '@@answer/POST_REQUEST';
|
|
5
|
+
export const POST_ANSWER_SUCCESS = '@@answer/POST_SUCCESS';
|
|
6
|
+
export const POST_ANSWER_FAILURE = '@@answer/POST_FAILURE';
|
|
7
|
+
export const postAnswer = async (dispatch, getState, { services }) => {
|
|
8
|
+
const action = buildTask({
|
|
9
|
+
types: [POST_ANSWER_REQUEST, POST_ANSWER_SUCCESS, POST_ANSWER_FAILURE],
|
|
10
|
+
task: () => {
|
|
11
|
+
const state = getState();
|
|
12
|
+
const token = get('data.token', state);
|
|
13
|
+
const answer = get('ui.answers', state);
|
|
14
|
+
const progressionId = get('data.progression._id', state);
|
|
15
|
+
const skillRef = get('data.progression.content.ref', state);
|
|
16
|
+
return services.postAnswer(skillRef, token, progressionId, answer);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const response = await dispatch(action);
|
|
20
|
+
if (response.type === POST_ANSWER_SUCCESS) {
|
|
21
|
+
const progression = response.payload;
|
|
22
|
+
const slideRef = progression.state.nextContent.ref;
|
|
23
|
+
await dispatch(fetchSlide(slideRef));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Dispatch } from 'redux';
|
|
2
|
-
import { Options, ProgressionFromAPI } from '../../types/common';
|
|
2
|
+
import type { Options, ProgressionFromAPI } from '../../types/common';
|
|
3
3
|
import type { StoreState } from '../../reducers';
|
|
4
4
|
export declare const POST_PROGRESSION_REQUEST: "@@progression/POST_REQUEST";
|
|
5
5
|
export declare const POST_PROGRESSION_SUCCESS: "@@progression/POST_SUCCESS";
|
|
6
6
|
export declare const POST_PROGRESSION_FAILURE: "@@progression/POST_FAILURE";
|
|
7
|
-
export declare type
|
|
7
|
+
export declare type ReceivedProgression = {
|
|
8
8
|
type: typeof POST_PROGRESSION_SUCCESS;
|
|
9
9
|
payload: ProgressionFromAPI;
|
|
10
10
|
};
|
|
11
|
-
export declare const postProgression: (skillRef: string
|
|
11
|
+
export declare const postProgression: (skillRef: string) => (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
2
3
|
import { fetchSlide } from './fetch-slide';
|
|
3
4
|
export const POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST';
|
|
4
5
|
export const POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS';
|
|
5
6
|
export const POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE';
|
|
6
|
-
export const postProgression = (skillRef
|
|
7
|
+
export const postProgression = (skillRef) => async (dispatch, getState, { services }) => {
|
|
8
|
+
const state = getState();
|
|
9
|
+
const token = get('data.token', state);
|
|
7
10
|
const action = buildTask({
|
|
8
11
|
types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
|
|
9
12
|
task: () => {
|
|
@@ -14,6 +17,6 @@ export const postProgression = (skillRef, token) => async (dispatch, getState, {
|
|
|
14
17
|
if (response.type === POST_PROGRESSION_SUCCESS) {
|
|
15
18
|
const progression = response.payload;
|
|
16
19
|
const slideRef = progression.state.nextContent.ref;
|
|
17
|
-
await dispatch(fetchSlide(slideRef
|
|
20
|
+
await dispatch(fetchSlide(slideRef));
|
|
18
21
|
}
|
|
19
22
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import { fetchSkills, SKILLS_FETCH_FAILURE, SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS } from '../fetch-skills';
|
|
3
3
|
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
4
|
-
import { createTestStore } from '
|
|
4
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
5
5
|
const initialState = {
|
|
6
6
|
data: {
|
|
7
7
|
progression: null,
|
|
@@ -12,7 +12,10 @@ const initialState = {
|
|
|
12
12
|
ui: {
|
|
13
13
|
currentSlideRef: '',
|
|
14
14
|
navigation: [],
|
|
15
|
-
answers: []
|
|
15
|
+
answers: [],
|
|
16
|
+
slide: {
|
|
17
|
+
validateButton: false
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
};
|
|
18
21
|
test('should dispatch SKILLS_FETCH_SUCCESS actions when fetchSkills return a list of skills', async (t) => {
|
|
@@ -31,7 +34,7 @@ test('should dispatch SKILLS_FETCH_SUCCESS actions when fetchSkills return a lis
|
|
|
31
34
|
}
|
|
32
35
|
];
|
|
33
36
|
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
34
|
-
await dispatch(fetchSkills
|
|
37
|
+
await dispatch(fetchSkills);
|
|
35
38
|
});
|
|
36
39
|
test('should dispatch SKILLS_FETCH_FAILURE action when fetchSkills fails', async (t) => {
|
|
37
40
|
const services = {
|
|
@@ -50,5 +53,5 @@ test('should dispatch SKILLS_FETCH_FAILURE action when fetchSkills fails', async
|
|
|
50
53
|
}
|
|
51
54
|
];
|
|
52
55
|
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
53
|
-
await dispatch(fetchSkills
|
|
56
|
+
await dispatch(fetchSkills);
|
|
54
57
|
});
|
|
@@ -3,7 +3,7 @@ import { fetchSlide, SLIDE_FETCH_FAILURE, SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCE
|
|
|
3
3
|
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
4
4
|
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
5
5
|
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
6
|
-
import { createTestStore } from '
|
|
6
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
7
7
|
const initialState = {
|
|
8
8
|
data: {
|
|
9
9
|
progression: null,
|
|
@@ -14,7 +14,10 @@ const initialState = {
|
|
|
14
14
|
ui: {
|
|
15
15
|
currentSlideRef: '',
|
|
16
16
|
navigation: [],
|
|
17
|
-
answers: []
|
|
17
|
+
answers: [],
|
|
18
|
+
slide: {
|
|
19
|
+
validateButton: false
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
};
|
|
20
23
|
test('should dispatch FETCH_SUCCESS and SET_CURRENT_SLIDE actions when fetchSlide return a slide', async (t) => {
|
|
@@ -36,7 +39,7 @@ test('should dispatch FETCH_SUCCESS and SET_CURRENT_SLIDE actions when fetchSlid
|
|
|
36
39
|
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
37
40
|
];
|
|
38
41
|
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
39
|
-
await dispatch(fetchSlide('sli_VJYjJnJhg'
|
|
42
|
+
await dispatch(fetchSlide('sli_VJYjJnJhg'));
|
|
40
43
|
});
|
|
41
44
|
test('should dispatch SLIDE_FETCH_FAILURE action when fetchSlide fails', async (t) => {
|
|
42
45
|
const services = {
|
|
@@ -57,5 +60,5 @@ test('should dispatch SLIDE_FETCH_FAILURE action when fetchSlide fails', async (
|
|
|
57
60
|
}
|
|
58
61
|
];
|
|
59
62
|
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
60
|
-
await dispatch(fetchSlide('slide_ref'
|
|
63
|
+
await dispatch(fetchSlide('slide_ref'));
|
|
61
64
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
3
|
+
import { postAnswerResponse, services } from '../../../test/util/services.mock';
|
|
4
|
+
import { postAnswer, POST_ANSWER_FAILURE, POST_ANSWER_REQUEST, POST_ANSWER_SUCCESS } from '../post-answer';
|
|
5
|
+
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
6
|
+
import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
7
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
8
|
+
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
9
|
+
const progressionId = '123456789123';
|
|
10
|
+
const skillRef = '_skill-ref';
|
|
11
|
+
const answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
12
|
+
const initialState = {
|
|
13
|
+
data: {
|
|
14
|
+
progression: {
|
|
15
|
+
_id: progressionId,
|
|
16
|
+
content: { type: 'skill', ref: skillRef },
|
|
17
|
+
engine: {
|
|
18
|
+
ref: 'review'
|
|
19
|
+
},
|
|
20
|
+
state: {
|
|
21
|
+
allAnswers: [],
|
|
22
|
+
isCorrect: true,
|
|
23
|
+
nextContent: {
|
|
24
|
+
ref: 'sli_VJYjJnJhg',
|
|
25
|
+
type: 'slide'
|
|
26
|
+
},
|
|
27
|
+
pendingSlides: [],
|
|
28
|
+
slides: [],
|
|
29
|
+
step: {
|
|
30
|
+
current: 1
|
|
31
|
+
},
|
|
32
|
+
stars: 0
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
slides: {
|
|
36
|
+
[freeTextSlide.id]: freeTextSlide
|
|
37
|
+
},
|
|
38
|
+
skills: [{ skillRef, custom: false, name: skillRef, slidesToReview: 5 }],
|
|
39
|
+
token: '1234'
|
|
40
|
+
},
|
|
41
|
+
ui: {
|
|
42
|
+
currentSlideRef: 'sli_VJYjJnJhg',
|
|
43
|
+
navigation: ['skills', 'slides'],
|
|
44
|
+
answers: answer,
|
|
45
|
+
slide: {
|
|
46
|
+
validateButton: false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
test('should dispatch POST_ANSWER_REQUEST, then POST_ANSWER_SUCCESS when the updated progression is returned', async (t) => {
|
|
51
|
+
const expectedActions = [
|
|
52
|
+
{ type: POST_ANSWER_REQUEST },
|
|
53
|
+
{
|
|
54
|
+
type: POST_ANSWER_SUCCESS,
|
|
55
|
+
payload: postAnswerResponse
|
|
56
|
+
},
|
|
57
|
+
{ type: SLIDE_FETCH_REQUEST, meta: { slideRef: 'sli_VkSQroQnx' } },
|
|
58
|
+
{
|
|
59
|
+
type: SLIDE_FETCH_SUCCESS,
|
|
60
|
+
meta: { slideRef: 'sli_VkSQroQnx' },
|
|
61
|
+
payload: qcmGraphicSlide
|
|
62
|
+
},
|
|
63
|
+
{ type: SET_CURRENT_SLIDE, payload: qcmGraphicSlide }
|
|
64
|
+
];
|
|
65
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
66
|
+
await dispatch(postAnswer);
|
|
67
|
+
});
|
|
68
|
+
test('should dispatch POST_ANSWER_REQUEST, then POST_ANSWER_FAILURE on error', async (t) => {
|
|
69
|
+
const expectedActions = [
|
|
70
|
+
{ type: POST_ANSWER_REQUEST },
|
|
71
|
+
{
|
|
72
|
+
type: POST_ANSWER_FAILURE,
|
|
73
|
+
payload: new Error('unexpected'),
|
|
74
|
+
error: true
|
|
75
|
+
}
|
|
76
|
+
];
|
|
77
|
+
const { dispatch } = createTestStore(t, initialState, {
|
|
78
|
+
...services,
|
|
79
|
+
postAnswer: () => Promise.reject(new Error('unexpected'))
|
|
80
|
+
}, expectedActions);
|
|
81
|
+
await dispatch(postAnswer);
|
|
82
|
+
});
|
|
@@ -4,7 +4,7 @@ import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
|
4
4
|
import { services as mockedServices } from '../../../test/util/services.mock';
|
|
5
5
|
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
6
6
|
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
7
|
-
import { createTestStore } from '
|
|
7
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
8
8
|
const initialState = {
|
|
9
9
|
data: {
|
|
10
10
|
progression: null,
|
|
@@ -15,7 +15,10 @@ const initialState = {
|
|
|
15
15
|
ui: {
|
|
16
16
|
currentSlideRef: '',
|
|
17
17
|
navigation: [],
|
|
18
|
-
answers: []
|
|
18
|
+
answers: [],
|
|
19
|
+
slide: {
|
|
20
|
+
validateButton: false
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
};
|
|
21
24
|
test('should dispatch POST_PROGRESSION_SUCCESS and SLIDE_FETCH_REQUEST actions when postProgression return a progression', async (t) => {
|
|
@@ -78,7 +81,7 @@ test('should dispatch POST_PROGRESSION_SUCCESS and SLIDE_FETCH_REQUEST actions w
|
|
|
78
81
|
{ type: SET_CURRENT_SLIDE, payload: freeTextSlide }
|
|
79
82
|
];
|
|
80
83
|
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
81
|
-
await dispatch(postProgression('skill_12345'
|
|
84
|
+
await dispatch(postProgression('skill_12345'));
|
|
82
85
|
});
|
|
83
86
|
test('should dispatch POST_PROGRESSION_FAILURE action when postProgression fails', async (t) => {
|
|
84
87
|
const services = {
|
|
@@ -98,5 +101,5 @@ test('should dispatch POST_PROGRESSION_FAILURE action when postProgression fails
|
|
|
98
101
|
}
|
|
99
102
|
];
|
|
100
103
|
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
101
|
-
await dispatch(postProgression('skill_12345'
|
|
104
|
+
await dispatch(postProgression('skill_12345'));
|
|
102
105
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import { createTestStore } from '../../test/create-test-store';
|
|
3
|
+
import { services } from '../../../test/util/services.mock';
|
|
4
|
+
import { storeToken, STORE_TOKEN } from '../token';
|
|
5
|
+
const initialState = {
|
|
6
|
+
data: {
|
|
7
|
+
progression: null,
|
|
8
|
+
slides: {},
|
|
9
|
+
skills: [],
|
|
10
|
+
token: '1234'
|
|
11
|
+
},
|
|
12
|
+
ui: {
|
|
13
|
+
currentSlideRef: '',
|
|
14
|
+
navigation: [],
|
|
15
|
+
answers: [],
|
|
16
|
+
slide: {
|
|
17
|
+
validateButton: false
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
test('should dispatch STORE_TOKEN action when storeToken is called', async (t) => {
|
|
22
|
+
const expectedActions = [{ type: STORE_TOKEN, payload: 'JWT.token' }];
|
|
23
|
+
const { dispatch } = createTestStore(t, initialState, services, expectedActions);
|
|
24
|
+
await dispatch(storeToken('JWT.token'));
|
|
25
|
+
});
|
package/es/actions/index.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { navigateBack, navigateTo, NavigateBack, NavigateTo, StartApp } from './ui/navigation';
|
|
3
|
-
import { ReceivedSlide } from './api/fetch-slide';
|
|
4
|
-
import { ReceiveProgression } from './api/post-progression';
|
|
5
|
-
import { ReceivedSkills } from './api/fetch-skills';
|
|
6
|
-
import { validateSlide } from './ui/slides';
|
|
7
|
-
export declare type Action = NavigateBack | NavigateTo | ReceivedSkills | StartApp | ReceivedSlide | StoreToken | ReceiveProgression;
|
|
1
|
+
import { navigateBack, navigateTo } from './ui/navigation';
|
|
8
2
|
export declare type Dispatchers = {
|
|
9
3
|
navigateTo: typeof navigateTo;
|
|
10
4
|
navigateBack: typeof navigateBack;
|
|
11
|
-
validateSlide: typeof validateSlide;
|
|
12
5
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExecutionContext } from 'ava';
|
|
2
2
|
import { AnyAction, Store } from 'redux';
|
|
3
|
-
import { StoreState } from '
|
|
4
|
-
import { Services } from '
|
|
3
|
+
import { StoreState } from '../../reducers';
|
|
4
|
+
import { Services } from '../../types/common';
|
|
5
5
|
export declare const createTestStore: (t: ExecutionContext, initialState: StoreState, services: Services, actions: AnyAction[]) => Store;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import constant from 'lodash/fp/constant';
|
|
2
2
|
import { applyMiddleware, compose, createStore } from 'redux';
|
|
3
3
|
import thunk from 'redux-thunk';
|
|
4
|
-
import rootReducer from '
|
|
4
|
+
import rootReducer from '../../reducers';
|
|
5
5
|
const assertActionsMiddleware = (t, ACTIONS) => constant((next) => (action) => {
|
|
6
6
|
const expectedAction = ACTIONS.shift();
|
|
7
7
|
if (!expectedAction)
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { Dispatch } from 'redux';
|
|
2
|
+
import type { StoreState } from '../../reducers';
|
|
3
|
+
export declare const EDIT_QCM: "@@answer/EDIT_QCM";
|
|
4
|
+
export declare const EDIT_QCM_GRAPHIC: "@@answer/EDIT_QCM_GRAPHIC";
|
|
5
|
+
export declare const EDIT_QCM_DRAG: "@@answer/EDIT_QCM_DRAG";
|
|
6
|
+
export declare const EDIT_TEMPLATE: "@@answer/EDIT_TEMPLATE";
|
|
2
7
|
export declare const EDIT_BASIC: "@@answer/EDIT_BASIC";
|
|
3
|
-
export declare
|
|
4
|
-
|
|
8
|
+
export declare const EDIT_SLIDER: "@@answer/EDIT_SLIDER";
|
|
9
|
+
export declare const ANSWER_EDIT: {
|
|
10
|
+
readonly qcm: "@@answer/EDIT_QCM";
|
|
11
|
+
readonly qcmGraphic: "@@answer/EDIT_QCM_GRAPHIC";
|
|
12
|
+
readonly qcmDrag: "@@answer/EDIT_QCM_DRAG";
|
|
13
|
+
readonly template: "@@answer/EDIT_TEMPLATE";
|
|
14
|
+
readonly basic: "@@answer/EDIT_BASIC";
|
|
15
|
+
readonly slider: "@@answer/EDIT_SLIDER";
|
|
16
|
+
};
|
|
17
|
+
export declare type EditAnswerAction = {
|
|
18
|
+
type: typeof EDIT_QCM | typeof EDIT_QCM_GRAPHIC | typeof EDIT_QCM_DRAG | typeof EDIT_TEMPLATE | typeof EDIT_BASIC | typeof EDIT_SLIDER;
|
|
5
19
|
payload: string[];
|
|
6
20
|
};
|
|
7
|
-
export declare const editAnswer: (answer: string) => (dispatch: Dispatch) =>
|
|
21
|
+
export declare const editAnswer: (answer: string) => (dispatch: Dispatch, getState: () => StoreState) => EditAnswerAction;
|
package/es/actions/ui/answers.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
|
+
import { flatten, get, includes, pull } from 'lodash/fp';
|
|
2
|
+
export const EDIT_QCM = '@@answer/EDIT_QCM';
|
|
3
|
+
export const EDIT_QCM_GRAPHIC = '@@answer/EDIT_QCM_GRAPHIC';
|
|
4
|
+
export const EDIT_QCM_DRAG = '@@answer/EDIT_QCM_DRAG';
|
|
5
|
+
export const EDIT_TEMPLATE = '@@answer/EDIT_TEMPLATE';
|
|
1
6
|
export const EDIT_BASIC = '@@answer/EDIT_BASIC';
|
|
2
|
-
export const
|
|
7
|
+
export const EDIT_SLIDER = '@@answer/EDIT_SLIDER';
|
|
8
|
+
export const ANSWER_EDIT = {
|
|
9
|
+
qcm: EDIT_QCM,
|
|
10
|
+
qcmGraphic: EDIT_QCM_GRAPHIC,
|
|
11
|
+
qcmDrag: EDIT_QCM_DRAG,
|
|
12
|
+
template: EDIT_TEMPLATE,
|
|
13
|
+
basic: EDIT_BASIC,
|
|
14
|
+
slider: EDIT_SLIDER
|
|
15
|
+
};
|
|
16
|
+
const buildAnswer = (userAnswers, questionType, newValue) => {
|
|
17
|
+
switch (questionType) {
|
|
18
|
+
case 'qcm':
|
|
19
|
+
case 'qcmGraphic':
|
|
20
|
+
case 'qcmDrag': {
|
|
21
|
+
return includes(newValue, userAnswers)
|
|
22
|
+
? pull(newValue, userAnswers)
|
|
23
|
+
: flatten([...userAnswers, newValue]);
|
|
24
|
+
}
|
|
25
|
+
case 'basic':
|
|
26
|
+
case 'slider':
|
|
27
|
+
return [newValue];
|
|
28
|
+
default:
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const editAnswer = (answer) => (dispatch, getState) => {
|
|
33
|
+
const state = getState();
|
|
34
|
+
const currentSlideRef = get(['ui', 'currentSlideRef'])(state);
|
|
35
|
+
const userAnswers = get(['ui', 'answers'])(state);
|
|
36
|
+
const slide = get(['data', 'slides', currentSlideRef])(state);
|
|
37
|
+
const questionType = get(['question', 'type'])(slide);
|
|
38
|
+
const type = get(questionType, ANSWER_EDIT);
|
|
3
39
|
return dispatch({
|
|
4
|
-
type
|
|
5
|
-
payload:
|
|
40
|
+
type,
|
|
41
|
+
payload: buildAnswer(userAnswers, questionType, answer)
|
|
6
42
|
});
|
|
7
43
|
};
|
|
@@ -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
|
@@ -51,9 +51,7 @@ const AppReview = ({ options }) => {
|
|
|
51
51
|
const skillRef = get('skillRef', options);
|
|
52
52
|
/* ThunkAction is not assignable to parameter of type 'AnyAction'
|
|
53
53
|
ts problem is described here = https://github.com/reduxjs/redux-thunk/issues/333 */
|
|
54
|
-
skillRef
|
|
55
|
-
? store.dispatch(postProgression(skillRef, token))
|
|
56
|
-
: store.dispatch(fetchSkills(token));
|
|
54
|
+
skillRef ? store.dispatch(postProgression(skillRef)) : store.dispatch(fetchSkills);
|
|
57
55
|
}, [options, store]);
|
|
58
56
|
useEffect(() => {
|
|
59
57
|
if (store === null)
|