@coorpacademy/app-review 0.1.17 → 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.
Files changed (63) hide show
  1. package/es/actions/api/post-answer.d.ts +5 -1
  2. package/es/actions/ui/answers.d.ts +1 -1
  3. package/es/actions/ui/answers.js +6 -4
  4. package/es/actions/ui/test/answers.test.js +15 -5
  5. package/es/reducers/data/index.d.ts +1 -1
  6. package/es/reducers/data/progression.d.ts +2 -1
  7. package/es/reducers/data/progression.js +2 -0
  8. package/es/reducers/data/test/progression.test.js +11 -26
  9. package/es/reducers/index.d.ts +1 -1
  10. package/es/reducers/ui/index.d.ts +1 -1
  11. package/es/reducers/ui/test/answers.test.js +4 -0
  12. package/es/test/util/services.mock.d.ts +1 -0
  13. package/es/test/util/services.mock.js +4 -1
  14. package/es/views/slides/index.js +1 -1
  15. package/es/views/slides/map-api-slide-to-ui.js +26 -22
  16. package/es/views/slides/test/fixtures/template.d.ts +4 -0
  17. package/es/views/slides/test/fixtures/{select-template.js → template.js} +82 -4
  18. package/es/views/slides/test/index.test.js +239 -0
  19. package/es/views/slides/test/map-api-slide-to-ui.test.js +4 -10
  20. package/es/views/slides/test/slide.template.on-change.test.d.ts +1 -0
  21. package/es/views/slides/test/slide.template.on-change.test.js +79 -0
  22. package/lib/actions/api/post-answer.d.ts +5 -1
  23. package/lib/actions/ui/answers.d.ts +1 -1
  24. package/lib/actions/ui/answers.js +6 -4
  25. package/lib/actions/ui/test/answers.test.js +24 -5
  26. package/lib/reducers/data/index.d.ts +1 -1
  27. package/lib/reducers/data/progression.d.ts +2 -1
  28. package/lib/reducers/data/progression.js +2 -0
  29. package/lib/reducers/data/test/progression.test.js +11 -26
  30. package/lib/reducers/index.d.ts +1 -1
  31. package/lib/reducers/ui/index.d.ts +1 -1
  32. package/lib/reducers/ui/test/answers.test.js +4 -0
  33. package/lib/test/util/services.mock.d.ts +1 -0
  34. package/lib/test/util/services.mock.js +4 -1
  35. package/lib/views/slides/index.js +1 -1
  36. package/lib/views/slides/map-api-slide-to-ui.js +34 -28
  37. package/lib/views/slides/test/fixtures/template.d.ts +4 -0
  38. package/lib/views/slides/test/fixtures/{select-template.js → template.js} +82 -4
  39. package/lib/views/slides/test/index.test.js +239 -0
  40. package/lib/views/slides/test/map-api-slide-to-ui.test.js +4 -10
  41. package/lib/views/slides/test/slide.template.on-change.test.d.ts +1 -0
  42. package/lib/views/slides/test/slide.template.on-change.test.js +82 -0
  43. package/package.json +3 -3
  44. package/src/actions/api/post-answer.ts +6 -1
  45. package/src/actions/ui/answers.ts +8 -6
  46. package/src/actions/ui/test/answers.test.ts +17 -5
  47. package/src/reducers/data/progression.ts +3 -1
  48. package/src/reducers/data/test/progression.test.ts +12 -28
  49. package/src/reducers/ui/test/answers.test.ts +5 -0
  50. package/src/test/util/services.mock.ts +4 -1
  51. package/src/views/slides/index.ts +1 -1
  52. package/src/views/slides/map-api-slide-to-ui.ts +63 -30
  53. package/src/views/slides/test/fixtures/{select-template.ts → template.ts} +82 -4
  54. package/src/views/slides/test/index.test.ts +253 -0
  55. package/src/views/slides/test/map-api-slide-to-ui.test.ts +4 -10
  56. package/src/views/slides/test/slide.template.on-change.test.ts +92 -0
  57. package/es/views/slides/test/fixtures/select-template.d.ts +0 -4
  58. package/es/views/slides/test/fixtures/text-template.d.ts +0 -4
  59. package/es/views/slides/test/fixtures/text-template.js +0 -58
  60. package/lib/views/slides/test/fixtures/select-template.d.ts +0 -4
  61. package/lib/views/slides/test/fixtures/text-template.d.ts +0 -4
  62. package/lib/views/slides/test/fixtures/text-template.js +0 -58
  63. package/src/views/slides/test/fixtures/text-template.ts +0 -62
