@coorpacademy/app-review 0.1.16 → 0.1.18
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 +14 -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 +41 -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 +100 -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 +3 -3
- package/es/reducers/data/progression.js +2 -5
- package/es/reducers/data/slides.d.ts +2 -3
- package/es/reducers/data/test/progression.test.js +12 -27
- 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 +23 -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 +3 -1
- package/es/test/util/services.mock.js +89 -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 +19 -15
- package/es/views/slides/map-api-slide-to-ui.js +65 -68
- 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/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/template.d.ts +4 -0
- package/{lib/views/slides/test/fixtures/select-template.js → es/views/slides/test/fixtures/template.js} +82 -4
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +473 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/es/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/es/views/slides/test/slide.template.on-change.test.js +79 -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 +14 -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 +50 -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 +190 -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 +3 -3
- package/lib/reducers/data/progression.js +2 -5
- package/lib/reducers/data/slides.d.ts +2 -3
- package/lib/reducers/data/test/progression.test.js +12 -27
- 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 +23 -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 +3 -1
- package/lib/test/util/services.mock.js +89 -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 +19 -15
- package/lib/views/slides/map-api-slide-to-ui.js +106 -99
- 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/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/template.d.ts +4 -0
- package/{es/views/slides/test/fixtures/select-template.js → lib/views/slides/test/fixtures/template.js} +82 -4
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +473 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.js +4 -10
- package/lib/views/slides/test/slide.template.on-change.test.d.ts +1 -0
- package/lib/views/slides/test/slide.template.on-change.test.js +82 -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 +44 -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 +55 -6
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +115 -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 +4 -7
- package/src/reducers/data/slides.ts +2 -3
- package/src/reducers/data/test/progression.test.ts +15 -31
- 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 +29 -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 +94 -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 +38 -23
- package/src/views/slides/map-api-slide-to-ui.ts +146 -113
- 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/slider.ts +2 -1
- package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +84 -5
- package/src/views/slides/test/index.test.ts +493 -0
- package/src/views/slides/test/map-api-slide-to-ui.test.ts +6 -11
- package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
- 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/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/es/views/slides/test/fixtures/text-template.js +0 -58
- 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/views/slides/test/fixtures/select-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.d.ts +0 -3
- package/lib/views/slides/test/fixtures/text-template.js +0 -58
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
- package/src/views/slides/test/fixtures/text-template.ts +0 -61
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import set from 'lodash/fp/set';
|
|
2
|
-
import {ValidateSlide} from '../../actions/ui/slides';
|
|
3
2
|
import {
|
|
4
3
|
ReceivedSlide,
|
|
5
4
|
FetchSlide,
|
|
@@ -8,9 +7,9 @@ import {
|
|
|
8
7
|
} from '../../actions/api/fetch-slide';
|
|
9
8
|
import {SlideFromAPI} from '../../types/common';
|
|
10
9
|
|
|
11
|
-
export type SlidesAction = FetchSlide | ReceivedSlide
|
|
10
|
+
export type SlidesAction = FetchSlide | ReceivedSlide;
|
|
12
11
|
|
|
13
|
-
export type SlidesState = Record<string, SlideFromAPI>;
|
|
12
|
+
export type SlidesState = Record<string, SlideFromAPI | null>;
|
|
14
13
|
export const initialState: SlidesState = {};
|
|
15
14
|
|
|
16
15
|
// eslint-disable-next-line default-param-last
|
|
@@ -1,42 +1,26 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../progression';
|
|
3
|
-
import {POST_PROGRESSION_SUCCESS,
|
|
4
|
-
import {
|
|
3
|
+
import {POST_PROGRESSION_SUCCESS, ReceivedProgression} from '../../../actions/api/post-progression';
|
|
4
|
+
import {POST_ANSWER_SUCCESS} from '../../../actions/api/post-answer';
|
|
5
|
+
import {postAnswerResponse, postProgressionResponse} from '../../../test/util/services.mock';
|
|
5
6
|
|
|
6
|
-
test('should have
|
|
7
|
-
const state = reducer(undefined, {} as
|
|
7
|
+
test('should have initial value', t => {
|
|
8
|
+
const state = reducer(undefined, {} as ReceivedProgression);
|
|
8
9
|
t.is(state, null);
|
|
9
10
|
});
|
|
10
11
|
|
|
11
12
|
test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
|
|
12
|
-
const progression: ProgressionFromAPI = {
|
|
13
|
-
_id: '62b1d1087aa12f00253f40ee',
|
|
14
|
-
content: {
|
|
15
|
-
ref: '_skill-ref',
|
|
16
|
-
type: 'skill'
|
|
17
|
-
},
|
|
18
|
-
engine: {
|
|
19
|
-
ref: 'review'
|
|
20
|
-
},
|
|
21
|
-
state: {
|
|
22
|
-
allAnswers: [],
|
|
23
|
-
isCorrect: true,
|
|
24
|
-
nextContent: {
|
|
25
|
-
ref: 'sli_N1XACJobn',
|
|
26
|
-
type: 'slide'
|
|
27
|
-
},
|
|
28
|
-
pendingSlides: [],
|
|
29
|
-
slides: [],
|
|
30
|
-
step: {
|
|
31
|
-
current: 1
|
|
32
|
-
},
|
|
33
|
-
stars: 0
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
13
|
const state = reducer(null, {
|
|
38
14
|
type: POST_PROGRESSION_SUCCESS,
|
|
39
|
-
payload:
|
|
15
|
+
payload: postProgressionResponse
|
|
16
|
+
});
|
|
17
|
+
t.deepEqual(state, postProgressionResponse);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('should set the value of POST_ANSWER_SUCCESS action', t => {
|
|
21
|
+
const state = reducer(null, {
|
|
22
|
+
type: POST_ANSWER_SUCCESS,
|
|
23
|
+
payload: postAnswerResponse
|
|
40
24
|
});
|
|
41
|
-
t.deepEqual(state,
|
|
25
|
+
t.deepEqual(state, postAnswerResponse);
|
|
42
26
|
});
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {includes, values} from 'lodash/fp';
|
|
2
|
+
import {EditAnswerAction, ANSWER_EDIT} from '../../actions/ui/answers';
|
|
2
3
|
|
|
3
4
|
export type AnswerState = string[];
|
|
5
|
+
const ANSWER_EDIT_ACTIONS = values(ANSWER_EDIT);
|
|
4
6
|
|
|
5
7
|
const reducer = (
|
|
6
8
|
// eslint-disable-next-line default-param-last
|
|
7
9
|
state: AnswerState = [],
|
|
8
|
-
action:
|
|
10
|
+
action: EditAnswerAction
|
|
9
11
|
): AnswerState => {
|
|
10
|
-
|
|
11
|
-
case EDIT_BASIC: {
|
|
12
|
-
return action.payload;
|
|
13
|
-
}
|
|
14
|
-
default:
|
|
15
|
-
return state;
|
|
16
|
-
}
|
|
12
|
+
return includes(action.type, ANSWER_EDIT_ACTIONS) ? action.payload : state;
|
|
17
13
|
};
|
|
18
14
|
|
|
19
15
|
export default reducer;
|
package/src/reducers/ui/index.ts
CHANGED
|
@@ -3,15 +3,18 @@ import {combineReducers} from 'redux';
|
|
|
3
3
|
import currentSlideRef, {CurrentSlideRefState} from './current-slide-ref';
|
|
4
4
|
import navigation, {NavigationState} from './navigation';
|
|
5
5
|
import answers, {AnswerState} from './answers';
|
|
6
|
+
import slide, {UISlideState} from './slide';
|
|
6
7
|
|
|
7
8
|
export type UIState = {
|
|
8
9
|
currentSlideRef: CurrentSlideRefState;
|
|
9
10
|
navigation: NavigationState;
|
|
10
11
|
answers: AnswerState;
|
|
12
|
+
slide: UISlideState;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export default combineReducers({
|
|
14
16
|
currentSlideRef,
|
|
15
17
|
navigation,
|
|
16
|
-
answers
|
|
18
|
+
answers,
|
|
19
|
+
slide
|
|
17
20
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import compact from 'lodash/fp/compact';
|
|
2
|
+
import isEmpty from 'lodash/fp/isEmpty';
|
|
3
|
+
import pipe from 'lodash/fp/pipe';
|
|
4
|
+
import {
|
|
5
|
+
EditAnswerAction,
|
|
6
|
+
EDIT_BASIC,
|
|
7
|
+
EDIT_QCM,
|
|
8
|
+
EDIT_QCM_DRAG,
|
|
9
|
+
EDIT_QCM_GRAPHIC,
|
|
10
|
+
EDIT_SLIDER,
|
|
11
|
+
EDIT_TEMPLATE
|
|
12
|
+
} from '../../actions/ui/answers';
|
|
13
|
+
import {PostAnswerRequestAction, POST_ANSWER_REQUEST} from '../../actions/api/post-answer';
|
|
14
|
+
|
|
15
|
+
export type UISlideState = {
|
|
16
|
+
validateButton: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const initialState: UISlideState = {validateButton: false};
|
|
20
|
+
|
|
21
|
+
const reducer = (
|
|
22
|
+
// eslint-disable-next-line default-param-last
|
|
23
|
+
state: UISlideState = initialState,
|
|
24
|
+
action: PostAnswerRequestAction | EditAnswerAction
|
|
25
|
+
): UISlideState => {
|
|
26
|
+
switch (action.type) {
|
|
27
|
+
case EDIT_QCM:
|
|
28
|
+
case EDIT_QCM_GRAPHIC:
|
|
29
|
+
case EDIT_QCM_DRAG:
|
|
30
|
+
case EDIT_TEMPLATE:
|
|
31
|
+
case EDIT_BASIC:
|
|
32
|
+
case EDIT_SLIDER: {
|
|
33
|
+
return pipe(compact, isEmpty)(action.payload) ? initialState : {validateButton: true};
|
|
34
|
+
}
|
|
35
|
+
case POST_ANSWER_REQUEST: {
|
|
36
|
+
return initialState;
|
|
37
|
+
}
|
|
38
|
+
default:
|
|
39
|
+
return state;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default reducer;
|
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../answers';
|
|
3
|
-
import {
|
|
3
|
+
import {EditAnswerAction, ANSWER_EDIT} from '../../../actions/ui/answers';
|
|
4
4
|
|
|
5
|
-
test('should have
|
|
6
|
-
const state = reducer(undefined, {} as
|
|
5
|
+
test('should have initial value', t => {
|
|
6
|
+
const state = reducer(undefined, {} as EditAnswerAction);
|
|
7
7
|
t.deepEqual(state, []);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
test('should set the value of EDIT_BASIC action', t => {
|
|
11
|
-
const state = reducer([], {type:
|
|
11
|
+
const state = reducer([], {type: ANSWER_EDIT.basic, payload: ['value']});
|
|
12
12
|
t.deepEqual(state, ['value']);
|
|
13
13
|
});
|
|
14
|
+
|
|
15
|
+
test('should set the value of EDIT_QCM action', t => {
|
|
16
|
+
const state = reducer([], {type: ANSWER_EDIT.qcm, payload: ['value1', 'value2']});
|
|
17
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('should set the value of EDIT_QCM_GRAPHIC action', t => {
|
|
21
|
+
const state = reducer([], {type: ANSWER_EDIT.qcmGraphic, payload: ['True', 'False']});
|
|
22
|
+
t.deepEqual(state, ['True', 'False']);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('should set the value of EDIT_QCM_DRAG action', t => {
|
|
26
|
+
const state = reducer([], {type: ANSWER_EDIT.qcmDrag, payload: ['value1', 'value2']});
|
|
27
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('should set the value of EDIT_SLIDER action', t => {
|
|
31
|
+
const state = reducer([], {type: ANSWER_EDIT.slider, payload: ['5']});
|
|
32
|
+
t.deepEqual(state, ['5']);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('should set the value of EDIT_TEMPLATE action', t => {
|
|
36
|
+
const state = reducer([], {type: ANSWER_EDIT.template, payload: ['value1', 'value2']});
|
|
37
|
+
t.deepEqual(state, ['value1', 'value2']);
|
|
38
|
+
});
|
|
@@ -3,7 +3,7 @@ import reducer from '../current-slide-ref';
|
|
|
3
3
|
import {SetCurrentSlide, SET_CURRENT_SLIDE} from '../../../actions/ui/slides';
|
|
4
4
|
import {freeTextSlide} from '../../../views/slides/test/fixtures/free-text';
|
|
5
5
|
|
|
6
|
-
test('should have
|
|
6
|
+
test('should have initial value', t => {
|
|
7
7
|
const state = reducer(undefined, {} as SetCurrentSlide);
|
|
8
8
|
t.is(state, '');
|
|
9
9
|
});
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import test from 'ava';
|
|
2
2
|
import reducer from '../navigation';
|
|
3
|
-
import {NavigateTo,
|
|
3
|
+
import {NavigateTo, navigateBack, navigateTo} from '../../../actions/ui/navigation';
|
|
4
4
|
|
|
5
|
-
test('should have
|
|
5
|
+
test('should have initial value', t => {
|
|
6
6
|
const state = reducer(undefined, {} as NavigateTo);
|
|
7
7
|
t.deepEqual(state, []);
|
|
8
8
|
});
|
|
9
9
|
|
|
10
10
|
test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
|
|
11
|
-
const state = reducer([],
|
|
11
|
+
const state = reducer([], navigateTo('loader'));
|
|
12
12
|
t.deepEqual(state, ['loader']);
|
|
13
13
|
|
|
14
|
-
const updatedState = reducer(state,
|
|
14
|
+
const updatedState = reducer(state, navigateTo('skills'));
|
|
15
15
|
t.deepEqual(updatedState, ['loader', 'skills']);
|
|
16
16
|
|
|
17
|
-
const _updatedState = reducer(updatedState,
|
|
17
|
+
const _updatedState = reducer(updatedState, navigateBack());
|
|
18
18
|
t.deepEqual(_updatedState, ['loader']);
|
|
19
19
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import reducer, {initialState} from '../slide';
|
|
3
|
+
import {EDIT_BASIC} from '../../../actions/ui/answers';
|
|
4
|
+
import {PostAnswerRequestAction} from '../../../actions/api/post-answer';
|
|
5
|
+
|
|
6
|
+
test('should use initial state if no answers are found when an EditAnswerAction is received', t => {
|
|
7
|
+
const state = reducer(undefined, {type: EDIT_BASIC, payload: ['']});
|
|
8
|
+
t.truthy(state);
|
|
9
|
+
t.false(state.validateButton);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('should return state directly when there is no corresponding action handler + have an initial state', t => {
|
|
13
|
+
const state = reducer(undefined, {type: 'NOPE'} as unknown as PostAnswerRequestAction);
|
|
14
|
+
t.deepEqual(state, initialState);
|
|
15
|
+
});
|
|
@@ -1,82 +1,103 @@
|
|
|
1
|
+
import {qcmSlide} from '../../views/slides/test/fixtures/qcm';
|
|
2
|
+
import {qcmGraphicSlide} from '../../views/slides/test/fixtures/qcm-graphic';
|
|
1
3
|
import {freeTextSlide} from '../../views/slides/test/fixtures/free-text';
|
|
2
|
-
import {
|
|
4
|
+
import {sliderSlide} from '../../views/slides/test/fixtures/slider';
|
|
5
|
+
import {templateSlide} from '../../views/slides/test/fixtures/template';
|
|
6
|
+
import {ProgressionFromAPI, Services, SlideFromAPI} from '../../types/common';
|
|
3
7
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const getSlideFixture = (ref: string): SlideFromAPI => {
|
|
9
|
+
switch (ref) {
|
|
10
|
+
case qcmSlide.universalRef:
|
|
11
|
+
return qcmSlide;
|
|
12
|
+
case qcmGraphicSlide.universalRef:
|
|
13
|
+
return qcmGraphicSlide;
|
|
14
|
+
case freeTextSlide.universalRef:
|
|
15
|
+
return freeTextSlide;
|
|
16
|
+
case templateSlide.universalRef:
|
|
17
|
+
return templateSlide;
|
|
18
|
+
default:
|
|
19
|
+
return sliderSlide;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const fetchSkillsResponse = [
|
|
24
|
+
{
|
|
25
|
+
skillRef: '_skill-ref',
|
|
26
|
+
slidesToReview: 2,
|
|
27
|
+
name: 'skill-test',
|
|
28
|
+
custom: false
|
|
20
29
|
},
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
{
|
|
31
|
+
skillRef: '_skill-ref-2',
|
|
32
|
+
slidesToReview: 2,
|
|
33
|
+
name: 'skill-test-2',
|
|
34
|
+
custom: true
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
export const postProgressionResponse: ProgressionFromAPI = {
|
|
39
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
40
|
+
content: {
|
|
41
|
+
ref: '_skill-ref',
|
|
42
|
+
type: 'skill'
|
|
23
43
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
44
|
+
engine: {
|
|
45
|
+
ref: 'review'
|
|
46
|
+
},
|
|
47
|
+
state: {
|
|
48
|
+
allAnswers: [],
|
|
49
|
+
isCorrect: true,
|
|
50
|
+
nextContent: {
|
|
51
|
+
ref: 'sli_VJYjJnJhg',
|
|
52
|
+
type: 'slide'
|
|
53
|
+
},
|
|
54
|
+
pendingSlides: [],
|
|
55
|
+
slides: [],
|
|
56
|
+
step: {
|
|
57
|
+
current: 1
|
|
58
|
+
},
|
|
59
|
+
stars: 0
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const postAnswerResponse: ProgressionFromAPI = {
|
|
64
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
65
|
+
content: {
|
|
66
|
+
ref: '_skill-ref',
|
|
67
|
+
type: 'skill'
|
|
49
68
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
engine: {
|
|
58
|
-
ref: 'review'
|
|
59
|
-
},
|
|
60
|
-
state: {
|
|
61
|
-
allAnswers: [
|
|
62
|
-
{
|
|
63
|
-
slideRef: 'sli_N1XACJobn',
|
|
64
|
-
isCorrect: true,
|
|
65
|
-
answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
|
|
66
|
-
}
|
|
67
|
-
],
|
|
69
|
+
engine: {
|
|
70
|
+
ref: 'review'
|
|
71
|
+
},
|
|
72
|
+
state: {
|
|
73
|
+
allAnswers: [
|
|
74
|
+
{
|
|
75
|
+
slideRef: 'sli_VJYjJnJhg',
|
|
68
76
|
isCorrect: true,
|
|
69
|
-
|
|
70
|
-
ref: 'sli_VkSQroQnx',
|
|
71
|
-
type: 'slide'
|
|
72
|
-
},
|
|
73
|
-
pendingSlides: [],
|
|
74
|
-
slides: ['sli_N1XACJobn'],
|
|
75
|
-
step: {
|
|
76
|
-
current: 2
|
|
77
|
-
},
|
|
78
|
-
stars: 4
|
|
77
|
+
answer: ['Benchmark']
|
|
79
78
|
}
|
|
80
|
-
|
|
79
|
+
],
|
|
80
|
+
isCorrect: true,
|
|
81
|
+
nextContent: {
|
|
82
|
+
ref: 'sli_VkSQroQnx',
|
|
83
|
+
type: 'slide'
|
|
84
|
+
},
|
|
85
|
+
content: {
|
|
86
|
+
ref: 'sli_VJYjJnJhg',
|
|
87
|
+
type: 'slide'
|
|
88
|
+
},
|
|
89
|
+
pendingSlides: [],
|
|
90
|
+
slides: ['sli_VJYjJnJhg'],
|
|
91
|
+
step: {
|
|
92
|
+
current: 2
|
|
93
|
+
},
|
|
94
|
+
stars: 4
|
|
81
95
|
}
|
|
82
96
|
};
|
|
97
|
+
|
|
98
|
+
export const services: Services = {
|
|
99
|
+
fetchSkills: () => Promise.resolve(fetchSkillsResponse),
|
|
100
|
+
fetchSlide: ref => Promise.resolve({...getSlideFixture(ref), universalRef: ref, id: ref}),
|
|
101
|
+
postProgression: () => Promise.resolve(postProgressionResponse),
|
|
102
|
+
postAnswer: () => Promise.resolve(postAnswerResponse)
|
|
103
|
+
};
|
package/src/types/common.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {SlideIndexes} from '../common';
|
|
2
|
-
import {AnswerUI} from './slides';
|
|
3
|
-
|
|
4
1
|
// TODO use type from components
|
|
5
2
|
type TemplateContextValues = {
|
|
6
3
|
brandTheme?: unknown;
|
|
@@ -172,33 +169,6 @@ export type JWT = {
|
|
|
172
169
|
host: string;
|
|
173
170
|
};
|
|
174
171
|
|
|
175
|
-
type SlideUIAnimations = 'unstack' | 'restack';
|
|
176
|
-
|
|
177
|
-
export type NextUISlide = {
|
|
178
|
-
questionText?: string;
|
|
179
|
-
answerUI?: AnswerUI;
|
|
180
|
-
hidden?: boolean;
|
|
181
|
-
position?: number;
|
|
182
|
-
animationType?: SlideUIAnimations;
|
|
183
|
-
isCorrect?: boolean;
|
|
184
|
-
endReview?: boolean;
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
export type UISlide = {
|
|
188
|
-
questionText?: string;
|
|
189
|
-
answerUI?: AnswerUI;
|
|
190
|
-
hidden?: boolean;
|
|
191
|
-
position: number;
|
|
192
|
-
animationType?: SlideUIAnimations;
|
|
193
|
-
isCorrect?: boolean;
|
|
194
|
-
endReview?: boolean;
|
|
195
|
-
nextContent?: NextUISlide;
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export type FinishedSlides = {
|
|
199
|
-
[key in SlideIndexes]?: true;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
172
|
export type WithRequired<T, K extends keyof T> = T & {
|
|
203
173
|
// the "-" is a Mapping Modifier, removes optionality from a prop
|
|
204
174
|
[P in K]-?: T[P];
|
|
@@ -28,11 +28,7 @@ type SkillsProps = NoSkillsProps & {
|
|
|
28
28
|
|
|
29
29
|
export {SkillsProps};
|
|
30
30
|
|
|
31
|
-
export const mapStateToSkillsProps = (state: StoreState): SkillsProps
|
|
32
|
-
if (!state.data.skills) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
31
|
+
export const mapStateToSkillsProps = (state: StoreState): SkillsProps => {
|
|
36
32
|
return {
|
|
37
33
|
title: '@todo title',
|
|
38
34
|
titleNoSkills: '@todo titleNoSkills',
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import map from 'lodash/fp/map';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import {StoreState} from '../../../reducers';
|
|
5
|
+
import {mapStateToSkillsProps} from '..';
|
|
6
|
+
|
|
7
|
+
test('should create initial props when there are no skills on the state', t => {
|
|
8
|
+
const state: StoreState = {
|
|
9
|
+
data: {
|
|
10
|
+
progression: null,
|
|
11
|
+
skills: [],
|
|
12
|
+
slides: {},
|
|
13
|
+
token: '1234'
|
|
14
|
+
},
|
|
15
|
+
ui: {
|
|
16
|
+
currentSlideRef: '',
|
|
17
|
+
navigation: ['loader', 'skills'],
|
|
18
|
+
answers: [],
|
|
19
|
+
slide: {
|
|
20
|
+
validateButton: false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const props = mapStateToSkillsProps(state);
|
|
26
|
+
|
|
27
|
+
t.deepEqual(props, {
|
|
28
|
+
title: '@todo title',
|
|
29
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
30
|
+
textNoSkills: '@todo textNoSkills',
|
|
31
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
32
|
+
isLoading: false,
|
|
33
|
+
isLoadingAriaLabel: '@todo loading',
|
|
34
|
+
listSkills: []
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('should create initial props when skills on the state', t => {
|
|
39
|
+
const state: StoreState = {
|
|
40
|
+
data: {
|
|
41
|
+
progression: null,
|
|
42
|
+
skills: [
|
|
43
|
+
{
|
|
44
|
+
skillRef: '_skill-ref',
|
|
45
|
+
slidesToReview: 2,
|
|
46
|
+
name: 'skill-test',
|
|
47
|
+
custom: false
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
skillRef: '_skill-ref-2',
|
|
51
|
+
slidesToReview: 5,
|
|
52
|
+
name: 'skill-test-2',
|
|
53
|
+
custom: true
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
slides: {},
|
|
57
|
+
token: '1234'
|
|
58
|
+
},
|
|
59
|
+
ui: {
|
|
60
|
+
currentSlideRef: '',
|
|
61
|
+
navigation: ['loader', 'skills'],
|
|
62
|
+
answers: [],
|
|
63
|
+
slide: {
|
|
64
|
+
validateButton: false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const props = mapStateToSkillsProps(state);
|
|
70
|
+
|
|
71
|
+
t.deepEqual(omit('listSkills', props), {
|
|
72
|
+
title: '@todo title',
|
|
73
|
+
titleNoSkills: '@todo titleNoSkills',
|
|
74
|
+
textNoSkills: '@todo textNoSkills',
|
|
75
|
+
iconSkillAriaLabel: '@todo iconSkillAriaLabel',
|
|
76
|
+
isLoading: false,
|
|
77
|
+
isLoadingAriaLabel: '@todo loading'
|
|
78
|
+
});
|
|
79
|
+
t.deepEqual(map(omit('onClick'), props.listSkills), [
|
|
80
|
+
{
|
|
81
|
+
'aria-label': '',
|
|
82
|
+
isCustom: false,
|
|
83
|
+
skillTitle: 'skill-test',
|
|
84
|
+
skillAriaLabel: '@todo skill aria label',
|
|
85
|
+
buttonLabel: '@todo button',
|
|
86
|
+
buttonAriaLabel: '@todo button aria label',
|
|
87
|
+
reviseLabel: '@todo revise',
|
|
88
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
'aria-label': '',
|
|
92
|
+
isCustom: true,
|
|
93
|
+
skillTitle: 'skill-test-2',
|
|
94
|
+
skillAriaLabel: '@todo skill aria label',
|
|
95
|
+
buttonLabel: '@todo button',
|
|
96
|
+
buttonAriaLabel: '@todo button aria label',
|
|
97
|
+
reviseLabel: '@todo revise',
|
|
98
|
+
reviseAriaLabel: '@todo revise aria label'
|
|
99
|
+
}
|
|
100
|
+
]);
|
|
101
|
+
});
|