@coorpacademy/app-review 0.2.12 → 0.3.1-alpha.1

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 (198) hide show
  1. package/es/actions/api/fetch-correction.js +1 -1
  2. package/es/actions/api/post-answer.d.ts +6 -0
  3. package/es/actions/api/post-answer.js +3 -1
  4. package/es/actions/ui/answers.d.ts +3 -0
  5. package/es/actions/ui/answers.js +3 -1
  6. package/es/reducers/index.d.ts +1 -1
  7. package/es/reducers/ui/answers.d.ts +4 -2
  8. package/es/reducers/ui/answers.js +6 -3
  9. package/es/reducers/ui/index.d.ts +4 -4
  10. package/es/reducers/ui/slide.d.ts +6 -4
  11. package/es/reducers/ui/slide.js +12 -4
  12. package/es/views/slides/index.js +4 -4
  13. package/lib/actions/api/fetch-correction.js +1 -1
  14. package/lib/actions/api/post-answer.d.ts +6 -0
  15. package/lib/actions/api/post-answer.js +4 -2
  16. package/lib/actions/ui/answers.d.ts +3 -0
  17. package/lib/actions/ui/answers.js +3 -1
  18. package/lib/reducers/index.d.ts +1 -1
  19. package/lib/reducers/ui/answers.d.ts +4 -2
  20. package/lib/reducers/ui/answers.js +6 -3
  21. package/lib/reducers/ui/index.d.ts +4 -4
  22. package/lib/reducers/ui/slide.d.ts +6 -4
  23. package/lib/reducers/ui/slide.js +12 -4
  24. package/lib/views/slides/index.js +4 -4
  25. package/package.json +4 -4
  26. package/src/actions/api/fetch-correction.ts +1 -1
  27. package/src/actions/api/post-answer.ts +5 -1
  28. package/src/actions/api/test/fetch-correction.test.ts +6 -2
  29. package/src/actions/api/test/fetch-rank.test.ts +2 -4
  30. package/src/actions/api/test/fetch-skills.test.ts +2 -4
  31. package/src/actions/api/test/fetch-slide.test.ts +2 -4
  32. package/src/actions/api/test/post-answer.test.ts +52 -13
  33. package/src/actions/api/test/post-progression.test.ts +2 -4
  34. package/src/actions/data/test/token.test.ts +2 -4
  35. package/src/actions/ui/answers.ts +4 -1
  36. package/src/actions/ui/test/answers.test.ts +38 -14
  37. package/src/actions/ui/test/next-slide.test.ts +8 -4
  38. package/src/actions/ui/test/slides.test.ts +2 -4
  39. package/src/reducers/data/test/progression.test.ts +1 -0
  40. package/src/reducers/ui/answers.ts +11 -5
  41. package/src/reducers/ui/index.ts +2 -2
  42. package/src/reducers/ui/slide.ts +30 -9
  43. package/src/reducers/ui/test/answers.test.ts +61 -13
  44. package/src/reducers/ui/test/slide.test.ts +36 -7
  45. package/src/views/skills/test/skills.test.ts +4 -8
  46. package/src/views/slides/index.ts +4 -4
  47. package/src/views/slides/test/index.test.ts +173 -28
  48. package/src/views/slides/test/slide.free-text.on-change.test.ts +7 -2
  49. package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +7 -2
  50. package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +7 -2
  51. package/src/views/slides/test/slide.qcm.on-click.test.ts +7 -2
  52. package/src/views/slides/test/slide.slider.on-change.test.ts +7 -2
  53. package/src/views/slides/test/slide.slider.on-slider-change.test.ts +7 -2
  54. package/src/views/slides/test/slide.template.on-change.test.ts +12 -4
  55. package/es/actions/api/test/fetch-correction.test.d.ts +0 -1
  56. package/es/actions/api/test/fetch-correction.test.js +0 -91
  57. package/es/actions/api/test/fetch-rank.test.d.ts +0 -1
  58. package/es/actions/api/test/fetch-rank.test.js +0 -100
  59. package/es/actions/api/test/fetch-skills.test.d.ts +0 -1
  60. package/es/actions/api/test/fetch-skills.test.js +0 -61
  61. package/es/actions/api/test/fetch-slide.test.d.ts +0 -1
  62. package/es/actions/api/test/fetch-slide.test.js +0 -68
  63. package/es/actions/api/test/post-answer.test.d.ts +0 -1
  64. package/es/actions/api/test/post-answer.test.js +0 -172
  65. package/es/actions/api/test/post-progression.test.d.ts +0 -1
  66. package/es/actions/api/test/post-progression.test.js +0 -109
  67. package/es/actions/data/test/token.test.d.ts +0 -1
  68. package/es/actions/data/test/token.test.js +0 -27
  69. package/es/actions/ui/test/answers.test.d.ts +0 -1
  70. package/es/actions/ui/test/answers.test.js +0 -117
  71. package/es/actions/ui/test/next-slide.test.d.ts +0 -1
  72. package/es/actions/ui/test/next-slide.test.js +0 -63
  73. package/es/actions/ui/test/slides.test.d.ts +0 -1
  74. package/es/actions/ui/test/slides.test.js +0 -28
  75. package/es/reducers/data/test/corrections.test.d.ts +0 -1
  76. package/es/reducers/data/test/corrections.test.js +0 -27
  77. package/es/reducers/data/test/progression.test.d.ts +0 -1
  78. package/es/reducers/data/test/progression.test.js +0 -24
  79. package/es/reducers/data/test/rank.test.d.ts +0 -1
  80. package/es/reducers/data/test/rank.test.js +0 -59
  81. package/es/reducers/data/test/skills.test.d.ts +0 -1
  82. package/es/reducers/data/test/skills.test.js +0 -12
  83. package/es/reducers/data/test/slides.test.d.ts +0 -1
  84. package/es/reducers/data/test/slides.test.js +0 -21
  85. package/es/reducers/data/test/token.test.d.ts +0 -1
  86. package/es/reducers/data/test/token.test.js +0 -11
  87. package/es/reducers/ui/test/answers.test.d.ts +0 -1
  88. package/es/reducers/ui/test/answers.test.js +0 -31
  89. package/es/reducers/ui/test/current-slide-ref.test.d.ts +0 -1
  90. package/es/reducers/ui/test/current-slide-ref.test.js +0 -12
  91. package/es/reducers/ui/test/navigation.test.d.ts +0 -1
  92. package/es/reducers/ui/test/navigation.test.js +0 -15
  93. package/es/reducers/ui/test/slide.test.d.ts +0 -1
  94. package/es/reducers/ui/test/slide.test.js +0 -24
  95. package/es/services/test/fetch-correction.test.d.ts +0 -1
  96. package/es/services/test/fetch-correction.test.js +0 -39
  97. package/es/services/test/fetch-rank.test.d.ts +0 -1
  98. package/es/services/test/fetch-rank.test.js +0 -24
  99. package/es/services/test/fetch-skills.test.d.ts +0 -1
  100. package/es/services/test/fetch-skills.test.js +0 -29
  101. package/es/services/test/fetch-slide.test.d.ts +0 -1
  102. package/es/services/test/fetch-slide.test.js +0 -22
  103. package/es/services/test/post-answer.test.d.ts +0 -1
  104. package/es/services/test/post-answer.test.js +0 -88
  105. package/es/services/test/post-progression.test.d.ts +0 -1
  106. package/es/services/test/post-progression.test.js +0 -56
  107. package/es/views/skills/test/skills.test.d.ts +0 -1
  108. package/es/views/skills/test/skills.test.js +0 -98
  109. package/es/views/slides/test/index.test.d.ts +0 -1
  110. package/es/views/slides/test/index.test.js +0 -979
  111. package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +0 -1
  112. package/es/views/slides/test/map-api-slide-to-ui.test.js +0 -36
  113. package/es/views/slides/test/slide.free-text.on-change.test.d.ts +0 -1
  114. package/es/views/slides/test/slide.free-text.on-change.test.js +0 -72
  115. package/es/views/slides/test/slide.qcm-drag.on-click.test.d.ts +0 -1
  116. package/es/views/slides/test/slide.qcm-drag.on-click.test.js +0 -72
  117. package/es/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +0 -1
  118. package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +0 -72
  119. package/es/views/slides/test/slide.qcm.on-click.test.d.ts +0 -1
  120. package/es/views/slides/test/slide.qcm.on-click.test.js +0 -74
  121. package/es/views/slides/test/slide.slider.on-change.test.d.ts +0 -1
  122. package/es/views/slides/test/slide.slider.on-change.test.js +0 -73
  123. package/es/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
  124. package/es/views/slides/test/slide.slider.on-slider-change.test.js +0 -63
  125. package/es/views/slides/test/slide.template.on-change.test.d.ts +0 -1
  126. package/es/views/slides/test/slide.template.on-change.test.js +0 -85
  127. package/lib/actions/api/test/fetch-correction.test.d.ts +0 -1
  128. package/lib/actions/api/test/fetch-correction.test.js +0 -151
  129. package/lib/actions/api/test/fetch-rank.test.d.ts +0 -1
  130. package/lib/actions/api/test/fetch-rank.test.js +0 -171
  131. package/lib/actions/api/test/fetch-skills.test.d.ts +0 -1
  132. package/lib/actions/api/test/fetch-skills.test.js +0 -120
  133. package/lib/actions/api/test/fetch-slide.test.d.ts +0 -1
  134. package/lib/actions/api/test/fetch-slide.test.js +0 -127
  135. package/lib/actions/api/test/post-answer.test.d.ts +0 -1
  136. package/lib/actions/api/test/post-answer.test.js +0 -254
  137. package/lib/actions/api/test/post-progression.test.d.ts +0 -1
  138. package/lib/actions/api/test/post-progression.test.js +0 -167
  139. package/lib/actions/data/test/token.test.d.ts +0 -1
  140. package/lib/actions/data/test/token.test.js +0 -72
  141. package/lib/actions/ui/test/answers.test.d.ts +0 -1
  142. package/lib/actions/ui/test/answers.test.js +0 -233
  143. package/lib/actions/ui/test/next-slide.test.d.ts +0 -1
  144. package/lib/actions/ui/test/next-slide.test.js +0 -64
  145. package/lib/actions/ui/test/slides.test.d.ts +0 -1
  146. package/lib/actions/ui/test/slides.test.js +0 -73
  147. package/lib/reducers/data/test/corrections.test.d.ts +0 -1
  148. package/lib/reducers/data/test/corrections.test.js +0 -28
  149. package/lib/reducers/data/test/progression.test.d.ts +0 -1
  150. package/lib/reducers/data/test/progression.test.js +0 -24
  151. package/lib/reducers/data/test/rank.test.d.ts +0 -1
  152. package/lib/reducers/data/test/rank.test.js +0 -59
  153. package/lib/reducers/data/test/skills.test.d.ts +0 -1
  154. package/lib/reducers/data/test/skills.test.js +0 -12
  155. package/lib/reducers/data/test/slides.test.d.ts +0 -1
  156. package/lib/reducers/data/test/slides.test.js +0 -22
  157. package/lib/reducers/data/test/token.test.d.ts +0 -1
  158. package/lib/reducers/data/test/token.test.js +0 -11
  159. package/lib/reducers/ui/test/answers.test.d.ts +0 -1
  160. package/lib/reducers/ui/test/answers.test.js +0 -31
  161. package/lib/reducers/ui/test/current-slide-ref.test.d.ts +0 -1
  162. package/lib/reducers/ui/test/current-slide-ref.test.js +0 -12
  163. package/lib/reducers/ui/test/navigation.test.d.ts +0 -1
  164. package/lib/reducers/ui/test/navigation.test.js +0 -15
  165. package/lib/reducers/ui/test/slide.test.d.ts +0 -1
  166. package/lib/reducers/ui/test/slide.test.js +0 -24
  167. package/lib/services/test/fetch-correction.test.d.ts +0 -1
  168. package/lib/services/test/fetch-correction.test.js +0 -95
  169. package/lib/services/test/fetch-rank.test.d.ts +0 -1
  170. package/lib/services/test/fetch-rank.test.js +0 -78
  171. package/lib/services/test/fetch-skills.test.d.ts +0 -1
  172. package/lib/services/test/fetch-skills.test.js +0 -83
  173. package/lib/services/test/fetch-slide.test.d.ts +0 -1
  174. package/lib/services/test/fetch-slide.test.js +0 -76
  175. package/lib/services/test/post-answer.test.d.ts +0 -1
  176. package/lib/services/test/post-answer.test.js +0 -142
  177. package/lib/services/test/post-progression.test.d.ts +0 -1
  178. package/lib/services/test/post-progression.test.js +0 -110
  179. package/lib/views/skills/test/skills.test.d.ts +0 -1
  180. package/lib/views/skills/test/skills.test.js +0 -98
  181. package/lib/views/slides/test/index.test.d.ts +0 -1
  182. package/lib/views/slides/test/index.test.js +0 -990
  183. package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +0 -1
  184. package/lib/views/slides/test/map-api-slide-to-ui.test.js +0 -47
  185. package/lib/views/slides/test/slide.free-text.on-change.test.d.ts +0 -1
  186. package/lib/views/slides/test/slide.free-text.on-change.test.js +0 -74
  187. package/lib/views/slides/test/slide.qcm-drag.on-click.test.d.ts +0 -1
  188. package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +0 -74
  189. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +0 -1
  190. package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +0 -74
  191. package/lib/views/slides/test/slide.qcm.on-click.test.d.ts +0 -1
  192. package/lib/views/slides/test/slide.qcm.on-click.test.js +0 -76
  193. package/lib/views/slides/test/slide.slider.on-change.test.d.ts +0 -1
  194. package/lib/views/slides/test/slide.slider.on-change.test.js +0 -75
  195. package/lib/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
  196. package/lib/views/slides/test/slide.slider.on-slider-change.test.js +0 -65
  197. package/lib/views/slides/test/slide.template.on-change.test.d.ts +0 -1
  198. package/lib/views/slides/test/slide.template.on-change.test.js +0 -88