@@ -232,3 +232,242 @@ test('should create initial props when the slide is on the state', t => {
232
232
  }
233
233
  });
234
234
  });
235
+ test('should create props when the next slide is on the state', t => {
236
+ const state = {
237
+ data: {
238
+ progression: {
239
+ _id: '62b1d1087aa12f00253f40ee',
240
+ content: {
241
+ ref: '_skill-ref',
242
+ type: 'skill'
243
+ },
244
+ engine: {
245
+ ref: 'review'
246
+ },
247
+ state: {
248
+ allAnswers: [
249
+ {
250
+ slideRef: 'sli_VJYjJnJhg',
251
+ isCorrect: true,
252
+ answer: ['Benchmark']
253
+ }
254
+ ],
255
+ isCorrect: true,
256
+ nextContent: {
257
+ ref: 'sli_VkSQroQnx',
258
+ type: 'slide'
259
+ },
260
+ content: {
261
+ ref: 'sli_VJYjJnJhg',
262
+ type: 'slide'
263
+ },
264
+ pendingSlides: [],
265
+ slides: ['sli_VJYjJnJhg'],
266
+ step: {
267
+ current: 2
268
+ },
269
+ stars: 4
270
+ }
271
+ },
272
+ skills: [],
273
+ slides: {
274
+ sli_VJYjJnJhg: {
275
+ question: {
276
+ content: {
277
+ media: {
278
+ src: [],
279
+ posters: [],
280
+ subtitles: []
281
+ },
282
+ label: '',
283
+ placeholder: 'Type here',
284
+ id: 'sli_VJYjJnJhg.choice_1'
285
+ },
286
+ type: 'basic',
287
+ header: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?',
288
+ explanation: 'Type your answer.'
289
+ },
290
+ klf: 'To negotiate your salary when being hired, you have to establish a benchmark beforehand. In other words, you should assess the salary to which you aspire by enquiring about the remuneration paid in the same industry, the same region and the same position.',
291
+ tips: 'According to Insee, Paris salaries are 20-25% higher compared with those of the provinces in 2015.',
292
+ universalRef: 'sli_VJYjJnJhg',
293
+ id: 'sli_VJYjJnJhg',
294
+ parentContentTitle: {
295
+ title: 'Developing the review app',
296
+ type: 'course'
297
+ }
298
+ },
299
+ sli_VkSQroQnx: {
300
+ question: {
301
+ content: {
302
+ media: {
303
+ src: [],
304
+ posters: [],
305
+ subtitles: []
306
+ },
307
+ choices: [
308
+ {
309
+ media: {
310
+ src: [
311
+ {
312
+ _id: '624efd915948a7013083e986',
313
+ mimeType: 'image/jpeg',
314
+ url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
315
+ id: '624efd915948a7013083e986'
316
+ }
317
+ ],
318
+ posters: [],
319
+ subtitles: [],
320
+ type: 'img'
321
+ },
322
+ items: [],
323
+ _id: '624efd915948a7013083e985',
324
+ label: 'Vrai',
325
+ value: 'sli_VkSQroQnx.choice_NJesyUo7nx',
326
+ id: '624efd915948a7013083e985'
327
+ },
328
+ {
329
+ media: {
330
+ src: [
331
+ {
332
+ _id: '624efd915948a7013083e988',
333
+ mimeType: 'image/jpeg',
334
+ url: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
335
+ id: '624efd915948a7013083e988'
336
+ }
337
+ ],
338
+ posters: [],
339
+ subtitles: [],
340
+ type: 'img'
341
+ },
342
+ items: [],
343
+ _id: '624efd915948a7013083e987',
344
+ label: 'Faux',
345
+ value: 'sli_VkSQroQnx.choice_VkgayLjX3e',
346
+ id: '624efd915948a7013083e987'
347
+ }
348
+ ]
349
+ },
350
+ type: 'qcmGraphic',
351
+ header: 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?',
352
+ explanation: 'Sélectionnez la bonne réponse.'
353
+ },
354
+ klf: "Il ne faut pas prendre la négociation comme une affaire personnelle, afin de rester centré sur son sujet. Mais cela ne signifie pas être dépourvu de toute émotion, car celles-ci peuvent être de vrais atouts. À condition de réussir à les exprimer sans accuser l'autre d'en être à l'origine.",
355
+ tips: "Pour gérer ses émotions, il faut d'abord les identifier, notamment en analysant ses ressentis physiques et en trouvant l'élément déclencheur.",
356
+ universalRef: 'sli_VkSQroQnx',
357
+ id: 'sli_VkSQroQnx',
358
+ parentContentTitle: {
359
+ title: 'Developing the review app',
360
+ type: 'course'
361
+ }
362
+ }
363
+ },
364
+ token: 'undefined'
365
+ },
366
+ ui: {
367
+ currentSlideRef: 'sli_VJYjJnJhg',
368
+ navigation: ['loader', 'slides'],
369
+ answers: ['My value'],
370
+ slide: {
371
+ validateButton: false
372
+ }
373
+ }
374
+ };
375
+ const props = mapStateToSlidesProps(state, identity);
376
+ t.is(props.congratsProps, undefined);
377
+ t.deepEqual(omit(['onQuitClick'], props.header), {
378
+ 'aria-label': 'aria-header-wrapper',
379
+ closeButtonAriaLabel: 'aria-close-button',
380
+ mode: '__revision_mode',
381
+ skillName: '__agility',
382
+ steps: [
383
+ {
384
+ current: true,
385
+ icon: 'right',
386
+ value: '1'
387
+ },
388
+ {
389
+ // FIX ME: update on PR -> https://trello.com/c/qOSDa8Fm/2715-app-review-props-dynamiques-pour-les-step-items-du-header-bas%C3%A9-sur-le-state
390
+ current: true,
391
+ icon: 'no-answer',
392
+ value: '2'
393
+ },
394
+ {
395
+ current: false,
396
+ icon: 'no-answer',
397
+ value: '3'
398
+ },
399
+ {
400
+ current: false,
401
+ icon: 'no-answer',
402
+ value: '4'
403
+ },
404
+ {
405
+ current: false,
406
+ icon: 'no-answer',
407
+ value: '5'
408
+ }
409
+ ]
410
+ });
411
+ t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
412
+ correctionPopinProps: undefined,
413
+ endReview: false
414
+ });
415
+ t.true(props.stack.validateButton.disabled);
416
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
417
+ hidden: false,
418
+ position: 0,
419
+ loading: false,
420
+ parentContentTitle: 'From "Developing the review app" course',
421
+ questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
422
+ });
423
+ t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
424
+ help: 'Type your answer.',
425
+ model: {
426
+ placeholder: 'Type here',
427
+ type: 'freeText',
428
+ value: 'My value'
429
+ }
430
+ });
431
+ t.deepEqual(omit(['0', '1.answerUI.model.answers.0.onClick', '1.answerUI.model.answers.1.onClick'], props.stack.slides), {
432
+ '1': {
433
+ answerUI: {
434
+ help: 'Sélectionnez la bonne réponse.',
435
+ model: {
436
+ answers: [
437
+ {
438
+ image: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
439
+ selected: false,
440
+ title: 'Vrai'
441
+ },
442
+ {
443
+ image: '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
444
+ selected: false,
445
+ title: 'Faux'
446
+ }
447
+ ],
448
+ type: 'qcmGraphic'
449
+ }
450
+ },
451
+ hidden: false,
452
+ loading: false,
453
+ position: 1,
454
+ parentContentTitle: 'From "Developing the review app" course',
455
+ questionText: 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?'
456
+ },
457
+ '2': {
458
+ hidden: false,
459
+ position: 2,
460
+ loading: true
461
+ },
462
+ '3': {
463
+ hidden: false,
464
+ position: 3,
465
+ loading: true
466
+ },
467
+ '4': {
468
+ hidden: false,
469
+ position: 4,
470
+ loading: true
471
+ }
472
+ });
473
+ });
@@ -5,8 +5,7 @@ import { qcmUISlide, qcmSlide } from './fixtures/qcm';
5
5
  import { qcmDragUISlide, qcmDragSlide } from './fixtures/qcm-drag';
