@coorpacademy/app-review 0.1.16 → 0.1.17

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 (183) hide show
  1. package/es/actions/api/fetch-skills.d.ts +3 -3
  2. package/es/actions/api/fetch-skills.js +7 -2
  3. package/es/actions/api/fetch-slide.d.ts +1 -1
  4. package/es/actions/api/fetch-slide.js +3 -1
  5. package/es/actions/api/post-answer.d.ts +10 -0
  6. package/es/actions/api/post-answer.js +25 -0
  7. package/es/actions/api/post-progression.d.ts +3 -3
  8. package/es/actions/api/post-progression.js +5 -2
  9. package/es/actions/api/test/fetch-skills.test.js +7 -4
  10. package/es/actions/api/test/fetch-slide.test.js +7 -4
  11. package/es/actions/api/test/post-answer.test.d.ts +1 -0
  12. package/es/actions/api/test/post-answer.test.js +82 -0
  13. package/es/actions/api/test/post-progression.test.js +7 -4
  14. package/es/actions/data/test/token.test.d.ts +1 -0
  15. package/es/actions/data/test/token.test.js +25 -0
  16. package/es/actions/index.d.ts +1 -8
  17. package/es/actions/{api/test → test}/create-test-store.d.ts +2 -2
  18. package/es/actions/{api/test → test}/create-test-store.js +1 -1
  19. package/es/actions/ui/answers.d.ts +17 -3
  20. package/es/actions/ui/answers.js +39 -3
  21. package/es/actions/ui/slides.d.ts +0 -5
  22. package/es/actions/ui/slides.js +0 -4
  23. package/es/actions/ui/test/answers.test.d.ts +1 -0
  24. package/es/actions/ui/test/answers.test.js +90 -0
  25. package/es/actions/ui/test/slides.test.d.ts +1 -0
  26. package/es/actions/ui/test/slides.test.js +26 -0
  27. package/es/common/index.d.ts +0 -3
  28. package/es/common/index.js +0 -4
  29. package/es/index.js +1 -3
  30. package/es/reducers/data/index.d.ts +1 -1
  31. package/es/reducers/data/progression.d.ts +2 -3
  32. package/es/reducers/data/progression.js +0 -5
  33. package/es/reducers/data/slides.d.ts +2 -3
  34. package/es/reducers/data/test/progression.test.js +1 -1
  35. package/es/reducers/index.d.ts +2 -1
  36. package/es/reducers/ui/answers.d.ts +2 -2
  37. package/es/reducers/ui/answers.js +4 -8
  38. package/es/reducers/ui/index.d.ts +4 -1
  39. package/es/reducers/ui/index.js +3 -1
  40. package/es/reducers/ui/slide.d.ts +8 -0
  41. package/es/reducers/ui/slide.js +26 -0
  42. package/es/reducers/ui/test/answers.test.js +19 -3
  43. package/es/reducers/ui/test/current-slide-ref.test.js +1 -1
  44. package/es/reducers/ui/test/navigation.test.js +5 -5
  45. package/es/reducers/ui/test/slide.test.d.ts +1 -0
  46. package/es/reducers/ui/test/slide.test.js +12 -0
  47. package/es/test/util/services.mock.d.ts +2 -1
  48. package/es/test/util/services.mock.js +86 -72
  49. package/es/types/common.d.ts +0 -25
  50. package/es/views/skills/index.d.ts +1 -1
  51. package/es/views/skills/index.js +0 -3
  52. package/es/views/skills/test/skills.test.d.ts +1 -0
  53. package/es/views/skills/test/skills.test.js +94 -0
  54. package/es/views/slides/index.d.ts +13 -2
  55. package/es/views/slides/index.js +18 -14
  56. package/es/views/slides/map-api-slide-to-ui.js +44 -51
  57. package/es/views/slides/test/fixtures/free-text.d.ts +2 -1
  58. package/es/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
  59. package/es/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
  60. package/es/views/slides/test/fixtures/qcm.d.ts +2 -1
  61. package/es/views/slides/test/fixtures/select-template.d.ts +2 -1
  62. package/es/views/slides/test/fixtures/slider.d.ts +2 -1
  63. package/es/views/slides/test/fixtures/text-template.d.ts +2 -1
  64. package/es/views/slides/test/index.test.d.ts +1 -0
  65. package/es/views/slides/test/index.test.js +234 -0
  66. package/lib/actions/api/fetch-skills.d.ts +3 -3
  67. package/lib/actions/api/fetch-skills.js +22 -19
  68. package/lib/actions/api/fetch-slide.d.ts +1 -1
  69. package/lib/actions/api/fetch-slide.js +3 -1
  70. package/lib/actions/api/post-answer.d.ts +10 -0
  71. package/lib/actions/api/post-answer.js +75 -0
  72. package/lib/actions/api/post-progression.d.ts +3 -3
  73. package/lib/actions/api/post-progression.js +6 -3
  74. package/lib/actions/api/test/fetch-skills.test.js +7 -4
  75. package/lib/actions/api/test/fetch-slide.test.js +7 -4
  76. package/lib/actions/api/test/post-answer.test.d.ts +1 -0
  77. package/lib/actions/api/test/post-answer.test.js +145 -0
  78. package/lib/actions/api/test/post-progression.test.js +7 -4
  79. package/lib/actions/data/test/token.test.d.ts +1 -0
  80. package/lib/actions/data/test/token.test.js +70 -0
  81. package/lib/actions/index.d.ts +1 -8
  82. package/lib/actions/{api/test → test}/create-test-store.d.ts +2 -2
  83. package/lib/actions/{api/test → test}/create-test-store.js +1 -1
  84. package/lib/actions/ui/answers.d.ts +17 -3
  85. package/lib/actions/ui/answers.js +48 -3
  86. package/lib/actions/ui/slides.d.ts +0 -5
  87. package/lib/actions/ui/slides.js +0 -4
  88. package/lib/actions/ui/test/answers.test.d.ts +1 -0
  89. package/lib/actions/ui/test/answers.test.js +171 -0
  90. package/lib/actions/ui/test/slides.test.d.ts +1 -0
  91. package/lib/actions/ui/test/slides.test.js +71 -0
  92. package/lib/common/index.d.ts +0 -3
  93. package/lib/common/index.js +0 -4
  94. package/lib/index.js +1 -3
  95. package/lib/reducers/data/index.d.ts +1 -1
  96. package/lib/reducers/data/progression.d.ts +2 -3
  97. package/lib/reducers/data/progression.js +0 -5
  98. package/lib/reducers/data/slides.d.ts +2 -3
  99. package/lib/reducers/data/test/progression.test.js +1 -1
  100. package/lib/reducers/index.d.ts +2 -1
  101. package/lib/reducers/ui/answers.d.ts +2 -2
  102. package/lib/reducers/ui/answers.js +4 -8
  103. package/lib/reducers/ui/index.d.ts +4 -1
  104. package/lib/reducers/ui/index.js +3 -1
  105. package/lib/reducers/ui/slide.d.ts +8 -0
  106. package/lib/reducers/ui/slide.js +27 -0
  107. package/lib/reducers/ui/test/answers.test.js +19 -3
  108. package/lib/reducers/ui/test/current-slide-ref.test.js +1 -1
  109. package/lib/reducers/ui/test/navigation.test.js +5 -5
  110. package/lib/reducers/ui/test/slide.test.d.ts +1 -0
  111. package/lib/reducers/ui/test/slide.test.js +12 -0
  112. package/lib/test/util/services.mock.d.ts +2 -1
  113. package/lib/test/util/services.mock.js +86 -72
  114. package/lib/types/common.d.ts +0 -25
  115. package/lib/views/skills/index.d.ts +1 -1
  116. package/lib/views/skills/index.js +0 -3
  117. package/lib/views/skills/test/skills.test.d.ts +1 -0
  118. package/lib/views/skills/test/skills.test.js +94 -0
  119. package/lib/views/slides/index.d.ts +13 -2
  120. package/lib/views/slides/index.js +18 -14
  121. package/lib/views/slides/map-api-slide-to-ui.js +77 -76
  122. package/lib/views/slides/test/fixtures/free-text.d.ts +2 -1
  123. package/lib/views/slides/test/fixtures/qcm-drag.d.ts +2 -1
  124. package/lib/views/slides/test/fixtures/qcm-graphic.d.ts +2 -1
  125. package/lib/views/slides/test/fixtures/qcm.d.ts +2 -1
  126. package/lib/views/slides/test/fixtures/select-template.d.ts +2 -1
  127. package/lib/views/slides/test/fixtures/slider.d.ts +2 -1
  128. package/lib/views/slides/test/fixtures/text-template.d.ts +2 -1
  129. package/lib/views/slides/test/index.test.d.ts +1 -0
  130. package/lib/views/slides/test/index.test.js +234 -0
  131. package/package.json +6 -5
  132. package/src/actions/api/fetch-skills.ts +18 -11
  133. package/src/actions/api/fetch-slide.ts +3 -1
  134. package/src/actions/api/post-answer.ts +39 -0
  135. package/src/actions/api/post-progression.ts +7 -4
  136. package/src/actions/api/test/fetch-skills.test.ts +9 -6
  137. package/src/actions/api/test/fetch-slide.test.ts +9 -6
  138. package/src/actions/api/test/post-answer.test.ts +101 -0
  139. package/src/actions/api/test/post-progression.test.ts +9 -6
  140. package/src/actions/data/test/token.test.ts +29 -0
  141. package/src/actions/index.ts +1 -17
  142. package/src/actions/{api/test → test}/create-test-store.ts +2 -2
  143. package/src/actions/ui/answers.ts +52 -5
  144. package/src/actions/ui/slides.ts +1 -8
  145. package/src/actions/ui/test/answers.test.ts +103 -0
  146. package/src/actions/ui/test/slides.test.ts +30 -0
  147. package/src/common/index.ts +0 -7
  148. package/src/index.tsx +1 -3
  149. package/src/reducers/data/progression.ts +2 -7
  150. package/src/reducers/data/slides.ts +2 -3
  151. package/src/reducers/data/test/progression.test.ts +3 -3
  152. package/src/reducers/ui/answers.ts +5 -9
  153. package/src/reducers/ui/index.ts +4 -1
  154. package/src/reducers/ui/slide.ts +43 -0
  155. package/src/reducers/ui/test/answers.test.ts +24 -4
  156. package/src/reducers/ui/test/current-slide-ref.test.ts +1 -1
  157. package/src/reducers/ui/test/navigation.test.ts +5 -5
  158. package/src/reducers/ui/test/slide.test.ts +15 -0
  159. package/src/test/util/services.mock.ts +91 -73
  160. package/src/types/common.ts +0 -30
  161. package/src/views/skills/index.ts +1 -5
  162. package/src/views/skills/test/skills.test.ts +101 -0
  163. package/src/views/slides/index.ts +37 -22
  164. package/src/views/slides/map-api-slide-to-ui.ts +89 -89
  165. package/src/views/slides/test/fixtures/free-text.ts +2 -1
  166. package/src/views/slides/test/fixtures/qcm-drag.ts +2 -1
  167. package/src/views/slides/test/fixtures/qcm-graphic.ts +2 -1
  168. package/src/views/slides/test/fixtures/qcm.ts +2 -1
  169. package/src/views/slides/test/fixtures/select-template.ts +2 -1
  170. package/src/views/slides/test/fixtures/slider.ts +2 -1
  171. package/src/views/slides/test/fixtures/text-template.ts +2 -1
  172. package/src/views/slides/test/index.test.ts +240 -0
  173. package/src/views/slides/test/map-api-slide-to-ui.test.ts +2 -1
  174. package/es/fixtures/qcm-slide.d.ts +0 -2
  175. package/es/fixtures/qcm-slide.js +0 -33
  176. package/es/fixtures/temp-fixture.d.ts +0 -3
  177. package/es/fixtures/temp-fixture.js +0 -84
  178. package/lib/fixtures/qcm-slide.d.ts +0 -2
  179. package/lib/fixtures/qcm-slide.js +0 -33
  180. package/lib/fixtures/temp-fixture.d.ts +0 -3
  181. package/lib/fixtures/temp-fixture.js +0 -84
  182. package/src/fixtures/qcm-slide.ts +0 -35
  183. package/src/fixtures/temp-fixture.ts +0 -94
