@coorpacademy/app-review 0.2.4 → 0.2.6

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 (97) hide show
  1. package/es/actions/api/post-answer.js +4 -2
  2. package/es/actions/api/test/fetch-correction.test.js +2 -1
  3. package/es/actions/api/test/fetch-skills.test.js +2 -1
  4. package/es/actions/api/test/fetch-slide.test.js +2 -1
  5. package/es/actions/api/test/post-answer.test.js +32 -10
  6. package/es/actions/api/test/post-progression.test.js +2 -1
  7. package/es/actions/data/test/token.test.js +2 -1
  8. package/es/actions/test/create-test-store.d.ts +1 -1
  9. package/es/actions/ui/answers.js +13 -6
  10. package/es/actions/ui/test/answers.test.js +17 -1
  11. package/es/actions/ui/test/slides.test.js +2 -1
  12. package/es/reducers/data/index.d.ts +4 -2
  13. package/es/reducers/data/index.js +2 -6
  14. package/es/reducers/index.d.ts +2 -1
  15. package/es/reducers/ui/index.d.ts +1 -1
  16. package/es/reducers/ui/slide.d.ts +3 -1
  17. package/es/reducers/ui/slide.js +5 -0
  18. package/es/reducers/ui/test/slide.test.js +12 -0
  19. package/es/types/slides.d.ts +1 -0
  20. package/es/views/skills/test/skills.test.js +4 -2
  21. package/es/views/slides/map-api-slide-to-ui.js +8 -7
  22. package/es/views/slides/test/fixtures/qcm-graphic.js +4 -2
  23. package/es/views/slides/test/fixtures/qcm.js +4 -4
  24. package/es/views/slides/test/index.test.js +20 -10
  25. package/es/views/slides/test/slide.free-text.on-change.test.d.ts +1 -0
  26. package/es/views/slides/test/slide.free-text.on-change.test.js +69 -0
  27. package/es/views/slides/test/slide.qcm-drag.on-click.test.d.ts +1 -0
  28. package/es/views/slides/test/slide.qcm-drag.on-click.test.js +69 -0
  29. package/es/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +1 -0
  30. package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +69 -0
  31. package/es/views/slides/test/slide.qcm.on-click.test.d.ts +1 -0
  32. package/es/views/slides/test/slide.qcm.on-click.test.js +71 -0
  33. package/es/views/slides/test/slide.slider.on-change.test.d.ts +1 -0
  34. package/es/views/slides/test/slide.slider.on-change.test.js +70 -0
  35. package/es/views/slides/test/slide.template.on-change.test.js +2 -1
  36. package/lib/actions/api/post-answer.js +9 -5
  37. package/lib/actions/api/test/fetch-correction.test.js +2 -1
  38. package/lib/actions/api/test/fetch-skills.test.js +2 -1
  39. package/lib/actions/api/test/fetch-slide.test.js +2 -1
  40. package/lib/actions/api/test/post-answer.test.js +45 -14
  41. package/lib/actions/api/test/post-progression.test.js +2 -1
  42. package/lib/actions/data/test/token.test.js +2 -1
  43. package/lib/actions/test/create-test-store.d.ts +1 -1
  44. package/lib/actions/ui/answers.js +13 -6
  45. package/lib/actions/ui/test/answers.test.js +43 -1
  46. package/lib/actions/ui/test/slides.test.js +2 -1
  47. package/lib/reducers/data/index.d.ts +4 -2
  48. package/lib/reducers/data/index.js +2 -6
  49. package/lib/reducers/index.d.ts +2 -1
  50. package/lib/reducers/ui/index.d.ts +1 -1
  51. package/lib/reducers/ui/slide.d.ts +3 -1
  52. package/lib/reducers/ui/slide.js +5 -0
  53. package/lib/reducers/ui/test/slide.test.js +12 -0
  54. package/lib/types/slides.d.ts +1 -0
  55. package/lib/views/skills/test/skills.test.js +4 -2
  56. package/lib/views/slides/map-api-slide-to-ui.js +8 -7
  57. package/lib/views/slides/test/fixtures/qcm-graphic.js +4 -2
  58. package/lib/views/slides/test/fixtures/qcm.js +4 -4
  59. package/lib/views/slides/test/index.test.js +20 -10
  60. package/lib/views/slides/test/slide.free-text.on-change.test.d.ts +1 -0
  61. package/lib/views/slides/test/slide.free-text.on-change.test.js +71 -0
  62. package/lib/views/slides/test/slide.qcm-drag.on-click.test.d.ts +1 -0
  63. package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +71 -0
  64. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +1 -0
  65. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +71 -0
  66. package/lib/views/slides/test/slide.qcm.on-click.test.d.ts +1 -0
  67. package/lib/views/slides/test/slide.qcm.on-click.test.js +73 -0
  68. package/lib/views/slides/test/slide.slider.on-change.test.d.ts +1 -0
  69. package/lib/views/slides/test/slide.slider.on-change.test.js +72 -0
  70. package/lib/views/slides/test/slide.template.on-change.test.js +2 -1
  71. package/package.json +3 -3
  72. package/src/actions/api/post-answer.ts +4 -2
  73. package/src/actions/api/test/fetch-correction.test.ts +2 -1
  74. package/src/actions/api/test/fetch-skills.test.ts +2 -1
  75. package/src/actions/api/test/fetch-slide.test.ts +2 -1
  76. package/src/actions/api/test/post-answer.test.ts +51 -10
  77. package/src/actions/api/test/post-progression.test.ts +2 -1
  78. package/src/actions/data/test/token.test.ts +2 -1
  79. package/src/actions/test/create-test-store.ts +1 -1
  80. package/src/actions/ui/answers.ts +15 -6
  81. package/src/actions/ui/test/answers.test.ts +33 -2
  82. package/src/actions/ui/test/slides.test.ts +2 -1
  83. package/src/reducers/data/index.ts +3 -7
  84. package/src/reducers/ui/slide.ts +7 -1
  85. package/src/reducers/ui/test/slide.test.ts +13 -0
  86. package/src/types/slides.ts +1 -0
  87. package/src/views/skills/test/skills.test.ts +4 -2
  88. package/src/views/slides/map-api-slide-to-ui.ts +8 -7
  89. package/src/views/slides/test/fixtures/qcm-graphic.ts +4 -2
  90. package/src/views/slides/test/fixtures/qcm.ts +5 -4
  91. package/src/views/slides/test/index.test.ts +20 -10
  92. package/src/views/slides/test/slide.free-text.on-change.test.ts +79 -0
  93. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +78 -0
  94. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +79 -0
  95. package/src/views/slides/test/slide.qcm.on-click.test.ts +80 -0
  96. package/src/views/slides/test/slide.slider.on-change.test.ts +80 -0
  97. package/src/views/slides/test/slide.template.on-change.test.ts +2 -1