6
6
  import { freeTextSlide, freeTextUISlide } from './fixtures/free-text';
7
7
  import { qcmGraphicUISlide, qcmGraphicSlide } from './fixtures/qcm-graphic';
8
- import { textTemplateSlide, textTemplateUISlide } from './fixtures/text-template';
9
- import { selectTemplateSlide, selectTemplateUISlide } from './fixtures/select-template';
8
+ import { templateSlide, templateUISlide } from './fixtures/template';
10
9
  import { sliderSlide, sliderUISlide } from './fixtures/slider';
11
10
  const _mapApiSlideToUi = mapApiSlideToUi(identity);
12
11
  const macro = test.macro({
@@ -24,15 +23,10 @@ test('qcm graphic', macro, {
24
23
  answers: [],
25
24
  expectedUiSlide: qcmGraphicUISlide
26
25
  });
27
- test('text template', macro, {
28
- slide: textTemplateSlide,
26
+ test('template', macro, {
27
+ slide: templateSlide,
29
28
  answers: [],
30
- expectedUiSlide: textTemplateUISlide
31
- });
32
- test('select template', macro, {
33
- slide: selectTemplateSlide,
34
- answers: [],
35
- expectedUiSlide: selectTemplateUISlide
29
+ expectedUiSlide: templateUISlide
36
30
  });
37
31
  test('free text', macro, { slide: freeTextSlide, answers: [], expectedUiSlide: freeTextUISlide });
38
32
  test('slider', macro, { slide: sliderSlide, answers: [], expectedUiSlide: sliderUISlide });
@@ -0,0 +1,79 @@
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_TEMPLATE } from '../../../actions/ui/answers';
8
+ import { templateSlide } from './fixtures/template';
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: templateSlide.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
+ [templateSlide.id]: templateSlide
35
+ },
36
+ skills: [],
37
+ token: '1234'
38
+ },
39
+ ui: {
40
+ currentSlideRef: templateSlide.id,
41
+ navigation: ['skills', 'slides'],
42
+ answers: [],
43
+ slide: {
44
+ validateButton: false
45
+ }
46
+ }
47
+ };
48
+ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Text slide', t => {
49
+ t.plan(2);
50
+ const expectedActions = [{ type: EDIT_TEMPLATE, payload: ['', 'test', ''] }];
51
+ const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
52
+ const props = mapStateToSlidesProps(getState(), dispatch);
53
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
54
+ hidden: false,
55
+ position: 0,
56
+ loading: false,
57
+ parentContentTitle: 'From "Developing the review app" course',
58
+ questionText: 'Complétez la phrase ci-dessous.'
59
+ });
60
+ const SlideProps = props.stack.slides['0'].answerUI?.model;
61
+ const onChange = get(['1', 'onChange'], SlideProps.answers);
62
+ onChange('test');
63
+ });
64
+ test('should dispatch EDIT_TEMPLATE action via the property onChange of a Template Select slide', t => {
65
+ t.plan(2);
66
+ const expectedActions = [{ type: EDIT_TEMPLATE, payload: ['Catalogue', '', ''] }];
67
+ const { dispatch, getState } = createTestStore(t, initialState, services, expectedActions);
68
+ const props = mapStateToSlidesProps(getState(), dispatch);
69
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
70
+ hidden: false,
71
+ position: 0,
72
+ loading: false,
73
+ parentContentTitle: 'From "Developing the review app" course',
74
+ questionText: 'Complétez la phrase ci-dessous.'
75
+ });
76
+ const SlideProps = props.stack.slides['0'].answerUI?.model;
77
+ const onChange = get(['0', 'onChange'], SlideProps.answers);
78
+ onChange('Catalogue');
79
+ });
@@ -1,5 +1,5 @@
1
1
  import type { Dispatch } from 'redux';