@@ -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").ReceiveProgression | import("../../actions/api/fetch-skills").ReceivedSkills | import("./slides").SlidesAction | import("../../actions/data/token").StoreToken>;
17
+ }>, 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,6 +1,5 @@
1
- import { ValidateSlide } from '../../actions/ui/slides';
2
- import { ReceiveProgression } from '../../actions/api/post-progression';
1
+ import { ReceivedProgression } from '../../actions/api/post-progression';
3
2
  import { ProgressionFromAPI } from '../../types/common';
4
3
  export declare type ProgressionState = ProgressionFromAPI | null;
5
- declare const reducer: (state: ProgressionState | undefined, action: ValidateSlide | ReceiveProgression) => ProgressionState;
4
+ declare const reducer: (state: ProgressionState | undefined, action: ReceivedProgression) => ProgressionState;
6
5
  export default reducer;
@@ -1,13 +1,8 @@
1
- import { VALIDATE_SLIDE } from '../../actions/ui/slides';
2
1
  import { POST_PROGRESSION_SUCCESS } from '../../actions/api/post-progression';
3
2
  const reducer = (
4
3
  // eslint-disable-next-line default-param-last
5
4
  state = null, action) => {
6
5
  switch (action.type) {
7
- case VALIDATE_SLIDE: {
8
- // TODO: fix on VALIDATE ticket -> launch a POST PROGRESSION
9
- return state;
10
- }
11
6
  case POST_PROGRESSION_SUCCESS: {
12
7
  const progression = action.payload;
13
8
  return progression;
@@ -1,8 +1,7 @@
1
- import { ValidateSlide } from '../../actions/ui/slides';
2
1
  import { ReceivedSlide, FetchSlide } from '../../actions/api/fetch-slide';
3
2
  import { SlideFromAPI } from '../../types/common';
4
- export declare type SlidesAction = FetchSlide | ReceivedSlide | ValidateSlide;
5
- export declare type SlidesState = Record<string, SlideFromAPI>;
3
+ export declare type SlidesAction = FetchSlide | ReceivedSlide;
4
+ export declare type SlidesState = Record<string, SlideFromAPI | null>;
6
5
  export declare const initialState: SlidesState;
7
6
  declare const reducer: (state: SlidesState | undefined, action: SlidesAction) => SlidesState;
8
7
  export default reducer;
@@ -1,7 +1,7 @@
1
1
  import test from 'ava';
2
2
  import reducer from '../progression';
3
3
  import { POST_PROGRESSION_SUCCESS } from '../../../actions/api/post-progression';
4
- test('should have inital value', t => {
4
+ test('should have initial value', t => {
5
5
  const state = reducer(undefined, {});
6
6
  t.is(state, null);
7
7
  });
@@ -15,6 +15,7 @@ declare const _default: import("redux").Reducer<import("redux").CombinedState<{
15
15
  currentSlideRef: string;
16
16
  navigation: import("./ui/navigation").NavigationState;
17
17
  answers: import("./ui/answers").AnswerState;
18
+ slide: import("./ui/slide").UISlideState;
18
19
  }>;
19
- }>, import("../actions/ui/slides").SetCurrentSlide | import("../actions/api/post-progression").ReceiveProgression | 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").EditBasicAction>;
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
21
  export default _default;
@@ -1,4 +1,4 @@
1
- import { EditBasicAction } from '../../actions/ui/answers';
1
+ import { EditAnswerAction } from '../../actions/ui/answers';
2
2
  export declare type AnswerState = string[];
3
- declare const reducer: (state: AnswerState | undefined, action: EditBasicAction) => AnswerState;
3
+ declare const reducer: (state: AnswerState | undefined, action: EditAnswerAction) => AnswerState;
4
4
  export default reducer;
@@ -1,13 +1,9 @@
1
- import { EDIT_BASIC } from '../../actions/ui/answers';
1
+ import { includes, values } from 'lodash/fp';
2
+ import { ANSWER_EDIT } from '../../actions/ui/answers';
3
+ const ANSWER_EDIT_ACTIONS = values(ANSWER_EDIT);
2
4
  const reducer = (
3
5
  // eslint-disable-next-line default-param-last
4
6
  state = [], action) => {
5
- switch (action.type) {
6
- case EDIT_BASIC: {
7
- return action.payload;
8
- }
9
- default:
10
- return state;
11
- }
7
+ return includes(action.type, ANSWER_EDIT_ACTIONS) ? action.payload : state;
12
8
  };
13
9
  export default reducer;
@@ -1,14 +1,17 @@
1
1
  import { CurrentSlideRefState } from './current-slide-ref';
2
2
  import { NavigationState } from './navigation';
3
3
  import { AnswerState } from './answers';
4
+ import { UISlideState } from './slide';
4
5
  export declare type UIState = {
5
6
  currentSlideRef: CurrentSlideRefState;
6
7
  navigation: NavigationState;
7
8
  answers: AnswerState;
9
+ slide: UISlideState;
8
10
  };
9
11
  declare const _default: import("redux").Reducer<import("redux").CombinedState<{
10
12
  currentSlideRef: string;
11
13
  navigation: NavigationState;
12
14
  answers: AnswerState;
13
- }>, import("../../actions/ui/slides").SetCurrentSlide | import("../../actions/ui/navigation").NavigateTo | import("../../actions/ui/navigation").NavigateBack | import("../../actions/ui/answers").EditBasicAction>;
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>;
14
17
  export default _default;
@@ -2,8 +2,10 @@ import { combineReducers } from 'redux';
2
2
  import currentSlideRef from './current-slide-ref';
3
3
  import navigation from './navigation';
4
4
  import answers from './answers';
5
+ import slide from './slide';
5
6
  export default combineReducers({
6
7
  currentSlideRef,
7
8
  navigation,
8
- answers
9
+ answers,
10
+ slide
9
11
  });
@@ -0,0 +1,8 @@
1
+ import { EditAnswerAction } from '../../actions/ui/answers';
2
+ import { PostAnswerRequestAction } from '../../actions/api/post-answer';
3
+ export declare type UISlideState = {
4
+ validateButton: boolean;
5
+ };
6
+ export declare const initialState: UISlideState;
7
+ declare const reducer: (state: UISlideState | undefined, action: PostAnswerRequestAction | EditAnswerAction) => UISlideState;
8
+ export default reducer;
@@ -0,0 +1,26 @@
1
+ import compact from 'lodash/fp/compact';
2
+ import isEmpty from 'lodash/fp/isEmpty';
3
+ import pipe from 'lodash/fp/pipe';
4
+ import { EDIT_BASIC, EDIT_QCM, EDIT_QCM_DRAG, EDIT_QCM_GRAPHIC, EDIT_SLIDER, EDIT_TEMPLATE } from '../../actions/ui/answers';
5
+ import { POST_ANSWER_REQUEST } from '../../actions/api/post-answer';
6
+ export const initialState = { validateButton: false };
7
+ const reducer = (
8
+ // eslint-disable-next-line default-param-last
9
+ state = initialState, action) => {
10
+ switch (action.type) {
11
+ case EDIT_QCM:
12
+ case EDIT_QCM_GRAPHIC:
13
+ case EDIT_QCM_DRAG:
14
+ case EDIT_TEMPLATE:
15
+ case EDIT_BASIC:
16
+ case EDIT_SLIDER: {
17
+ return pipe(compact, isEmpty)(action.payload) ? initialState : { validateButton: true };
18
+ }
19
+ case POST_ANSWER_REQUEST: {
20
+ return initialState;
21
+ }
22
+ default:
23
+ return state;
24
+ }
25
+ };
26
+ export default reducer;
@@ -1,11 +1,27 @@
1
1
  import test from 'ava';
2
2
  import reducer from '../answers';
3
- import { EDIT_BASIC } from '../../../actions/ui/answers';
4
- test('should have inital value', t => {
3
+ import { ANSWER_EDIT } from '../../../actions/ui/answers';
4
+ test('should have initial value', t => {
5
5
  const state = reducer(undefined, {});
6
6
  t.deepEqual(state, []);
7
7
  });
8
8
  test('should set the value of EDIT_BASIC action', t => {
9
- const state = reducer([], { type: EDIT_BASIC, payload: ['value'] });
9
+ const state = reducer([], { type: ANSWER_EDIT.basic, payload: ['value'] });
10
10
  t.deepEqual(state, ['value']);
11
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
+ });
@@ -2,7 +2,7 @@ import test from 'ava';
2
2
  import reducer from '../current-slide-ref';
3
3
  import { SET_CURRENT_SLIDE } from '../../../actions/ui/slides';
4
4
  import { freeTextSlide } from '../../../views/slides/test/fixtures/free-text';
5
- test('should have inital value', t => {
5
+ test('should have initial value', t => {
6
6
  const state = reducer(undefined, {});
7
7
  t.is(state, '');
8
8
  });
@@ -1,15 +1,15 @@
1
1
  import test from 'ava';
2
2
  import reducer from '../navigation';
3
- import { NAVIGATE_TO, NAVIGATE_BACK } from '../../../actions/ui/navigation';
4
- test('should have inital value', t => {
3
+ import { navigateBack, navigateTo } from '../../../actions/ui/navigation';
4
+ test('should have initial value', t => {
5
5
  const state = reducer(undefined, {});
6
6
  t.deepEqual(state, []);
7
7
  });
8
8
  test('should set the value of NAVIGATE_TO and NAVIGATE_BACK action', t => {
9
- const state = reducer([], { type: NAVIGATE_TO, payload: 'loader' });
9
+ const state = reducer([], navigateTo('loader'));
10
10
  t.deepEqual(state, ['loader']);
11
- const updatedState = reducer(state, { type: NAVIGATE_TO, payload: 'skills' });
11
+ const updatedState = reducer(state, navigateTo('skills'));
12
12
  t.deepEqual(updatedState, ['loader', 'skills']);
13
- const _updatedState = reducer(updatedState, { type: NAVIGATE_BACK });
13
+ const _updatedState = reducer(updatedState, navigateBack());
14
14
  t.deepEqual(_updatedState, ['loader']);
15
15
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import test from 'ava';
2
+ import reducer, { initialState } from '../slide';
3
+ import { EDIT_BASIC } from '../../../actions/ui/answers';
4
+ test('should use initial state if no answers are found when an EditAnswerAction is received', t => {
5
+ const state = reducer(undefined, { type: EDIT_BASIC, payload: [''] });
6
+ t.truthy(state);
7
+ t.false(state.validateButton);
8
+ });
9
+ test('should return state directly when there is no corresponding action handler + have an initial state', t => {
10
+ const state = reducer(undefined, { type: 'NOPE' });
11
+ t.deepEqual(state, initialState);
12
+ });
@@ -1,2 +1,3 @@
1
- import { Services } from '../../types/common';
1
+ import { ProgressionFromAPI, Services } from '../../types/common';
2
+ export declare const postAnswerResponse: ProgressionFromAPI;
2
3
  export declare const services: Services;
@@ -1,80 +1,94 @@
1
+ import { qcmSlide } from '../../views/slides/test/fixtures/qcm';
2
+ import { qcmGraphicSlide } from '../../views/slides/test/fixtures/qcm-graphic';
1
3
  import { freeTextSlide } from '../../views/slides/test/fixtures/free-text';
2
- export const services = {
3
- fetchSkills: () => {
4
- return Promise.resolve([
5
- {
6
- skillRef: '_skill-ref',
7
- slidesToReview: 2,
8
- name: 'skill-test',
9
- custom: false
10
- },
11
- {
12
- skillRef: '_skill-ref-2',
13
- slidesToReview: 2,
14
- name: 'skill-test-2',
15
- custom: true
16
- }
17
- ]);
4
+ import { sliderSlide } from '../../views/slides/test/fixtures/slider';
5
+ const getSlideFixture = (ref) => {
6
+ switch (ref) {
7
+ case qcmSlide.universalRef:
8
+ return qcmSlide;
9
+ case qcmGraphicSlide.universalRef:
10
+ return qcmGraphicSlide;
11
+ case freeTextSlide.universalRef:
12
+ return freeTextSlide;
13
+ default:
14
+ return sliderSlide;
15
+ }
16
+ };
17
+ const fetchSkillsResponse = [
18
+ {
19
+ skillRef: '_skill-ref',
20
+ slidesToReview: 2,
21
+ name: 'skill-test',
22
+ custom: false
18
23
  },
19
- fetchSlide: ref => {
20
- return Promise.resolve({ ...freeTextSlide, universalRef: ref, id: ref });
24
+ {
25
+ skillRef: '_skill-ref-2',
26
+ slidesToReview: 2,
27
+ name: 'skill-test-2',
28
+ custom: true
29
+ }
30
+ ];
31
+ const postProgressionResponse = {
32
+ _id: '62b1d1087aa12f00253f40ee',
33
+ content: {
34
+ ref: '_skill-ref',
35
+ type: 'skill'
21
36
  },
22
- postProgression: () => {
23
- return Promise.resolve({
24
- _id: '62b1d1087aa12f00253f40ee',
25
- content: {
26
- ref: '_skill-ref',
27
- type: 'skill'
28
- },
29
- engine: {
30
- ref: 'review'
31
- },
32
- state: {
33
- allAnswers: [],
34
- isCorrect: true,
35
- nextContent: {
36
- ref: 'sli_N1XACJobn',
37
- type: 'slide'
38
- },
39
- pendingSlides: [],
40
- slides: [],
41
- step: {
42
- current: 1
43
- },
44
- stars: 0
45
- }
46
- });
37
+ engine: {
38
+ ref: 'review'
39
+ },
40
+ state: {
41
+ allAnswers: [],
42
+ isCorrect: true,
43
+ nextContent: {
44
+ ref: 'sli_VJYjJnJhg',
45
+ type: 'slide'
46
+ },
47
+ pendingSlides: [],
48
+ slides: [],
49
+ step: {
50
+ current: 1
51
+ },
52
+ stars: 0
53
+ }
54
+ };
55
+ export const postAnswerResponse = {
56
+ _id: '62b1d1087aa12f00253f40ee',
57
+ content: {
58
+ ref: '_skill-ref',
59
+ type: 'skill'
47
60
  },
48
- postAnswer: () => {
49
- return Promise.resolve({
50
- _id: '62b1d1087aa12f00253f40ee',
51
- content: {
52
- ref: '_skill-ref',
53
- type: 'skill'
54
- },
55
- engine: {
56
- ref: 'review'
57
- },
58
- state: {
59
- allAnswers: [
60
- {
61
- slideRef: 'sli_N1XACJobn',
62
- isCorrect: true,
63
- answer: ['Le créateur peut fixer un pourcentage pour chaque transaction future']
64
- }
65
- ],
61
+ engine: {
62
+ ref: 'review'
63
+ },
64
+ state: {
65
+ allAnswers: [
66
+ {
67
+ slideRef: 'sli_VJYjJnJhg',
66
68
  isCorrect: true,
67
- nextContent: {
68
- ref: 'sli_VkSQroQnx',
69
- type: 'slide'
70
- },
71
- pendingSlides: [],
72
- slides: ['sli_N1XACJobn'],
73
- step: {
74
- current: 2
75
- },
76
- stars: 4
69
+ answer: ['Benchmark']
77
70
  }
78
- });
71
+ ],
72
+ isCorrect: true,
73
+ nextContent: {
74
+ ref: 'sli_VkSQroQnx',
75
+ type: 'slide'
76
+ },
77
+ content: {
78
+ ref: 'sli_VJYjJnJhg',
79
+ type: 'slide'
80
+ },
81
+ pendingSlides: [],
82
+ slides: ['sli_VJYjJnJhg'],
83
+ step: {
84
+ current: 2
85
+ },
86
+ stars: 4
79
87
  }
80
88
  };
89
+ export const services = {
90
+ fetchSkills: () => Promise.resolve(fetchSkillsResponse),
91
+ fetchSlide: ref => Promise.resolve({ ...getSlideFixture(ref), universalRef: ref, id: ref }),
92
+ postProgression: () => Promise.resolve(postProgressionResponse),
93
+ postAnswer: () => Promise.resolve(postAnswerResponse)
94
+ };
@@ -1,5 +1,3 @@
1
- import { SlideIndexes } from '../common';
2
- import { AnswerUI } from './slides';
3
1
  declare type TemplateContextValues = {
4
2
  brandTheme?: unknown;
5
3
  theme?: unknown;
@@ -142,29 +140,6 @@ export declare type JWT = {
142
140
  usage: string;
143
141
  host: string;
144
142
  };
145
- declare type SlideUIAnimations = 'unstack' | 'restack';
146
- export declare type NextUISlide = {
147
- questionText?: string;
148
- answerUI?: AnswerUI;
149
- hidden?: boolean;
150
- position?: number;
151
- animationType?: SlideUIAnimations;
152
- isCorrect?: boolean;
153
- endReview?: boolean;
154
- };
155
- export declare type UISlide = {
156
- questionText?: string;
157
- answerUI?: AnswerUI;
158
- hidden?: boolean;
159
- position: number;
160
- animationType?: SlideUIAnimations;
161
- isCorrect?: boolean;
162
- endReview?: boolean;
163
- nextContent?: NextUISlide;
164
- };
165
- export declare type FinishedSlides = {
166
- [key in SlideIndexes]?: true;
167
- };
168
143
  export declare type WithRequired<T, K extends keyof T> = T & {
169
144
  [P in K]-?: T[P];
170
145
  };
@@ -23,4 +23,4 @@ declare type SkillsProps = NoSkillsProps & {
23
23
  listSkills: SkillCard[];
24
24
  };
25
25
  export { SkillsProps };
26
- export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps | null;
26
+ export declare const mapStateToSkillsProps: (state: StoreState) => SkillsProps;
@@ -1,7 +1,4 @@
1
1
  export const mapStateToSkillsProps = (state) => {
2
- if (!state.data.skills) {
3
- return null;
4
- }
5
2
  return {
6
3
  title: '@todo title',
7
4
  titleNoSkills: '@todo titleNoSkills',
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,94 @@
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
+ },
13
+ ui: {
14
+ currentSlideRef: '',
15
+ navigation: ['loader', 'skills'],
16
+ answers: [],
17
+ slide: {
18
+ validateButton: false
19
+ }
20
+ }
21
+ };
22
+ const props = mapStateToSkillsProps(state);
23
+ t.deepEqual(props, {
24
+ title: '@todo title',
25
+ titleNoSkills: '@todo titleNoSkills',
26
+ textNoSkills: '@todo textNoSkills',
27
+ iconSkillAriaLabel: '@todo iconSkillAriaLabel',
28
+ isLoading: false,
29
+ isLoadingAriaLabel: '@todo loading',
30
+ listSkills: []
31
+ });
32
+ });
33
+ test('should create initial props when skills on the state', t => {
34
+ const state = {
35
+ data: {
36
+ progression: null,
37
+ skills: [
38
+ {
39
+ skillRef: '_skill-ref',
40
+ slidesToReview: 2,
41
+ name: 'skill-test',
42
+ custom: false
43
+ },
44
+ {
45
+ skillRef: '_skill-ref-2',
46
+ slidesToReview: 5,
47
+ name: 'skill-test-2',
48
+ custom: true
49
+ }
50
+ ],
51
+ slides: {},
52
+ token: '1234'
53
+ },
54
+ ui: {
55
+ currentSlideRef: '',
56
+ navigation: ['loader', 'skills'],
57
+ answers: [],
58
+ slide: {
59
+ validateButton: false
60
+ }
61
+ }
62
+ };
63
+ const props = mapStateToSkillsProps(state);
64
+ t.deepEqual(omit('listSkills', props), {
65
+ title: '@todo title',
66
+ titleNoSkills: '@todo titleNoSkills',
67
+ textNoSkills: '@todo textNoSkills',
68
+ iconSkillAriaLabel: '@todo iconSkillAriaLabel',
69
+ isLoading: false,
70
+ isLoadingAriaLabel: '@todo loading'
71
+ });
72
+ t.deepEqual(map(omit('onClick'), props.listSkills), [
73
+ {
74
+ 'aria-label': '',
75
+ isCustom: false,
76
+ skillTitle: 'skill-test',
77
+ skillAriaLabel: '@todo skill aria label',
78
+ buttonLabel: '@todo button',
79
+ buttonAriaLabel: '@todo button aria label',
80
+ reviseLabel: '@todo revise',
81
+ reviseAriaLabel: '@todo revise aria label'
82
+ },
83
+ {
84
+ 'aria-label': '',
85
+ isCustom: true,
86
+ skillTitle: 'skill-test-2',
87
+ skillAriaLabel: '@todo skill aria label',
88
+ buttonLabel: '@todo button',
89
+ buttonAriaLabel: '@todo button aria label',
90
+ reviseLabel: '@todo revise',
91
+ reviseAriaLabel: '@todo revise aria label'
92
+ }
93
+ ]);
94
+ });
@@ -1,7 +1,7 @@
1
1
  import { Dispatch } from 'redux';
2
- import { UISlide } from '../../types/common';
3
2
  import { SlideIndexes } from '../../common';
4
3
  import { StoreState } from '../../reducers';
4
+ import { AnswerUI } from '../../types/slides';
5
5
  declare const ICON_VALUES: {
6
6
  readonly right: "right";
7
7
  readonly wrong: "wrong";
@@ -13,6 +13,17 @@ declare type StepItem = {
13
13
  icon: IconValue;
14
14
  value: string;
15
15
  };
16
+ declare type SlideUIAnimations = 'unstack' | 'restack';
17
+ export declare type UISlide = {
18
+ questionText?: string;
19
+ answerUI?: AnswerUI;
20
+ hidden?: boolean;
21
+ position: number;
22
+ animationType?: SlideUIAnimations;
23
+ isCorrect?: boolean;
24
+ endReview?: boolean;
25
+ loading: boolean;
26
+ };
16
27
  declare type SlidesStack = {
17
28
  [key in SlideIndexes]: UISlide;
18
29
  };
@@ -75,5 +86,5 @@ export declare type SlidesViewProps = {
75
86
  };
76
87
  };
77
88
  export declare const initialState: SlidesStack;
78
- export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps | null;
89
+ export declare const mapStateToSlidesProps: (state: StoreState, dispatch: Dispatch) => SlidesViewProps;
79
90
  export {};