@@ -80,14 +80,16 @@ export const qcmGraphicUISlide: Partial<UISlide> = {
80
80
  image:
81
81
  '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/true-1512554153232.jpg',
82
82
  selected: false,
83
- onClick: noop
83
+ onClick: noop,
84
+ ariaLabel: 'Vrai'
84
85
  },
85
86
  {
86
87
  title: 'Faux',
87
88
  image:
88
89
  '//static.coorpacademy.com/content/CoorpAcademy/content-partnerships/cockpit-partner-au-feminin/default/false-1512554160848.jpg',
89
90
  selected: false,
90
- onClick: noop
91
+ onClick: noop,
92
+ ariaLabel: 'Faux'
91
93
  }
92
94
  ]
93
95
  }
@@ -89,14 +89,14 @@ export const qcmUISlide: Partial<UISlide> = {
89
89
  title: 'Le créateur peut fixer un pourcentage pour chaque transaction future',
90
90
  selected: false,
91
91
  onClick: noop,
92
- ariaLabel: 'Le créateur peut fixer un pourcentage pour chaque transaction future'
92
+ 'aria-label': 'Le créateur peut fixer un pourcentage pour chaque transaction future'
93
93
  },
94
94
  {
95
95
  title:
96
96
  "Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente",
97
97
  selected: false,
98
98
  onClick: noop,
99
- ariaLabel:
99
+ 'aria-label':
100
100
  "Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente"
101
101
  },
102
102
  {
@@ -104,14 +104,15 @@ export const qcmUISlide: Partial<UISlide> = {
104
104
  "Seule la galerie ou la plateforme peut toucher une commission sur la vente d'un NFT",
105
105
  selected: false,
106
106
  onClick: noop,
107
- ariaLabel:
107
+ 'aria-label':
108
108
  "Seule la galerie ou la plateforme peut toucher une commission sur la vente d'un NFT"
109
109
  },
110
110
  {
111
111
  title: "Les NFT payés en ETH ne peuvent pas être soumis au paiement d'une commission",
112
112
  selected: false,
113
113
  onClick: noop,
114
- ariaLabel: "Les NFT payés en ETH ne peuvent pas être soumis au paiement d'une commission"
114
+ 'aria-label':
115
+ "Les NFT payés en ETH ne peuvent pas être soumis au paiement d'une commission"
115
116
  }
116
117
  ]