2
- import type { Options } from '../../types/common';
2
+ import type { Options, ProgressionFromAPI } from '../../types/common';
3
3
  import type { StoreState } from '../../reducers';
4
4
  export declare const POST_ANSWER_REQUEST: "@@answer/POST_REQUEST";
5
5
  export declare const POST_ANSWER_SUCCESS: "@@answer/POST_SUCCESS";
@@ -7,4 +7,8 @@ export declare const POST_ANSWER_FAILURE: "@@answer/POST_FAILURE";
7
7
  export declare type PostAnswerRequestAction = {
8
8
  type: typeof POST_ANSWER_REQUEST;
9
9
  };
10
+ export declare type PostAnswerSuccessAction = {
11
+ type: typeof POST_ANSWER_SUCCESS;
12
+ payload: ProgressionFromAPI;
13
+ };
10
14
  export declare const postAnswer: (dispatch: Dispatch, getState: () => StoreState, { services }: Options) => Promise<void>;
@@ -18,4 +18,4 @@ export declare type EditAnswerAction = {
18
18
  type: typeof EDIT_QCM | typeof EDIT_QCM_GRAPHIC | typeof EDIT_QCM_DRAG | typeof EDIT_TEMPLATE | typeof EDIT_BASIC | typeof EDIT_SLIDER;
19
19
  payload: string[];
20
20
  };
