@coorpacademy/app-review 0.2.4 → 0.2.5
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/post-answer.js +4 -2
- package/es/actions/api/test/fetch-correction.test.js +2 -1
- package/es/actions/api/test/fetch-skills.test.js +2 -1
- package/es/actions/api/test/fetch-slide.test.js +2 -1
- package/es/actions/api/test/post-answer.test.js +32 -10
- package/es/actions/api/test/post-progression.test.js +2 -1
- package/es/actions/data/test/token.test.js +2 -1
- package/es/actions/test/create-test-store.d.ts +1 -1
- package/es/actions/ui/answers.js +13 -6
- package/es/actions/ui/test/answers.test.js +17 -1
- package/es/actions/ui/test/slides.test.js +2 -1
- package/es/reducers/data/index.d.ts +4 -2
- package/es/reducers/data/index.js +2 -6
- package/es/reducers/index.d.ts +2 -1
- package/es/reducers/ui/index.d.ts +1 -1
- package/es/reducers/ui/slide.d.ts +3 -1
- package/es/reducers/ui/slide.js +5 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/types/slides.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +4 -2
- package/es/views/slides/map-api-slide-to-ui.js +8 -7
- package/es/views/slides/test/fixtures/qcm-graphic.js +4 -2
- package/es/views/slides/test/fixtures/qcm.js +4 -4
- package/es/views/slides/test/index.test.js +20 -10
- package/es/views/slides/test/slide.free-text.on-change.test.d.ts +1 -0
- package/es/views/slides/test/slide.free-text.on-change.test.js +69 -0
- package/es/views/slides/test/slide.qcm-drag.on-click.test.d.ts +1 -0
- package/es/views/slides/test/slide.qcm-drag.on-click.test.js +69 -0
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +1 -0
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +69 -0
- package/es/views/slides/test/slide.qcm.on-click.test.d.ts +1 -0
- package/es/views/slides/test/slide.qcm.on-click.test.js +71 -0
- package/es/views/slides/test/slide.slider.on-change.test.d.ts +1 -0
- package/es/views/slides/test/slide.slider.on-change.test.js +70 -0
- package/es/views/slides/test/slide.template.on-change.test.js +2 -1
- package/lib/actions/api/post-answer.js +9 -5
- package/lib/actions/api/test/fetch-correction.test.js +2 -1
- package/lib/actions/api/test/fetch-skills.test.js +2 -1
- package/lib/actions/api/test/fetch-slide.test.js +2 -1
- package/lib/actions/api/test/post-answer.test.js +45 -14
- package/lib/actions/api/test/post-progression.test.js +2 -1
- package/lib/actions/data/test/token.test.js +2 -1
- package/lib/actions/test/create-test-store.d.ts +1 -1
- package/lib/actions/ui/answers.js +13 -6
- package/lib/actions/ui/test/answers.test.js +43 -1
- package/lib/actions/ui/test/slides.test.js +2 -1
- package/lib/reducers/data/index.d.ts +4 -2
- package/lib/reducers/data/index.js +2 -6
- package/lib/reducers/index.d.ts +2 -1
- package/lib/reducers/ui/index.d.ts +1 -1
- package/lib/reducers/ui/slide.d.ts +3 -1
- package/lib/reducers/ui/slide.js +5 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/types/slides.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +4 -2
- package/lib/views/slides/map-api-slide-to-ui.js +8 -7
- package/lib/views/slides/test/fixtures/qcm-graphic.js +4 -2
- package/lib/views/slides/test/fixtures/qcm.js +4 -4
- package/lib/views/slides/test/index.test.js +20 -10
- package/lib/views/slides/test/slide.free-text.on-change.test.d.ts +1 -0
- package/lib/views/slides/test/slide.free-text.on-change.test.js +71 -0
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.d.ts +1 -0
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +71 -0
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +1 -0
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +71 -0
- package/lib/views/slides/test/slide.qcm.on-click.test.d.ts +1 -0
- package/lib/views/slides/test/slide.qcm.on-click.test.js +73 -0
- package/lib/views/slides/test/slide.slider.on-change.test.d.ts +1 -0
- package/lib/views/slides/test/slide.slider.on-change.test.js +72 -0
- package/lib/views/slides/test/slide.template.on-change.test.js +2 -1
- package/package.json +3 -3
- package/src/actions/api/post-answer.ts +4 -2
- package/src/actions/api/test/fetch-correction.test.ts +2 -1
- package/src/actions/api/test/fetch-skills.test.ts +2 -1
- package/src/actions/api/test/fetch-slide.test.ts +2 -1
- package/src/actions/api/test/post-answer.test.ts +51 -10
- package/src/actions/api/test/post-progression.test.ts +2 -1
- package/src/actions/data/test/token.test.ts +2 -1
- package/src/actions/test/create-test-store.ts +1 -1
- package/src/actions/ui/answers.ts +15 -6
- package/src/actions/ui/test/answers.test.ts +33 -2
- package/src/actions/ui/test/slides.test.ts +2 -1
- package/src/reducers/data/index.ts +3 -7
- package/src/reducers/ui/slide.ts +7 -1
- package/src/reducers/ui/test/slide.test.ts +13 -0
- package/src/types/slides.ts +1 -0
- package/src/views/skills/test/skills.test.ts +4 -2
- package/src/views/slides/map-api-slide-to-ui.ts +8 -7
- package/src/views/slides/test/fixtures/qcm-graphic.ts +4 -2
- package/src/views/slides/test/fixtures/qcm.ts +5 -4
- package/src/views/slides/test/index.test.ts +20 -10
- package/src/views/slides/test/slide.free-text.on-change.test.ts +79 -0
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +78 -0
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +79 -0
- package/src/views/slides/test/slide.qcm.on-click.test.ts +80 -0
- package/src/views/slides/test/slide.slider.on-change.test.ts +80 -0
- package/src/views/slides/test/slide.template.on-change.test.ts +2 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import omit from 'lodash/fp/omit';
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import { mapStateToSlidesProps } from '..';
|
|
5
|
+
import { services } from '../../../test/util/services.mock';
|
|
6
|
+
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
7
|
+
import { EDIT_BASIC } from '../../../actions/ui/answers';
|
|
8
|
+
import { freeTextSlide } from './fixtures/free-text';
|
|
9
|
+
const progression = {
|
|
10
|
+
_id: '123456789123',
|
|
11
|
+
content: { type: 'skill', ref: '_skill-ref' },
|
|
12
|
+
engine: {
|
|
13
|
+
ref: 'review'
|
|
14
|
+
},
|
|
15
|
+
state: {
|
|
16
|
+
allAnswers: [],
|
|
17
|
+
isCorrect: true,
|
|
18
|
+
nextContent: {
|
|
19
|
+
ref: freeTextSlide._id,
|
|
20
|
+
type: 'slide'
|
|
21
|
+
},
|
|
22
|
+
pendingSlides: [],
|
|
23
|
+
slides: [],
|
|
24
|
+
step: {
|
|
25
|
+
current: 1
|
|
26
|
+
},
|
|
27
|
+
stars: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const initialState = {
|
|
31
|
+
data: {
|
|
32
|
+
progression,
|
|
33
|
+
slides: {
|
|
34
|
+
[freeTextSlide._id]: freeTextSlide
|
|
35
|
+
},
|
|
36
|
+
skills: [],
|
|
37
|
+
token: '1234',
|
|
38
|
+
corrections: {}
|
|
39
|
+
},
|
|
40
|
+
ui: {
|
|
41
|
+
currentSlideRef: freeTextSlide._id,
|
|
42
|
+
navigation: ['skills', 'slides'],
|
|
43
|
+
answers: [],
|
|
44
|
+
slide: {
|
|
45
|
+
validateButton: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
test('should dispatch EDIT_BASIC action via the property onChange of a Free Text slide', t => {
|
|
50
|
+
t.plan(2);
|
|
51
|
+
const expectedActions = [
|
|
52
|
+
{
|
|
53
|
+
type: EDIT_BASIC,
|
|
54
|
+
payload: ['My Answer']
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
|
+
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
60
|
+
hidden: false,
|
|
61
|
+
position: 0,
|
|
62
|
+
loading: false,
|
|
63
|
+
parentContentTitle: 'From "Developing the review app" course',
|
|
64
|
+
questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
|
|
65
|
+
});
|
|
66
|
+
const SlideProps = props.stack.slides['0'].answerUI?.model;
|
|
67
|
+
const onChange = get('onChange', SlideProps);
|
|
68
|
+
onChange('My Answer');
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import omit from 'lodash/fp/omit';
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import { mapStateToSlidesProps } from '..';
|
|
5
|
+
import { services } from '../../../test/util/services.mock';
|
|
6
|
+
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
7
|
+
import { EDIT_QCM_DRAG } from '../../../actions/ui/answers';
|
|
8
|
+
import { qcmDragSlide } from './fixtures/qcm-drag';
|
|
9
|
+
const progression = {
|
|
10
|
+
_id: '123456789123',
|
|
11
|
+
content: { type: 'skill', ref: '_skill-ref' },
|
|
12
|
+
engine: {
|
|
13
|
+
ref: 'review'
|
|
14
|
+
},
|
|
15
|
+
state: {
|
|
16
|
+
allAnswers: [],
|
|
17
|
+
isCorrect: true,
|
|
18
|
+
nextContent: {
|
|
19
|
+
ref: qcmDragSlide._id,
|
|
20
|
+
type: 'slide'
|
|
21
|
+
},
|
|
22
|
+
pendingSlides: [],
|
|
23
|
+
slides: [],
|
|
24
|
+
step: {
|
|
25
|
+
current: 1
|
|
26
|
+
},
|
|
27
|
+
stars: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const initialState = {
|
|
31
|
+
data: {
|
|
32
|
+
progression,
|
|
33
|
+
slides: {
|
|
34
|
+
[qcmDragSlide._id]: qcmDragSlide
|
|
35
|
+
},
|
|
36
|
+
skills: [],
|
|
37
|
+
token: '1234',
|
|
38
|
+
corrections: {}
|
|
39
|
+
},
|
|
40
|
+
ui: {
|
|
41
|
+
currentSlideRef: qcmDragSlide._id,
|
|
42
|
+
navigation: ['skills', 'slides'],
|
|
43
|
+
answers: [],
|
|
44
|
+
slide: {
|
|
45
|
+
validateButton: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Drag slide', t => {
|
|
50
|
+
t.plan(2);
|
|
51
|
+
const expectedActions = [
|
|
52
|
+
{
|
|
53
|
+
type: EDIT_QCM_DRAG,
|
|
54
|
+
payload: ['La démoralisation']
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
|
+
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
60
|
+
hidden: false,
|
|
61
|
+
position: 0,
|
|
62
|
+
loading: false,
|
|
63
|
+
parentContentTitle: 'From "Using redux" chapter',
|
|
64
|
+
questionText: "Remettez dans l'ordre les quatre étapes du burn out."
|
|
65
|
+
});
|
|
66
|
+
const SlideProps = props.stack.slides['0'].answerUI?.model;
|
|
67
|
+
const onClick = get(['0', 'onClick'], SlideProps.answers);
|
|
68
|
+
onClick();
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import omit from 'lodash/fp/omit';
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import { mapStateToSlidesProps } from '..';
|
|
5
|
+
import { services } from '../../../test/util/services.mock';
|
|
6
|
+
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
7
|
+
import { EDIT_QCM_GRAPHIC } from '../../../actions/ui/answers';
|
|
8
|
+
import { qcmGraphicSlide } from './fixtures/qcm-graphic';
|
|
9
|
+
const progression = {
|
|
10
|
+
_id: '123456789123',
|
|
11
|
+
content: { type: 'skill', ref: '_skill-ref' },
|
|
12
|
+
engine: {
|
|
13
|
+
ref: 'review'
|
|
14
|
+
},
|
|
15
|
+
state: {
|
|
16
|
+
allAnswers: [],
|
|
17
|
+
isCorrect: true,
|
|
18
|
+
nextContent: {
|
|
19
|
+
ref: qcmGraphicSlide._id,
|
|
20
|
+
type: 'slide'
|
|
21
|
+
},
|
|
22
|
+
pendingSlides: [],
|
|
23
|
+
slides: [],
|
|
24
|
+
step: {
|
|
25
|
+
current: 1
|
|
26
|
+
},
|
|
27
|
+
stars: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const initialState = {
|
|
31
|
+
data: {
|
|
32
|
+
progression,
|
|
33
|
+
slides: {
|
|
34
|
+
[qcmGraphicSlide._id]: qcmGraphicSlide
|
|
35
|
+
},
|
|
36
|
+
skills: [],
|
|
37
|
+
token: '1234',
|
|
38
|
+
corrections: {}
|
|
39
|
+
},
|
|
40
|
+
ui: {
|
|
41
|
+
currentSlideRef: qcmGraphicSlide._id,
|
|
42
|
+
navigation: ['skills', 'slides'],
|
|
43
|
+
answers: [],
|
|
44
|
+
slide: {
|
|
45
|
+
validateButton: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM Graphic slide', t => {
|
|
50
|
+
t.plan(2);
|
|
51
|
+
const expectedActions = [
|
|
52
|
+
{
|
|
53
|
+
type: EDIT_QCM_GRAPHIC,
|
|
54
|
+
payload: ['Faux']
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
|
+
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
60
|
+
hidden: false,
|
|
61
|
+
position: 0,
|
|
62
|
+
loading: false,
|
|
63
|
+
parentContentTitle: 'From "Developing the review app" course',
|
|
64
|
+
questionText: 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?'
|
|
65
|
+
});
|
|
66
|
+
const SlideProps = props.stack.slides['0'].answerUI?.model;
|
|
67
|
+
const onClick = get(['1', 'onClick'], SlideProps.answers);
|
|
68
|
+
onClick();
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import omit from 'lodash/fp/omit';
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import { mapStateToSlidesProps } from '..';
|
|
5
|
+
import { services } from '../../../test/util/services.mock';
|
|
6
|
+
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
7
|
+
import { EDIT_QCM } from '../../../actions/ui/answers';
|
|
8
|
+
import { qcmSlide } from './fixtures/qcm';
|
|
9
|
+
const progression = {
|
|
10
|
+
_id: '123456789123',
|
|
11
|
+
content: { type: 'skill', ref: '_skill-ref' },
|
|
12
|
+
engine: {
|
|
13
|
+
ref: 'review'
|
|
14
|
+
},
|
|
15
|
+
state: {
|
|
16
|
+
allAnswers: [],
|
|
17
|
+
isCorrect: true,
|
|
18
|
+
nextContent: {
|
|
19
|
+
ref: qcmSlide._id,
|
|
20
|
+
type: 'slide'
|
|
21
|
+
},
|
|
22
|
+
pendingSlides: [],
|
|
23
|
+
slides: [],
|
|
24
|
+
step: {
|
|
25
|
+
current: 1
|
|
26
|
+
},
|
|
27
|
+
stars: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const initialState = {
|
|
31
|
+
data: {
|
|
32
|
+
progression,
|
|
33
|
+
slides: {
|
|
34
|
+
[qcmSlide._id]: qcmSlide
|
|
35
|
+
},
|
|
36
|
+
skills: [],
|
|
37
|
+
token: '1234',
|
|
38
|
+
corrections: {}
|
|
39
|
+
},
|
|
40
|
+
ui: {
|
|
41
|
+
currentSlideRef: qcmSlide._id,
|
|
42
|
+
navigation: ['skills', 'slides'],
|
|
43
|
+
answers: [],
|
|
44
|
+
slide: {
|
|
45
|
+
validateButton: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
test('should dispatch EDIT_QCM action via the property onClick of a QCM slide', t => {
|
|
50
|
+
t.plan(2);
|
|
51
|
+
const expectedActions = [
|
|
52
|
+
{
|
|
53
|
+
type: EDIT_QCM,
|
|
54
|
+
payload: [
|
|
55
|
+
"Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
60
|
+
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
61
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
62
|
+
hidden: false,
|
|
63
|
+
position: 0,
|
|
64
|
+
loading: false,
|
|
65
|
+
parentContentTitle: 'From "Developing the review app" course',
|
|
66
|
+
questionText: "Après la vente d'un NFT, son créateur peut-il toucher de l'argent ?"
|
|
67
|
+
});
|
|
68
|
+
const SlideProps = props.stack.slides['0'].answerUI?.model;
|
|
69
|
+
const onClick = get(['1', 'onClick'], SlideProps.answers);
|
|
70
|
+
onClick();
|
|
71
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import omit from 'lodash/fp/omit';
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import { mapStateToSlidesProps } from '..';
|
|
5
|
+
import { services } from '../../../test/util/services.mock';
|
|
6
|
+
import { createTestStore } from '../../../actions/test/create-test-store';
|
|
7
|
+
import { EDIT_SLIDER } from '../../../actions/ui/answers';
|
|
8
|
+
import { sliderSlide } from './fixtures/slider';
|
|
9
|
+
const progression = {
|
|
10
|
+
_id: '123456789123',
|
|
11
|
+
content: { type: 'skill', ref: '_skill-ref' },
|
|
12
|
+
engine: {
|
|
13
|
+
ref: 'review'
|
|
14
|
+
},
|
|
15
|
+
state: {
|
|
16
|
+
allAnswers: [],
|
|
17
|
+
isCorrect: true,
|
|
18
|
+
nextContent: {
|
|
19
|
+
ref: sliderSlide._id,
|
|
20
|
+
type: 'slide'
|
|
21
|
+
},
|
|
22
|
+
pendingSlides: [],
|
|
23
|
+
slides: [],
|
|
24
|
+
step: {
|
|
25
|
+
current: 1
|
|
26
|
+
},
|
|
27
|
+
stars: 0
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const initialState = {
|
|
31
|
+
data: {
|
|
32
|
+
progression,
|
|
33
|
+
slides: {
|
|
34
|
+
[sliderSlide._id]: sliderSlide
|
|
35
|
+
},
|
|
36
|
+
skills: [],
|
|
37
|
+
token: '1234',
|
|
38
|
+
corrections: {}
|
|
39
|
+
},
|
|
40
|
+
ui: {
|
|
41
|
+
currentSlideRef: sliderSlide._id,
|
|
42
|
+
navigation: ['skills', 'slides'],
|
|
43
|
+
answers: [],
|
|
44
|
+
slide: {
|
|
45
|
+
validateButton: false
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
test('should dispatch EDIT_SLIDER action via the property onChange of a Slider slide', t => {
|
|
50
|
+
t.plan(2);
|
|
51
|
+
const expectedActions = [
|
|
52
|
+
{
|
|
53
|
+
type: EDIT_SLIDER,
|
|
54
|
+
payload: ['5']
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
|
|
58
|
+
const props = mapStateToSlidesProps(getState(), dispatch);
|
|
59
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
60
|
+
hidden: false,
|
|
61
|
+
position: 0,
|
|
62
|
+
loading: false,
|
|
63
|
+
parentContentTitle: 'From "Developing the review app" course',
|
|
64
|
+
questionText: 'En combien d’années la communauté de communes du Thouarsais est-elle passée de zéro à un tiers d’énergies renouvelables ?'
|
|
65
|
+
});
|
|
66
|
+
const SlideProps = props.stack.slides['0'].answerUI?.model;
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
68
|
+
const onChange = get('onChange', SlideProps);
|
|
69
|
+
onChange(0.29339261968085106);
|
|
70
|
+
});
|
|
@@ -36,6 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
};
|
|
37
37
|
import buildTask from '@coorpacademy/redux-task';
|
|
38
38
|
import get from 'lodash/fp/get';
|
|
39
|
+
import { fetchCorrection } from './fetch-correction';
|
|
39
40
|
import { fetchSlide } from './fetch-slide';
|
|
40
41
|
export var POST_ANSWER_REQUEST = '@@answer/POST_REQUEST';
|
|
41
42
|
export var POST_ANSWER_SUCCESS = '@@answer/POST_SUCCESS';
|
|
@@ -50,9 +51,9 @@ export var postAnswer = function (dispatch, getState, _a) {
|
|
|
50
51
|
state = getState();
|
|
51
52
|
token = get(['data', 'token'], state);
|
|
52
53
|
answer = get(['ui', 'answers'], state);
|
|
53
|
-
progression =
|
|
54
|
+
progression = get(['data', 'progression'], state);
|
|
54
55
|
if (!progression)
|
|
55
|
-
throw new Error('
|
|
56
|
+
throw new Error('Cannot answer a question of an inexistent progression');
|
|
56
57
|
action = buildTask({
|
|
57
58
|
types: [POST_ANSWER_REQUEST, POST_ANSWER_SUCCESS, POST_ANSWER_FAILURE],
|
|
58
59
|
task: function () { return services.postAnswer(progression, token, answer); }
|
|
@@ -60,14 +61,17 @@ export var postAnswer = function (dispatch, getState, _a) {
|
|
|
60
61
|
return [4 /*yield*/, dispatch(action)];
|
|
61
62
|
case 1:
|
|
62
63
|
response = _b.sent();
|
|
63
|
-
if (!(response.type === POST_ANSWER_SUCCESS)) return [3 /*break*/,
|
|
64
|
+
if (!(response.type === POST_ANSWER_SUCCESS)) return [3 /*break*/, 4];
|
|
64
65
|
updatedProgression = response.payload;
|
|
65
66
|
slideRef = updatedProgression.state.nextContent.ref;
|
|
66
67
|
return [4 /*yield*/, dispatch(fetchSlide(slideRef))];
|
|
67
68
|
case 2:
|
|
68
69
|
_b.sent();
|
|
69
|
-
|
|
70
|
-
case 3:
|
|
70
|
+
return [4 /*yield*/, dispatch(fetchCorrection)];
|
|
71
|
+
case 3:
|
|
72
|
+
_b.sent();
|
|
73
|
+
_b.label = 4;
|
|
74
|
+
case 4: return [2 /*return*/];
|
|
71
75
|
}
|
|
72
76
|
});
|
|
73
77
|
});
|
|
@@ -63,7 +63,8 @@ var initialState = {
|
|
|
63
63
|
_a[qcmSlide.universalRef] = qcmSlide,
|
|
64
64
|
_a),
|
|
65
65
|
skills: [{ skillRef: skillRef, custom: false, name: skillRef, slidesToReview: 5 }],
|
|
66
|
-
token: '1234'
|
|
66
|
+
token: '1234',
|
|
67
|
+
corrections: {}
|
|
67
68
|
},
|
|
68
69
|
ui: {
|
|
69
70
|
currentSlideRef: freeTextSlide._id,
|
|
@@ -48,12 +48,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
48
48
|
var _a;
|
|
49
49
|
import test from 'ava';
|
|
50
50
|
import { createTestStore } from '../../test/create-test-store';
|
|
51
|
-
import { postAnswerResponses, services } from '../../../test/util/services.mock';
|
|
51
|
+
import { getChoicesCorrection, postAnswerResponses, services } from '../../../test/util/services.mock';
|
|
52
52
|
import { postAnswer, POST_ANSWER_FAILURE, POST_ANSWER_REQUEST, POST_ANSWER_SUCCESS } from '../post-answer';
|
|
53
|
+
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
54
|
+
import { CORRECTION_FETCH_REQUEST, CORRECTION_FETCH_SUCCESS } from '../fetch-correction';
|
|
53
55
|
import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../fetch-slide';
|
|
54
56
|
import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
|
|
55
|
-
import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
|
|
56
|
-
import { SET_CURRENT_SLIDE } from '../../ui/slides';
|
|
57
57
|
var progressionId = '123456789123';
|
|
58
58
|
var skillRef = '_skill-ref';
|
|
59
59
|
var answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
@@ -84,7 +84,8 @@ var initialState = {
|
|
|
84
84
|
_a[freeTextSlide._id] = freeTextSlide,
|
|
85
85
|
_a),
|
|
86
86
|
skills: [{ skillRef: skillRef, custom: false, name: skillRef, slidesToReview: 5 }],
|
|
87
|
-
token: '1234'
|
|
87
|
+
token: '1234',
|
|
88
|
+
corrections: {}
|
|
88
89
|
},
|
|
89
90
|
ui: {
|
|
90
91
|
currentSlideRef: freeTextSlide._id,
|
|
@@ -95,30 +96,45 @@ var initialState = {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
};
|
|
98
|
-
test('should dispatch
|
|
99
|
-
var expectedActions, dispatch;
|
|
100
|
-
return __generator(this, function (
|
|
101
|
-
switch (
|
|
99
|
+
test('should dispatch post-answer, fetch-slide and fetch-correction actions when the answer is submitted', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
100
|
+
var expectedActions, _a, dispatch, getState, state;
|
|
101
|
+
return __generator(this, function (_b) {
|
|
102
|
+
switch (_b.label) {
|
|
102
103
|
case 0:
|
|
103
|
-
t.plan(
|
|
104
|
+
t.plan(8);
|
|
104
105
|
expectedActions = [
|
|
105
106
|
{ type: POST_ANSWER_REQUEST },
|
|
106
107
|
{
|
|
107
108
|
type: POST_ANSWER_SUCCESS,
|
|
108
109
|
payload: postAnswerResponses[freeTextSlide._id]
|
|
109
110
|
},
|
|
110
|
-
{
|
|
111
|
+
{
|
|
112
|
+
type: SLIDE_FETCH_REQUEST,
|
|
113
|
+
meta: {
|
|
114
|
+
slideRef: qcmGraphicSlide._id
|
|
115
|
+
}
|
|
116
|
+
},
|
|
111
117
|
{
|
|
112
118
|
type: SLIDE_FETCH_SUCCESS,
|
|
113
|
-
meta: {
|
|
119
|
+
meta: {
|
|
120
|
+
slideRef: qcmGraphicSlide._id
|
|
121
|
+
},
|
|
114
122
|
payload: qcmGraphicSlide
|
|
115
123
|
},
|
|
116
|
-
{ type:
|
|
124
|
+
{ type: CORRECTION_FETCH_REQUEST, meta: { slideRef: freeTextSlide._id } },
|
|
125
|
+
{
|
|
126
|
+
type: CORRECTION_FETCH_SUCCESS,
|
|
127
|
+
meta: { slideRef: freeTextSlide._id },
|
|
128
|
+
payload: getChoicesCorrection(freeTextSlide._id)
|
|
129
|
+
}
|
|
117
130
|
];
|
|
118
|
-
|
|
131
|
+
_a = createTestStore(t, initialState, services, expectedActions), dispatch = _a.dispatch, getState = _a.getState;
|
|
119
132
|
return [4 /*yield*/, dispatch(postAnswer)];
|
|
120
133
|
case 1:
|
|
121
|
-
|
|
134
|
+
_b.sent();
|
|
135
|
+
state = getState();
|
|
136
|
+
t.false(state.ui.slide.validateButton);
|
|
137
|
+
t.true(state.ui.slide.animateCorrectionPopin);
|
|
122
138
|
return [2 /*return*/];
|
|
123
139
|
}
|
|
124
140
|
});
|
|
@@ -148,3 +164,18 @@ test('should dispatch POST_ANSWER_REQUEST, then POST_ANSWER_FAILURE on error', f
|
|
|
148
164
|
}
|
|
149
165
|
});
|
|
150
166
|
}); });
|
|
167
|
+
test('should not dispatch any action && throw an error if progression does not exist', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
168
|
+
var expectedActions, dispatch;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
switch (_a.label) {
|
|
171
|
+
case 0:
|
|
172
|
+
t.plan(1);
|
|
173
|
+
expectedActions = [];
|
|
174
|
+
dispatch = createTestStore(t, __assign(__assign({}, initialState), { data: __assign(__assign({}, initialState.data), { progression: null }) }), services, expectedActions).dispatch;
|
|
175
|
+
return [4 /*yield*/, t.throwsAsync(function () { return dispatch(postAnswer); }, undefined, 'Cannot answer a question of an inexistent progression')];
|
|
176
|
+
case 1:
|
|
177
|
+
_a.sent();
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}); });
|
|
@@ -2,4 +2,4 @@ import type { ExecutionContext } from 'ava';
|
|
|
2
2
|
import { AnyAction, Store } from 'redux';
|
|
3
3
|
import { StoreState } from '../../reducers';
|
|
4
4
|
import { Services } from '../../types/common';
|
|
5
|
-
export declare const createTestStore: (t: ExecutionContext, initialState: StoreState, services: Services, actions: AnyAction[]) => Store
|
|
5
|
+
export declare const createTestStore: (t: ExecutionContext, initialState: StoreState, services: Services, actions: AnyAction[]) => Store<StoreState, AnyAction>;
|
|
@@ -7,7 +7,10 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
7
7
|
}
|
|
8
8
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
9
|
};
|
|
10
|
-
import
|
|
10
|
+
import flatten from 'lodash/fp/flatten';
|
|
11
|
+
import get from 'lodash/fp/get';
|
|
12
|
+
import includes from 'lodash/fp/includes';
|
|
13
|
+
import pull from 'lodash/fp/pull';
|
|
11
14
|
export var EDIT_QCM = '@@answer/EDIT_QCM';
|
|
12
15
|
export var EDIT_QCM_GRAPHIC = '@@answer/EDIT_QCM_GRAPHIC';
|
|
13
16
|
export var EDIT_QCM_DRAG = '@@answer/EDIT_QCM_DRAG';
|
|
@@ -36,18 +39,22 @@ var buildAnswer = function (userAnswers, questionType, newValue) {
|
|
|
36
39
|
case 'slider':
|
|
37
40
|
case 'template':
|
|
38
41
|
return newValue;
|
|
39
|
-
default:
|
|
42
|
+
/* istanbul ignore next */ default:
|
|
40
43
|
return [];
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
46
|
export var editAnswer = function (answer) {
|
|
44
47
|
return function (dispatch, getState) {
|
|
45
48
|
var state = getState();
|
|
46
|
-
var currentSlideRef = get(['ui', 'currentSlideRef']
|
|
47
|
-
var userAnswers = get(['ui', 'answers']
|
|
48
|
-
var slide = get(['data', 'slides', currentSlideRef]
|
|
49
|
-
|
|
49
|
+
var currentSlideRef = get(['ui', 'currentSlideRef'], state);
|
|
50
|
+
var userAnswers = get(['ui', 'answers'], state);
|
|
51
|
+
var slide = get(['data', 'slides', currentSlideRef], state);
|
|
52
|
+
if (!slide)
|
|
53
|
+
throw new Error('No slide was found');
|
|
54
|
+
var questionType = get(['question', 'type'], slide);
|
|
50
55
|
var type = get(questionType, ANSWER_EDIT);
|
|
56
|
+
if (!type)
|
|
57
|
+
throw new Error("Question type ".concat(questionType, " is not supported"));
|
|
51
58
|
return dispatch({
|
|
52
59
|
type: type,
|
|
53
60
|
payload: buildAnswer(userAnswers, questionType, answer)
|