@@ -1,27 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../corrections';
3
- import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
4
- import { CORRECTION_FETCH_REQUEST, CORRECTION_FETCH_SUCCESS } from '../../../actions/api/fetch-correction';
5
- import { getChoicesCorrection } from '../../../test/util/services.mock';
6
- test('should have an initial empty record value', t => {
7
- const state = reducer(undefined, {});
8
- t.deepEqual(state, {});
9
- });
10
- test("should set the key (slide's id) of the correction to null when a CORRECTION_FETCH_REQUEST is received", t => {
11
- const slideRef = freeTextSlide._id;
12
- const state = reducer({}, { type: CORRECTION_FETCH_REQUEST, meta: { slideRef: freeTextSlide._id } });
13
- t.deepEqual(state, {
14
- [slideRef]: null
15
- });
16
- });
17
- test('should set the value of CORRECTION_FETCH_SUCCESS', t => {
18
- const expectedCorrection = getChoicesCorrection(freeTextSlide._id);
19
- const state = reducer({}, {
20
- type: CORRECTION_FETCH_SUCCESS,
21
- payload: expectedCorrection,
22
- meta: { slideRef: freeTextSlide._id }
23
- });
24
- t.deepEqual(state, {
25
- sli_VJYjJnJhg: expectedCorrection
26
- });
27
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../progression';
3
- import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
4
- import { POST_ANSWER_SUCCESS } from '../../../actions/api/post-answer';
5
- import { postAnswerResponses, postProgressionResponse } from '../../../test/util/services.mock';
6
- import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
7
- test('should have initial value', t => {
8
- const state = reducer(undefined, {});
9
- t.is(state, null);
10
- });
11
- test('should set the value of POST_PROGRESSION_SUCCESS action', t => {
12
- const state = reducer(null, {
13
- type: POST_PROGRESSION_SUCCESS,
14
- payload: postProgressionResponse
15
- });
16
- t.deepEqual(state, postProgressionResponse);
17
- });
18
- test('should set the value of POST_ANSWER_SUCCESS action', t => {
19
- const state = reducer(null, {
20
- type: POST_ANSWER_SUCCESS,
21
- payload: postAnswerResponses[freeTextSlide.universalRef]
22
- });
23
- t.deepEqual(state, postAnswerResponses[freeTextSlide.universalRef]);
24
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,59 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../rank';
3
- import { RANK_FETCH_START_REQUEST, RANK_FETCH_START_SUCCESS, RANK_FETCH_START_FAILURE, RANK_FETCH_END_REQUEST, RANK_FETCH_END_SUCCESS, RANK_FETCH_END_FAILURE } from '../../../actions/api/fetch-rank';
4
- test('should have initial value', t => {
5
- const state = reducer(undefined, {});
6
- t.deepEqual(state, {});
7
- });
8
- test("should set the start value to null if the value doesn't exist of FETCH_START_REQUEST action", t => {
9
- const state = reducer({}, { type: RANK_FETCH_START_REQUEST });
10
- t.deepEqual(state, {
11
- start: null
12
- });
13
- });
14
- test('should do nothing if a start value already exists of FETCH_START_REQUEST action', t => {
15
- const state = reducer({ start: 93 }, { type: RANK_FETCH_START_REQUEST });
16
- t.deepEqual(state, {
17
- start: 93
18
- });
19
- });
20
- test('should set the start value of FETCH_START_SUCCESS action', t => {
21
- const state = reducer({}, { type: RANK_FETCH_START_SUCCESS, payload: { rank: 93 } });
22
- t.deepEqual(state, {
23
- start: 93
24
- });
25
- });
26
- test('should unset the start value if the value is null of FETCH_START_FAILURE action', t => {
27
- const state = reducer({ start: null }, { type: RANK_FETCH_START_FAILURE });
28
- t.deepEqual(state, {});
29
- });
30
- test('should do nothing if the start value already exists of FETCH_START_FAILURE action', t => {
31
- const state = reducer({ start: 93 }, { type: RANK_FETCH_START_FAILURE });
32
- t.deepEqual(state, { start: 93 });
33
- });
34
- test("should set the end value to null if the value doesn't exist of FETCH_END_REQUEST action", t => {
35
- const state = reducer({}, { type: RANK_FETCH_END_REQUEST });
36
- t.deepEqual(state, {
37
- end: null
38
- });
39
- });
40
- test('should do nothing if an end value already exists of FETCH_END_REQUEST action', t => {
41
- const state = reducer({ end: 94 }, { type: RANK_FETCH_END_REQUEST });
42
- t.deepEqual(state, {
43
- end: 94
44
- });
45
- });
46
- test('should set the end value of FETCH_END_SUCCESS action', t => {
47
- const state = reducer({}, { type: RANK_FETCH_END_SUCCESS, payload: { rank: 94 } });
48
- t.deepEqual(state, {
49
- end: 94
50
- });
51
- });
52
- test('should unset the end value if the value is null of FETCH_END_FAILURE action', t => {
53
- const state = reducer({ end: null }, { type: RANK_FETCH_END_FAILURE });
54
- t.deepEqual(state, {});
55
- });
56
- test('should do nothing if the end value already exists of FETCH_END_FAILURE action', t => {
57
- const state = reducer({ end: 94 }, { type: RANK_FETCH_END_FAILURE });
58
- t.deepEqual(state, { end: 94 });
59
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../skills';
3
- import { SKILLS_FETCH_SUCCESS } from '../../../actions/api/fetch-skills';
4
- test('should have initial value', t => {
5
- const state = reducer(undefined, {});
6
- t.deepEqual(state, []);
7
- });
8
- test('should set the value of SKILLS_FETCH_SUCCESS action', t => {
9
- const skills = [{ skillRef: 'skill', name: 'skill name', slidesToReview: 5, custom: false }];
10
- const state = reducer([], { type: SKILLS_FETCH_SUCCESS, payload: skills });
11
- t.deepEqual(state, skills);
12
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,21 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../slides';
3
- import { SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS } from '../../../actions/api/fetch-slide';
4
- import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
5
- test('should have initial value', t => {
6
- const state = reducer(undefined, {});
7
- t.deepEqual(state, {});
8
- });
9
- test('should set the value of SLIDE_FETCH_REQUEST action', t => {
10
- const slideRef = 'sli_VJYjJnJhg';
11
- const state = reducer({}, { type: SLIDE_FETCH_REQUEST, meta: { slideRef } });
12
- t.deepEqual(state, {
13
- [slideRef]: null
14
- });
15
- });
16
- test('should set the value of SLIDE_FETCH_SUCCESS action', t => {
17
- const state = reducer({}, { type: SLIDE_FETCH_SUCCESS, payload: freeTextSlide, meta: { slideRef: 'sli_VJYjJnJhg' } });
18
- t.deepEqual(state, {
19
- sli_VJYjJnJhg: freeTextSlide
20
- });
21
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../token';
3
- import { STORE_TOKEN } from '../../../actions/data/token';
4
- test('should have initial value', t => {
5
- const state = reducer(undefined, {});
6
- t.is(state, '');
7
- });
8
- test('should set the value of STORE_TOKEN action', t => {
9
- const state = reducer('', { type: STORE_TOKEN, payload: 'token' });
10
- t.is(state, 'token');
11
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,31 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../answers';
3
- import { ANSWER_EDIT } from '../../../actions/ui/answers';
4
- test('should have initial value', t => {
5
- const state = reducer(undefined, {});
6
- t.deepEqual(state, []);
7
- });
8
- test('should set the value of EDIT_BASIC action', t => {
9
- const state = reducer([], { type: ANSWER_EDIT.basic, payload: ['value'] });
10
- t.deepEqual(state, ['value']);
11
- });
12
- test('should set the value of EDIT_QCM action', t => {
13
- const state = reducer([], { type: ANSWER_EDIT.qcm, payload: ['value1', 'value2'] });
14
- t.deepEqual(state, ['value1', 'value2']);
15
- });
16
- test('should set the value of EDIT_QCM_GRAPHIC action', t => {
17
- const state = reducer([], { type: ANSWER_EDIT.qcmGraphic, payload: ['True', 'False'] });
18
- t.deepEqual(state, ['True', 'False']);
19
- });
20
- test('should set the value of EDIT_QCM_DRAG action', t => {
21
- const state = reducer([], { type: ANSWER_EDIT.qcmDrag, payload: ['value1', 'value2'] });
22
- t.deepEqual(state, ['value1', 'value2']);
23
- });
24
- test('should set the value of EDIT_SLIDER action', t => {
25
- const state = reducer([], { type: ANSWER_EDIT.slider, payload: ['5'] });
26
- t.deepEqual(state, ['5']);
27
- });
28
- test('should set the value of EDIT_TEMPLATE action', t => {
29
- const state = reducer([], { type: ANSWER_EDIT.template, payload: ['value1', 'value2'] });
30
- t.deepEqual(state, ['value1', 'value2']);
31
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,12 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../current-slide-ref';
3
- import { SET_CURRENT_SLIDE } from '../../../actions/ui/slides';
4
- import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
5
- test('should have initial value', t => {
6
- const state = reducer(undefined, {});
7
- t.is(state, '');
8
- });
9
- test('should set the value of SET_CURRENT_SLIDE action', t => {
10
- const state = reducer('', { type: SET_CURRENT_SLIDE, payload: freeTextSlide });
11
- t.is(state, 'sli_VJYjJnJhg');
12
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- import test from 'ava';
2
- import reducer from '../navigation';
3
- import { navigateBack, navigateTo } from '../../../actions/ui/navigation';
4
- test('should have initial value', t => {
5
- const state = reducer(undefined, {});
6
- t.deepEqual(state, []);
7
- });
8
- test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
9
- const state = reducer([], navigateTo('loader'));
10
- t.deepEqual(state, ['loader']);
11
- const updatedState = reducer(state, navigateTo('skills'));
12
- t.deepEqual(updatedState, ['loader', 'skills']);
13
- const _updatedState = reducer(updatedState, navigateBack());
14
- t.deepEqual(_updatedState, ['loader']);
15
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- import test from 'ava';
2
- import reducer, { initialState } from '../slide';
3
- import { EDIT_BASIC } from '../../../actions/ui/answers';
4
- import { CORRECTION_FETCH_SUCCESS } from '../../../actions/api/fetch-correction';
5
- test('should use initial state if no answers are found when an EditAnswerAction is received', t => {
6
- const state = reducer(undefined, { type: EDIT_BASIC, payload: [''] });
7
- t.truthy(state);
8
- t.false(state.validateButton);
9
- t.falsy(state.animateCorrectionPopin);
10
- });
11
- test('should set animateCorrectionPopin to true if CORRECTION_FETCH_SUCCESS is received', t => {
12
- const state = reducer(undefined, {
13
- type: CORRECTION_FETCH_SUCCESS,
14
- payload: undefined,
15
- meta: { slideRef: '1234' }
16
- });
17
- t.truthy(state);
18
- t.false(state.validateButton);
19
- t.true(state.animateCorrectionPopin);
20
- });
21
- test('should return state directly when there is no corresponding action handler + have an initial state', t => {
22
- const state = reducer(undefined, { type: 'NOPE' });
23
- t.deepEqual(state, initialState);
24
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,39 +0,0 @@
1
- import test from 'ava';
2
- import nock from 'nock';
3
- import { fetchCorrection } from '../fetch-correction';
4
- const progressionId = '123456789123';
5
- const slideRef = 'sli_123546';
6
- const answer = ['Lister vos tâches pour vous libérer l’esprit', '15 jours à Bora Bora'];
7
- const correction = {
8
- correctAnswer: ['15 jours à Bora Bora'],
9
- corrections: [
10
- {
11
- answer: answer[0],
12
- isCorrect: false
13
- },
14
- {
15
- answer: answer[1],
16
- isCorrect: true
17
- }
18
- ]
19
- };
20
- test.before(() => {
21
- nock('http://localhost:3000')
22
- .post(`/api/v2/progressions/${progressionId}/answers/${slideRef}`, JSON.stringify({
23
- answer
24
- }))
25
- .reply(200, correction);
26
- });
27
- test.after(() => {
28
- nock.cleanAll();
29
- });
30
- test('should fetch the correction of the slide for the specified progression successfully', async (t) => {
31
- const token = process.env.API_TEST_TOKEN || '';
32
- const response = await fetchCorrection(slideRef, token, progressionId, answer);
33
- t.deepEqual(correction, response);
34
- });
35
- test('should reject if a bad token is passed', async (t) => {
36
- const badToken = 'token is not a jwt';
37
- const error = await t.throwsAsync(() => fetchCorrection(slideRef, badToken, progressionId, answer));
38
- t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
39
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- import test from 'ava';
2
- import nock from 'nock';
3
- import { fetchRank } from '../fetch-rank';
4
- const result = {
5
- rank: 93
6
- };
7
- test.before(() => {
8
- nock('http://localhost:3000')
9
- .get('/api/v1/leaderboard/rank/592d830b240b923f00bffba6?group=ALL')
10
- .reply(200, result);
11
- });
12
- test.after(() => {
13
- nock.cleanAll();
14
- });
15
- test('should fetch rank with success', async (t) => {
16
- const token = process.env.API_TEST_TOKEN || '';
17
- const rank = await fetchRank(token);
18
- t.deepEqual(result, rank);
19
- });
20
- test('should reject bad token', async (t) => {
21
- const badToken = 'token is not a jwt';
22
- const error = await t.throwsAsync(() => fetchRank(badToken));
23
- t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
24
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,29 +0,0 @@
1
- import test from 'ava';
2
- import nock from 'nock';
3
- import { fetchSkills } from '../fetch-skills';
4
- const result = [
5
- {
6
- slidesToReview: 1,
7
- name: 'skill-test',
8
- custom: false,
9
- skillRef: '_skill-ref'
10
- }
11
- ];
12
- test.before(() => {
13
- nock('http://localhost:3000')
14
- .get('/api/v2/skills/review/user/592d830b240b923f00bffba6')
15
- .reply(200, result);
16
- });
17
- test.after(() => {
18
- nock.cleanAll();
19
- });
20
- test('should fetch skills with success', async (t) => {
21
- const token = process.env.API_TEST_TOKEN || '';
22
- const skills = await fetchSkills(token);
23
- t.deepEqual(result, skills);
24
- });
25
- test('should reject bad token', async (t) => {
26
- const badToken = 'token is not a jwt';
27
- const error = await t.throwsAsync(() => fetchSkills(badToken));
28
- t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
29
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- import test from 'ava';
2
- import nock from 'nock';
3
- import { qcmDragSlide } from '../../views/slides/test/fixtures/qcm-drag';
4
- import { fetchSlide } from '../fetch-slide';
5
- test.before(() => {
6
- nock('http://localhost:3000')
7
- .get('/api/v1/slides/sli_123546/parentContentTitle')
8
- .reply(200, qcmDragSlide);
9
- });
10
- test.after(() => {
11
- nock.cleanAll();
12
- });
13
- test('should fetch a slide with the parentTitleContent info successfully', async (t) => {
14
- const token = process.env.API_TEST_TOKEN || '';
15
- const slide = await fetchSlide('sli_123546', token);
16
- t.deepEqual(qcmDragSlide, slide);
17
- });
18
- test('should reject if a bad token is passed', async (t) => {
19
- const badToken = 'token is not a jwt';
20
- const error = await t.throwsAsync(() => fetchSlide('sli_123546', badToken));
21
- t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
22
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,88 +0,0 @@
1
- import test from 'ava';
2
- import nock from 'nock';
3
- import { postAnswer } from '../post-answer';
4
- const skillRef = '_skill-ref';
5
- const answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
6
- const initProgression = {
7
- content: {
8
- type: 'skill',
9
- ref: skillRef
10
- },
11
- engine: {
12
- ref: 'review'
13
- },
14
- _id: '123456123456',
15
- state: {
16
- allAnswers: [],
17
- isCorrect: true,
18
- nextContent: {
19
- type: 'slide',
20
- ref: 'sli_NkvrWPFF2'
21
- },
22
- pendingSlides: [],
23
- slides: [],
24
- step: {
25
- current: 1
26
- },
27
- stars: 0
28
- }
29
- };
30
- const result = {
31
- content: {
32
- type: 'skill',
33
- ref: skillRef
34
- },
35
- engine: {
36
- ref: 'review'
37
- },
38
- _id: '123456123456',
39
- state: {
40
- allAnswers: [
41
- {
42
- slideRef: 'sli_NkvrWPFF2',
43
- isCorrect: true,
44
- answer
45
- }
46
- ],
47
- isCorrect: true,
48
- nextContent: {
49
- type: 'slide',
50
- ref: 'sli_NJ3m5KtWh'
51
- },
52
- pendingSlides: [],
53
- slides: ['sli_NkvrWPFF2'],
54
- content: {
55
- ref: 'sli_NkvrWPFF2',
56
- type: 'slide'
57
- },
58
- step: {
59
- current: 2
60
- },
61
- stars: 4
62
- }
63
- };
64
- test.before(() => {
65
- const moocApi = nock('http://localhost:3000');
66
- moocApi
67
- .post('/api/v2/progressions/123456123456/answers', {
68
- content: {
69
- ref: 'sli_NkvrWPFF2',
70
- type: 'slide'
71
- },
72
- answer
73
- })
74
- .reply(200, result);
75
- });
76
- test.after(() => {
77
- nock.cleanAll();
78
- });
79
- test('should post the answers successfully', async (t) => {
80
- const token = process.env.API_TEST_TOKEN || '';
81
- const progression = await postAnswer(initProgression, token, answer);
82
- t.deepEqual(result, progression);
83
- });
84
- test('should reject bad token', async (t) => {
85
- const badToken = 'token is not a jwt';
86
- const error = await t.throwsAsync(() => postAnswer(initProgression, badToken, answer));
87
- t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
88
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,56 +0,0 @@
1
- import test from 'ava';
2
- import nock from 'nock';
3
- import { postProgression } from '../post-progression';
4
- const skillRef = '_skill-ref';
5
- const result = {
6
- _id: '123456123456',
7
- content: {
8
- ref: '_skill-ref',
9
- type: 'skill'
10
- },
11
- engine: {
12
- ref: 'review'
13
- },
14
- state: {
15
- allAnswers: [],
16
- isCorrect: true,
17
- nextContent: {
18
- type: 'slide',
19
- ref: 'sli_NJ3m5KtWh'
20
- },
21
- pendingSlides: [],
22
- slides: [],
23
- step: {
24
- current: 1
25
- },
26
- stars: 0
27
- }
28
- };
29
- test.before(() => {
30
- const moocApi = nock('http://localhost:3000');
31
- moocApi
32
- .post('/api/v2/progressions', {
33
- content: {
34
- ref: '_skill-ref',
35
- type: 'skill'
36
- },
37
- engine: {
38
- ref: 'review',
39
- version: '1'
40
- }
41
- })
42
- .reply(200, result);
43
- });
44
- test.after(() => {
45
- nock.cleanAll();
46
- });
47
- test('should create progression with success', async (t) => {
48
- const token = process.env.API_TEST_TOKEN || '';
49
- const progression = await postProgression(skillRef, token);
50
- t.deepEqual(result, progression);
51
- });
52
- test('should reject bad token', async (t) => {
53
- const badToken = 'token is not a jwt';
54
- const error = await t.throwsAsync(() => postProgression(skillRef, badToken));
55
- t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
56
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,98 +0,0 @@
1
- import test from 'ava';
2
- import map from 'lodash/fp/map';
3
- import omit from 'lodash/fp/omit';
4
- import { mapStateToSkillsProps } from '..';
5
- test('should create initial props when there are no skills on the state', t => {
6
- const state = {
7
- data: {
8
- progression: null,
9
- skills: [],
10
- slides: {},
11
- token: '1234',
12
- corrections: {},
13
- rank: {}
14
- },
15
- ui: {
16
- currentSlideRef: '',
17
- navigation: ['loader', 'skills'],
18
- answers: [],
19
- slide: {
20
- validateButton: false
21
- }
22
- }
23
- };
24
- const props = mapStateToSkillsProps(state);
25
- t.deepEqual(props, {
26
- title: '@todo title',
27
- titleNoSkills: '@todo titleNoSkills',
28
- textNoSkills: '@todo textNoSkills',
29
- iconSkillAriaLabel: '@todo iconSkillAriaLabel',
30
- isLoading: false,
31
- isLoadingAriaLabel: '@todo loading',
32
- listSkills: []
33
- });
34
- });
35
- test('should create initial props when skills on the state', t => {
36
- const state = {
37
- data: {
38
- progression: null,
39
- skills: [
40
- {
41
- skillRef: '_skill-ref',
42
- slidesToReview: 2,
43
- name: 'skill-test',
44
- custom: false
45
- },
46
- {
47
- skillRef: '_skill-ref-2',
48
- slidesToReview: 5,
49
- name: 'skill-test-2',
50
- custom: true
51
- }
52
- ],
53
- slides: {},
54
- token: '1234',
55
- corrections: {},
56
- rank: {}
57
- },
58
- ui: {
59
- currentSlideRef: '',
60
- navigation: ['loader', 'skills'],
61
- answers: [],
62
- slide: {
63
- validateButton: false
64
- }
65
- }
66
- };
67
- const props = mapStateToSkillsProps(state);
68
- t.deepEqual(omit('listSkills', props), {
69
- title: '@todo title',
70
- titleNoSkills: '@todo titleNoSkills',
71
- textNoSkills: '@todo textNoSkills',
72
- iconSkillAriaLabel: '@todo iconSkillAriaLabel',
73
- isLoading: false,
74
- isLoadingAriaLabel: '@todo loading'
75
- });
76
- t.deepEqual(map(omit('onClick'), props.listSkills), [
77
- {
78
- 'aria-label': '',
79
- isCustom: false,
80
- skillTitle: 'skill-test',
81
- skillAriaLabel: '@todo skill aria label',
82
- buttonLabel: '@todo button',
83
- buttonAriaLabel: '@todo button aria label',
84
- reviseLabel: '@todo revise',
85
- reviseAriaLabel: '@todo revise aria label'
86
- },
87
- {
88
- 'aria-label': '',
89
- isCustom: true,
90
- skillTitle: 'skill-test-2',
91
- skillAriaLabel: '@todo skill aria label',
92
- buttonLabel: '@todo button',
93
- buttonAriaLabel: '@todo button aria label',
94
- reviseLabel: '@todo revise',
95
- reviseAriaLabel: '@todo revise aria label'
96
- }
97
- ]);
98
- });