21
- export declare const editAnswer: (answer: string) => (dispatch: Dispatch, getState: () => StoreState) => EditAnswerAction;
21
+ export declare const editAnswer: (answer: string[]) => (dispatch: Dispatch, getState: () => StoreState) => EditAnswerAction;
@@ -27,13 +27,15 @@ var buildAnswer = function (userAnswers, questionType, newValue) {
27
27
  case 'qcm':
28
28
  case 'qcmGraphic':
29
29
  case 'qcmDrag': {
30
- return includes(newValue, userAnswers)
31
- ? pull(newValue, userAnswers)
32
- : flatten(__spreadArray(__spreadArray([], userAnswers, true), [newValue], false));
30
+ var firstValue = newValue[0];
31
+ return includes(firstValue, userAnswers)
32
+ ? pull(firstValue, userAnswers)
33
+ : flatten(__spreadArray(__spreadArray([], userAnswers, true), [firstValue], false));
33
34
  }
34
35
  case 'basic':
35
36
  case 'slider':
36
- return [newValue];
37
+ case 'template':
38
+ return newValue;
37
39
  default:
38
40
  return [];
39
41
  }
@@ -44,6 +44,7 @@ import { qcmDragSlide } from '../../../views/slides/test/fixtures/qcm-drag';
44
44
  import { qcmSlide } from '../../../views/slides/test/fixtures/qcm';
45
45
  import { qcmGraphicSlide } from '../../../views/slides/test/fixtures/qcm-graphic';
46
46
  import { sliderSlide } from '../../../views/slides/test/fixtures/slider';
47
+ import { templateSlide } from '../../../views/slides/test/fixtures/template';
47
48
  import { editAnswer, ANSWER_EDIT } from '../answers';