117
118
  }
@@ -24,7 +24,8 @@ test('should create initial props when fetched slide is not still received', t =
24
24
  slides: {
25
25
  sli_N1XACJobn: null
26
26
  },
27
- token: '1234'
27
+ token: '1234',
28
+ corrections: {}
28
29
  },
29
30
  ui: {
30
31
  currentSlideRef: '',
@@ -113,7 +114,8 @@ test('should create props when first slide is on the state', t => {
113
114
  slides: {
114
115
  sli_VJYjJnJhg: freeTextSlide
115
116
  },
116
- token: '1234'
117
+ token: '1234',
118
+ corrections: {}
117
119
  },
118
120
  ui: {
119
121
  currentSlideRef: 'sli_VJYjJnJhg',
@@ -214,7 +216,8 @@ test('should create props when slide is on the state and user has selected answe
214
216
  slides: {
215
217
  sli_VJYjJnJhg: freeTextSlide
216
218
  },
217
- token: '1234'
219
+ token: '1234',
220
+ corrections: {}
218
221
  },
219
222
  ui: {
220
223
  currentSlideRef: 'sli_VJYjJnJhg',
@@ -316,7 +319,8 @@ test('should verify props when first slide was answered correctly and next slide
316
319
  sli_VJYjJnJhg: freeTextSlide,
317
320
  sli_VkSQroQnx: null
318
321
  },
319
- token: '1234'
322
+ token: '1234',
323
+ corrections: {}
320
324
  },
321
325
  ui: {
322
326
  currentSlideRef: 'sli_VJYjJnJhg',
@@ -422,7 +426,8 @@ test('should verify props when first slide was answered with error and next slid
422
426
  sli_VJYjJnJhg: freeTextSlide,
423
427
  sli_VkSQroQnx: null
424
428
  },
425
- token: '1234'
429
+ token: '1234',
430
+ corrections: {}
426
431
  },
427
432
  ui: {
428
433
  currentSlideRef: 'sli_VJYjJnJhg',
@@ -481,7 +486,8 @@ test('should verify props when first slide was answered and next slide is fecthe
481
486
  sli_VJYjJnJhg: freeTextSlide,
482
487
  sli_VkSQroQnx: qcmGraphicSlide
483
488
  },
484
- token: '1234'
489
+ token: '1234',
490
+ corrections: {}
485
491
  },
486
492
  ui: {
487
493
  currentSlideRef: 'sli_VJYjJnJhg',
@@ -586,7 +592,8 @@ test('should verify props when currentSlideRef has changed to nextContent of pro
586
592
  sli_VJYjJnJhg: freeTextSlide,
587
593
  sli_VkSQroQnx: qcmGraphicSlide
588
594
  },
589
- token: '1234'
595
+ token: '1234',
596
+ corrections: {}
590
597
  },
591
598
  ui: {
592
599
  currentSlideRef: 'sli_VkSQroQnx',
@@ -650,7 +657,8 @@ test('should verify props when progression is in success', t => {
650
657
  [sliderSlide.universalRef]: sliderSlide,
651
658
  [templateSlide.universalRef]: templateSlide
652
659
  },
653
- token: '1234'
660
+ token: '1234',
661
+ corrections: {}
654
662
  },
655
663
  ui: {
656
664
  currentSlideRef: templateSlide.universalRef,
@@ -714,7 +722,8 @@ test('should verify props when progression has answered a current pendingslide',
714
722
  [sliderSlide.universalRef]: sliderSlide,
715
723
  [templateSlide.universalRef]: templateSlide
716
724
  },
717
- token: '1234'
725
+ token: '1234',
726
+ corrections: {}
718
727
  },
719
728
  ui: {
720
729
  currentSlideRef: freeTextSlide.universalRef,
@@ -775,7 +784,8 @@ test('should verify props when progression has still pendingslide', t => {
775
784
  [sliderSlide.universalRef]: sliderSlide,
776
785
  [templateSlide.universalRef]: templateSlide
777
786
  },
778
- token: '1234'
787
+ token: '1234',
788
+ corrections: {}
779
789
  },
780
790
  ui: {
781
791
  currentSlideRef: qcmSlide.universalRef,
@@ -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 {ProgressionFromAPI} from '../../../types/common';
6
+ import {services} from '../../../test/util/services.mock';
7
+ import {createTestStore} from '../../../actions/test/create-test-store';
8
+ import {StoreState} from '../../../reducers';
9
+ import {EDIT_BASIC} from '../../../actions/ui/answers';
10
+ import {FreeText} from '../../../types/slides';
11
+ import {freeTextSlide} from './fixtures/free-text';
12
+
13
+ const progression: ProgressionFromAPI = {
14
+ _id: '123456789123',
15
+ content: {type: 'skill', ref: '_skill-ref'},
16
+ engine: {
17
+ ref: 'review'
18
+ },
19
+ state: {
20
+ allAnswers: [],
21
+ isCorrect: true,
22
+ nextContent: {
23
+ ref: freeTextSlide._id,
24
+ type: 'slide'
25
+ },
26
+ pendingSlides: [],
27
+ slides: [],
28
+ step: {
29
+ current: 1
30
+ },
31
+ stars: 0
32
+ }
33
+ };
34
+
35
+ const initialState: StoreState = {
36
+ data: {
37
+ progression,
38
+ slides: {
39
+ [freeTextSlide._id]: freeTextSlide
40
+ },
41
+ skills: [],
42
+ token: '1234',
43
+ corrections: {}
44
+ },
45
+ ui: {
46
+ currentSlideRef: freeTextSlide._id,
47
+ navigation: ['skills', 'slides'],
48
+ answers: [],
49
+ slide: {
50
+ validateButton: false
51
+ }
52
+ }
53
+ };
54
+
55
+ test('should dispatch EDIT_BASIC action via the property onChange of a Free Text slide', t => {
56
+ t.plan(2);
57
+
58
+ const expectedActions = [
59
+ {
60
+ type: EDIT_BASIC,
61
+ payload: ['My Answer']
62
+ }
63
+ ];
64
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
65
+
66
+ const props = mapStateToSlidesProps(getState(), dispatch);
67
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
68
+ hidden: false,
69
+ position: 0,
70
+ loading: false,
71
+ parentContentTitle: 'From "Developing the review app" course',
72
+ questionText:
73
+ 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
74
+ });
75
+
76
+ const SlideProps = props.stack.slides['0'].answerUI?.model as FreeText;
77
+ const onChange = get('onChange', SlideProps);
78
+ onChange('My Answer');
79
+ });
@@ -0,0 +1,78 @@
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 {ProgressionFromAPI} from '../../../types/common';
6
+ import {services} from '../../../test/util/services.mock';
7
+ import {createTestStore} from '../../../actions/test/create-test-store';
8
+ import {StoreState} from '../../../reducers';
9
+ import {EDIT_QCM_DRAG} from '../../../actions/ui/answers';
10
+ import {QcmDrag} from '../../../types/slides';
11
+ import {qcmDragSlide} from './fixtures/qcm-drag';
12
+
13
+ const progression: ProgressionFromAPI = {
14
+ _id: '123456789123',
15
+ content: {type: 'skill', ref: '_skill-ref'},
16
+ engine: {
17
+ ref: 'review'
18
+ },
19
+ state: {
20
+ allAnswers: [],
21
+ isCorrect: true,
22
+ nextContent: {
23
+ ref: qcmDragSlide._id,
24
+ type: 'slide'
25
+ },
26
+ pendingSlides: [],
27
+ slides: [],
28
+ step: {
29
+ current: 1
30
+ },
31
+ stars: 0
32
+ }
33
+ };
34
+
35
+ const initialState: StoreState = {
36
+ data: {
37
+ progression,
38
+ slides: {
39
+ [qcmDragSlide._id]: qcmDragSlide
40
+ },
41
+ skills: [],
42
+ token: '1234',
43
+ corrections: {}
44
+ },
45
+ ui: {
46
+ currentSlideRef: qcmDragSlide._id,
47
+ navigation: ['skills', 'slides'],
48
+ answers: [],
49
+ slide: {
50
+ validateButton: false
51
+ }
52
+ }
53
+ };
54
+
55
+ test('should dispatch EDIT_QCM_DRAG action via the property onClick of a QCM Drag slide', t => {
56
+ t.plan(2);
57
+
58
+ const expectedActions = [
59
+ {
60
+ type: EDIT_QCM_DRAG,
61
+ payload: ['La démoralisation']
62
+ }
63
+ ];
64
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
65
+
66
+ const props = mapStateToSlidesProps(getState(), dispatch);
67
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
68
+ hidden: false,
69
+ position: 0,
70
+ loading: false,
71
+ parentContentTitle: 'From "Using redux" chapter',
72
+ questionText: "Remettez dans l'ordre les quatre étapes du burn out."
73
+ });
74
+
75
+ const SlideProps = props.stack.slides['0'].answerUI?.model as QcmDrag;
76
+ const onClick = get(['0', 'onClick'], SlideProps.answers);
77
+ onClick();
78
+ });
@@ -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 {ProgressionFromAPI} from '../../../types/common';
6
+ import {services} from '../../../test/util/services.mock';
7
+ import {createTestStore} from '../../../actions/test/create-test-store';
8
+ import {StoreState} from '../../../reducers';
9
+ import {EDIT_QCM_GRAPHIC} from '../../../actions/ui/answers';
10
+ import {QcmGraphic} from '../../../types/slides';
11
+ import {qcmGraphicSlide} from './fixtures/qcm-graphic';
12
+
13
+ const progression: ProgressionFromAPI = {
14
+ _id: '123456789123',
15
+ content: {type: 'skill', ref: '_skill-ref'},
16
+ engine: {
17
+ ref: 'review'
18
+ },
19
+ state: {
20
+ allAnswers: [],
21
+ isCorrect: true,
22
+ nextContent: {
23
+ ref: qcmGraphicSlide._id,
24
+ type: 'slide'
25
+ },
26
+ pendingSlides: [],
27
+ slides: [],
28
+ step: {
29
+ current: 1
30
+ },
31
+ stars: 0
32
+ }
33
+ };
34
+
35
+ const initialState: StoreState = {
36
+ data: {
37
+ progression,
38
+ slides: {
39
+ [qcmGraphicSlide._id]: qcmGraphicSlide
40
+ },
41
+ skills: [],
42
+ token: '1234',
43
+ corrections: {}
44
+ },
45
+ ui: {
46
+ currentSlideRef: qcmGraphicSlide._id,
47
+ navigation: ['skills', 'slides'],
48
+ answers: [],
49
+ slide: {
50
+ validateButton: false
51
+ }
52
+ }
53
+ };
54
+
55
+ test('should dispatch EDIT_QCM_GRAPHIC action via the property onClick of a QCM Graphic slide', t => {
56
+ t.plan(2);
57
+
58
+ const expectedActions = [
59
+ {
60
+ type: EDIT_QCM_GRAPHIC,
61
+ payload: ['Faux']
62
+ }
63
+ ];
64
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
65
+
66
+ const props = mapStateToSlidesProps(getState(), dispatch);
67
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
68
+ hidden: false,
69
+ position: 0,
70
+ loading: false,
71
+ parentContentTitle: 'From "Developing the review app" course',
72
+ questionText:
73
+ 'Pour mener une bonne négociation, il ne faut ressentir aucune émotion. Vrai ou faux ?'
74
+ });
75
+
76
+ const SlideProps = props.stack.slides['0'].answerUI?.model as QcmGraphic;
77
+ const onClick = get(['1', 'onClick'], SlideProps.answers);
78
+ onClick();
79
+ });
@@ -0,0 +1,80 @@
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 {ProgressionFromAPI} from '../../../types/common';
6
+ import {services} from '../../../test/util/services.mock';
7
+ import {createTestStore} from '../../../actions/test/create-test-store';
8
+ import {StoreState} from '../../../reducers';
9
+ import {EDIT_QCM} from '../../../actions/ui/answers';
10
+ import {Qcm} from '../../../types/slides';
11
+ import {qcmSlide} from './fixtures/qcm';
12
+
13
+ const progression: ProgressionFromAPI = {
14
+ _id: '123456789123',
15
+ content: {type: 'skill', ref: '_skill-ref'},
16
+ engine: {
17
+ ref: 'review'
18
+ },
19
+ state: {
20
+ allAnswers: [],
21
+ isCorrect: true,
22
+ nextContent: {
23
+ ref: qcmSlide._id,
24
+ type: 'slide'
25
+ },
26
+ pendingSlides: [],
27
+ slides: [],
28
+ step: {
29
+ current: 1
30
+ },
31
+ stars: 0
32
+ }
33
+ };
34
+
35
+ const initialState: StoreState = {
36
+ data: {
37
+ progression,
38
+ slides: {
39
+ [qcmSlide._id]: qcmSlide
40
+ },
41
+ skills: [],
42
+ token: '1234',
43
+ corrections: {}
44
+ },
45
+ ui: {
46
+ currentSlideRef: qcmSlide._id,
47
+ navigation: ['skills', 'slides'],
48
+ answers: [],
49
+ slide: {
50
+ validateButton: false
51
+ }
52
+ }
53
+ };
54
+
55
+ test('should dispatch EDIT_QCM action via the property onClick of a QCM slide', t => {
56
+ t.plan(2);
57
+
58
+ const expectedActions = [
59
+ {
60
+ type: EDIT_QCM,
61
+ payload: [
62
+ "Pour chaque transaction il existe un pourcentage fixe déterminé par le droit d'auteur du pays où se tient la vente"
63
+ ]
64
+ }
65
+ ];
66
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
67
+
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: "Après la vente d'un NFT, son créateur peut-il toucher de l'argent ?"
75
+ });
76
+
77
+ const SlideProps = props.stack.slides['0'].answerUI?.model as Qcm;
78
+ const onClick = get(['1', 'onClick'], SlideProps.answers);
79
+ onClick();
80
+ });
@@ -0,0 +1,80 @@
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 {ProgressionFromAPI} from '../../../types/common';
6
+ import {services} from '../../../test/util/services.mock';
7
+ import {createTestStore} from '../../../actions/test/create-test-store';
8
+ import {StoreState} from '../../../reducers';
9
+ import {EDIT_SLIDER} from '../../../actions/ui/answers';
10
+ import {QuestionRange} from '../../../types/slides';
11
+ import {sliderSlide} from './fixtures/slider';
12
+
13
+ const progression: ProgressionFromAPI = {
14
+ _id: '123456789123',
15
+ content: {type: 'skill', ref: '_skill-ref'},
16
+ engine: {
17
+ ref: 'review'
18
+ },
19
+ state: {
20
+ allAnswers: [],
21
+ isCorrect: true,
22
+ nextContent: {
23
+ ref: sliderSlide._id,
24
+ type: 'slide'
25
+ },
26
+ pendingSlides: [],
27
+ slides: [],
28
+ step: {
29
+ current: 1
30
+ },
31
+ stars: 0
32
+ }
33
+ };
34
+
35
+ const initialState: StoreState = {
36
+ data: {
37
+ progression,
38
+ slides: {
39
+ [sliderSlide._id]: sliderSlide
40
+ },
41
+ skills: [],
42
+ token: '1234',
43
+ corrections: {}
44
+ },
45
+ ui: {
46
+ currentSlideRef: sliderSlide._id,
47
+ navigation: ['skills', 'slides'],
48
+ answers: [],
49
+ slide: {
50
+ validateButton: false
51
+ }
52
+ }
53
+ };
54
+
55
+ test('should dispatch EDIT_SLIDER action via the property onChange of a Slider slide', t => {
56
+ t.plan(2);
57
+
58
+ const expectedActions = [
59
+ {
60
+ type: EDIT_SLIDER,
61
+ payload: ['5']
62
+ }
63
+ ];
64
+ const {dispatch, getState} = createTestStore(t, initialState, services, expectedActions);
65
+
66
+ const props = mapStateToSlidesProps(getState(), dispatch);
67
+ t.deepEqual(omit('answerUI', props.stack.slides['0']), {
68
+ hidden: false,
69
+ position: 0,
70
+ loading: false,
71
+ parentContentTitle: 'From "Developing the review app" course',
72
+ questionText:
73
+ 'En combien d’années la communauté de communes du Thouarsais est-elle passée de zéro à un tiers d’énergies renouvelables ?'
74
+ });
75
+
76
+ const SlideProps = props.stack.slides['0'].answerUI?.model as QuestionRange;
77
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
78
+ const onChange = get('onChange', SlideProps)!;
79
+ onChange(0.29339261968085106);
80
+ });
@@ -39,7 +39,8 @@ const initialState: StoreState = {
39
39
  [templateSlide._id]: templateSlide
40
40
  },
41
41
  skills: [],
42
- token: '1234'
42
+ token: '1234',
43
+ corrections: {}
43
44
  },
44
45
  ui: {
45
46
  currentSlideRef: templateSlide._id,