48
49
  var initialState = {
49
50
  data: {
@@ -95,7 +96,7 @@ test('should dispatch EDIT_BASIC action when editAnswer is called', function (t)
95
96
  state = buildInitialState(initialState, freeTextSlide);
96
97
  expectedActions = [{ type: ANSWER_EDIT.basic, payload: ['My Answer'] }];
97
98
  dispatch = createTestStore(t, state, services, expectedActions).dispatch;
98
- return [4 /*yield*/, dispatch(editAnswer('My Answer'))];
99
+ return [4 /*yield*/, dispatch(editAnswer(['My Answer']))];
99
100
  case 1:
100
101
  _a.sent();
101
102
  return [2 /*return*/];
@@ -111,7 +112,7 @@ test('should dispatch EDIT_QCM action when editAnswer is called', function (t) {
111
112
  state = set(['ui', 'answers'], ['My First Answer', 'My Second Answer'], state);
112
113
  expectedActions = [{ type: ANSWER_EDIT.qcm, payload: ['My First Answer'] }];
113
114
  dispatch = createTestStore(t, state, services, expectedActions).dispatch;
114
- return [4 /*yield*/, dispatch(editAnswer('My Second Answer'))];
115
+ return [4 /*yield*/, dispatch(editAnswer(['My Second Answer']))];
115
116
  case 1:
116
117
  _a.sent();
117
118
  return [2 /*return*/];
@@ -129,7 +130,7 @@ test('should dispatch EDIT_QCM_GRAPHIC action when editAnswer is called', functi
129
130
  { type: ANSWER_EDIT.qcmGraphic, payload: ['My First Answer', 'My Third Answer'] }
130
131
  ];
131
132
  dispatch = createTestStore(t, state, services, expectedActions).dispatch;
132
- return [4 /*yield*/, dispatch(editAnswer('My Second Answer'))];
133
+ return [4 /*yield*/, dispatch(editAnswer(['My Second Answer']))];
133
134
  case 1:
134
135
  _a.sent();
135
136
  return [2 /*return*/];
@@ -147,7 +148,7 @@ test('should dispatch EDIT_QCM_DRAG action when editAnswer is called', function
147
148
  { type: ANSWER_EDIT.qcmDrag, payload: ['My First Answer', 'My Second Answer', 'My Third Answer'] }
148
149
  ];
149
150
  dispatch = createTestStore(t, state, services, expectedActions).dispatch;
150
- return [4 /*yield*/, dispatch(editAnswer('My Third Answer'))];
151
+ return [4 /*yield*/, dispatch(editAnswer(['My Third Answer']))];
151
152
  case 1:
152
153
  _a.sent();
153
154
  return [2 /*return*/];
@@ -162,7 +163,25 @@ test('should dispatch EDIT_SLIDER action when editAnswer is called', function (t
162
163
  state = buildInitialState(initialState, sliderSlide);
163
164
  expectedActions = [{ type: ANSWER_EDIT.slider, payload: ['5'] }];
164
165
  dispatch = createTestStore(t, state, services, expectedActions).dispatch;
165
- return [4 /*yield*/, dispatch(editAnswer('5'))];
166
+ return [4 /*yield*/, dispatch(editAnswer(['5']))];
167
+ case 1:
168
+ _a.sent();
169
+ return [2 /*return*/];
170
+ }
171
+ });
172
+ }); });
173
+ test('should dispatch EDIT_TEMPLATE action when editAnswer is called', function (t) { return __awaiter(void 0, void 0, void 0, function () {
174
+ var state, expectedActions, dispatch;
175
+ return __generator(this, function (_a) {
176
+ switch (_a.label) {
177
+ case 0:
178
+ state = buildInitialState(initialState, templateSlide);
179
+ state = set(['ui', 'answers'], ['Catalogue', '', 'étoiles'], state);
180
+ expectedActions = [
181
+ { type: ANSWER_EDIT.template, payload: ['Catalogue', 'My Answer', 'étoiles'] }
182
+ ];
183
+ dispatch = createTestStore(t, state, services, expectedActions).dispatch;
184
+ return [4 /*yield*/, dispatch(editAnswer(['Catalogue', 'My Answer', 'étoiles']))];
166
185
  case 1:
167
186
  _a.sent();
168
187
  return [2 /*return*/];
@@ -14,5 +14,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
14
14
  skills: SkillsState;
15
15
  slides: SlidesState;
16
16
  token: TokenState;
17
- }>, import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
17
+ }>, import("../../actions/api/post-answer").PostAnswerSuccessAction | import("../../actions/api/post-progression").ReceivedProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
18
18
  export default _default;
@@ -1,5 +1,6 @@
1
+ import { PostAnswerSuccessAction } from '../../actions/api/post-answer';
1
2
  import { ReceivedProgression } from '../../actions/api/post-progression';
2
3
  import { ProgressionFromAPI } from '../../types/common';
3
4
  export declare type ProgressionState = ProgressionFromAPI | null;
4
- declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression) => ProgressionState;
5
+ declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression | PostAnswerSuccessAction) => ProgressionState;
5
6
  export default reducer;
@@ -1,9 +1,11 @@
1
+ import { POST_ANSWER_SUCCESS } from '../../actions/api/post-answer';
1
2
  import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
2
3
  var reducer = function (
3
4
  // eslint-disable-next-line default-param-last
4
5
  state, action) {
5
6
  if (state === void 0) { state = null; }
6
7
  switch (action.type) {
8
+ case POST_ANSWER_SUCCESS:
7
9
  case POST_PROGRESSION_SUCCESS: {
8
10
  var progression = action.payload;
9
11
  return progression;
@@ -1,38 +1,23 @@
1
1
  import test from 'ava';
2
2
  import reducer from '../progression';
3
3
  import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
4
+ import { POST_ANSWER_SUCCESS } from '../../../actions/api/post-answer';
5
+ import { postAnswerResponse, postProgressionResponse } from '../../../test/util/services.mock';
4
6
  test('should have initial value', function (t) {
5
7
  var state = reducer(undefined, {});
6
8
  t.is(state, null);
7
9
  });
8
10
  test('should set the value of POST_PROGRESSION_SUCCESS action', function (t) {
9
- var progression = {
10
- _id: '62b1d1087aa12f00253f40ee',
11
- content: {
12
- ref: '_skill-ref',
13
- type: 'skill'
14
- },
15
- engine: {
16
- ref: 'review'
17
- },
18
- state: {
19
- allAnswers: [],
20
- isCorrect: true,
21
- nextContent: {
22
- ref: 'sli_N1XACJobn',
23
- type: 'slide'
24
- },
25
- pendingSlides: [],
26
- slides: [],
27
- step: {
28
- current: 1
29
- },
30
- stars: 0
31
- }
32
- };
33
11
  var state = reducer(null, {
34
12
  type: POST_PROGRESSION_SUCCESS,
35
- payload: progression
13
+ payload: postProgressionResponse
36
14
  });
37
- t.deepEqual(state, progression);
15
+ t.deepEqual(state, postProgressionResponse);
16
+ });
17
+ test('should set the value of POST_ANSWER_SUCCESS action', function (t) {
18
+ var state = reducer(null, {
19
+ type: POST_ANSWER_SUCCESS,
20
+ payload: postAnswerResponse
21
+ });
22
+ t.deepEqual(state, postAnswerResponse);
38
23
  });
@@ -17,5 +17,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
17
17
  answers: import("./ui/answers").AnswerState;
18
18
  slide: import("./ui/slide").UISlideState;
19
19
  }>;
20
- }>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction | import("../actions/api/post-answer").PostAnswerRequestAction>;
20
+ }>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-answer").PostAnswerRequestAction | import("../actions/api/post-answer").PostAnswerSuccessAction | import("../actions/api/post-progression").ReceivedProgression | import("../actions/api/fetch-skills").ReceivedSkills | import("./data/slides").SlidesAction | import("../actions/data/token").StoreToken | import("../actions/ui/navigation").NavigateTo | import("../actions/ui/navigation").NavigateBack | import("../actions/ui/answers").EditAnswerAction>;
21
21
  export default _default;
@@ -13,5 +13,5 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
13
13
  navigation: NavigationState;
14
14
  answers: AnswerState;
15
15
  slide: UISlideState;
16
- }>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction | import("../../actions/api/post-answer").PostAnswerRequestAction>;
16
+ }>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/api/post-answer").PostAnswerRequestAction | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditAnswerAction>;
17
17
  export default _default;
@@ -25,3 +25,7 @@ test('should set the value of EDIT_SLIDER action', function (t) {
25
25
  var state = reducer([], { type: ANSWER_EDIT.slider, payload: ['5'] });
26
26
  t.deepEqual(state, ['5']);
27
27
  });
28
+ test('should set the value of EDIT_TEMPLATE action', function (t) {
29
+ var state = reducer([], { type: ANSWER_EDIT.template, payload: ['value1', 'value2'] });
30
+ t.deepEqual(state, ['value1', 'value2']);
31
+ });
@@ -1,3 +1,4 @@
1
1
  import { ProgressionFromAPI, Services } from '../../types/common';
2
+ export declare const postProgressionResponse: ProgressionFromAPI;
2
3
  export declare const postAnswerResponse: ProgressionFromAPI;
3
4
  export declare const services: Services;
@@ -13,6 +13,7 @@ import { qcmSlide } from '../../views/slides/test/fixtures/qcm';
13
13
  import { qcmGraphicSlide } from '../../views/slides/test/fixtures/qcm-graphic';
14
14
  import { freeTextSlide } from '../../views/slides/test/fixtures/free-text';
15
15
  import { sliderSlide } from '../../views/slides/test/fixtures/slider';
16
+ import { templateSlide } from '../../views/slides/test/fixtures/template';
16
17
  var getSlideFixture = function (ref) {
17
18
  switch (ref) {
18
19
  case qcmSlide.universalRef:
@@ -21,6 +22,8 @@ var getSlideFixture = function (ref) {
21
22
  return qcmGraphicSlide;
22
23
  case freeTextSlide.universalRef:
23
24
  return freeTextSlide;
25
+ case templateSlide.universalRef:
26
+ return templateSlide;
24
27
  default:
25
28
  return sliderSlide;
26
29
  }
@@ -39,7 +42,7 @@ var fetchSkillsResponse = [
39
42
  custom: true
40
43
  }
41
44
  ];
42
- var postProgressionResponse = {
45
+ export var postProgressionResponse = {
43
46
  _id: '62b1d1087aa12f00253f40ee',
44
47
  content: {
45
48
  ref: '_skill-ref',
@@ -55,7 +55,7 @@ export var initialState = {
55
55
  var getProgressionSlidesRefs = function (progression) {
56
56
  if (progression.state.step.current < 5) {
57
57
  var slideRef = progression.state.nextContent.ref;
58
- return concat([slideRef], progression.state.slides);
58
+ return concat(progression.state.slides, [slideRef]);
59
59
  }
60
60
  return slice(0, 5, progression.state.slides);
61
61
  };