@coorpacademy/app-review 0.1.15 → 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.
- package/es/actions/api/fetch-skills.d.ts +5 -7
- package/es/actions/api/fetch-skills.js +12 -4
- package/es/actions/api/fetch-slide.d.ts +14 -7
- package/es/actions/api/fetch-slide.js +23 -18
- package/es/actions/api/post-answer.d.ts +10 -0
- package/es/actions/api/post-answer.js +25 -0
- package/es/actions/api/post-progression.d.ts +5 -7
- package/es/actions/api/post-progression.js +16 -8
- package/es/actions/api/test/fetch-skills.test.js +57 -0
- package/es/actions/api/test/fetch-slide.test.js +64 -0
- package/es/actions/api/test/post-answer.test.d.ts +1 -0
- package/es/actions/api/test/post-answer.test.js +82 -0
- package/es/actions/api/test/post-progression.test.d.ts +1 -0
- package/es/actions/api/test/post-progression.test.js +105 -0
- package/es/actions/data/test/token.test.d.ts +1 -0
- package/es/actions/data/test/token.test.js +25 -0
- package/es/actions/index.d.ts +1 -8
- package/es/actions/test/create-test-store.d.ts +5 -0
- package/es/actions/test/create-test-store.js +16 -0
- package/es/actions/ui/answers.d.ts +21 -0
- package/es/actions/ui/answers.js +43 -0
- package/es/actions/ui/slides.d.ts +0 -5
- package/es/actions/ui/slides.js +0 -4
- package/es/actions/ui/test/answers.test.d.ts +1 -0
- package/es/actions/ui/test/answers.test.js +90 -0
- package/es/actions/ui/test/slides.test.d.ts +1 -0
- package/es/actions/ui/test/slides.test.js +26 -0
- package/es/common/index.d.ts +0 -3
- package/es/common/index.js +0 -4
- package/es/index.js +11 -19
- package/es/reducers/data/index.d.ts +2 -2
- package/es/reducers/data/progression.d.ts +2 -3
- package/es/reducers/data/progression.js +0 -5
- package/es/reducers/data/slides.d.ts +3 -4
- package/es/reducers/data/slides.js +5 -1
- package/es/reducers/data/test/progression.test.d.ts +1 -0
- package/es/reducers/data/test/progression.test.js +38 -0
- package/es/reducers/data/test/skills.test.d.ts +1 -0
- package/es/reducers/data/test/skills.test.js +12 -0
- package/es/reducers/data/test/slides.test.d.ts +1 -0
- package/es/reducers/data/test/slides.test.js +20 -0
- package/es/reducers/data/test/token.test.d.ts +1 -0
- package/es/reducers/data/test/token.test.js +11 -0
- package/es/reducers/index.d.ts +3 -2
- package/es/reducers/ui/answers.d.ts +4 -0
- package/es/reducers/ui/answers.js +9 -0
- package/es/reducers/ui/index.d.ts +7 -4
- package/es/reducers/ui/index.js +4 -2
- package/es/reducers/ui/slide.d.ts +8 -0
- package/es/reducers/ui/slide.js +26 -0
- package/es/reducers/ui/test/answers.test.d.ts +1 -0
- package/es/reducers/ui/test/answers.test.js +27 -0
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/es/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/es/reducers/ui/test/navigation.test.d.ts +1 -0
- package/es/reducers/ui/test/navigation.test.js +15 -0
- package/es/reducers/ui/test/slide.test.d.ts +1 -0
- package/es/reducers/ui/test/slide.test.js +12 -0
- package/es/services/fetch-slide.js +1 -1
- package/es/services/index.js +3 -1
- package/es/services/post-answer.d.ts +2 -0
- package/es/services/post-answer.js +18 -0
- package/es/services/test/fetch-slide.test.d.ts +1 -0
- package/es/services/test/fetch-slide.test.js +22 -0
- package/es/services/test/post-answer.test.d.ts +1 -0
- package/es/services/test/post-answer.test.js +57 -0
- package/es/services/test/post-progression.test.js +9 -1
- package/es/test/util/services.mock.d.ts +2 -1
- package/es/test/util/services.mock.js +88 -44
- package/es/types/common.d.ts +22 -33
- package/es/views/skills/index.d.ts +1 -1
- package/es/views/skills/index.js +0 -3
- package/es/views/skills/test/skills.test.d.ts +1 -0
- package/es/views/skills/test/skills.test.js +94 -0
- package/es/views/slides/index.d.ts +89 -2
- package/es/views/slides/index.js +80 -10
- package/es/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/es/views/slides/map-api-slide-to-ui.js +165 -0
- package/es/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
- package/es/views/slides/test/fixtures/free-text.js +38 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
- package/es/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/es/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
- package/es/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/es/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
- package/es/views/slides/test/fixtures/select-template.js +92 -0
- package/es/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
- package/es/views/slides/test/fixtures/slider.js +36 -0
- package/es/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
- package/es/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/es/views/slides/test/index.test.d.ts +1 -0
- package/es/views/slides/test/index.test.js +234 -0
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/es/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/lib/actions/api/fetch-skills.d.ts +5 -7
- package/lib/actions/api/fetch-skills.js +58 -7
- package/lib/actions/api/fetch-slide.d.ts +14 -7
- package/lib/actions/api/fetch-slide.js +72 -20
- package/lib/actions/api/post-answer.d.ts +10 -0
- package/lib/actions/api/post-answer.js +75 -0
- package/lib/actions/api/post-progression.d.ts +5 -7
- package/lib/actions/api/post-progression.js +67 -10
- package/lib/actions/api/test/fetch-skills.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-skills.test.js +116 -0
- package/lib/actions/api/test/fetch-slide.test.d.ts +1 -0
- package/lib/actions/api/test/fetch-slide.test.js +123 -0
- package/lib/actions/api/test/post-answer.test.d.ts +1 -0
- package/lib/actions/api/test/post-answer.test.js +145 -0
- package/lib/actions/api/test/post-progression.test.d.ts +1 -0
- package/lib/actions/api/test/post-progression.test.js +163 -0
- package/lib/actions/data/test/token.test.d.ts +1 -0
- package/lib/actions/data/test/token.test.js +70 -0
- package/lib/actions/index.d.ts +1 -8
- package/lib/actions/test/create-test-store.d.ts +5 -0
- package/lib/actions/test/create-test-store.js +18 -0
- package/lib/actions/ui/answers.d.ts +21 -0
- package/lib/actions/ui/answers.js +54 -0
- package/lib/actions/ui/slides.d.ts +0 -5
- package/lib/actions/ui/slides.js +0 -4
- package/lib/actions/ui/test/answers.test.d.ts +1 -0
- package/lib/actions/ui/test/answers.test.js +171 -0
- package/lib/actions/ui/test/slides.test.d.ts +1 -0
- package/lib/actions/ui/test/slides.test.js +71 -0
- package/lib/common/index.d.ts +0 -3
- package/lib/common/index.js +0 -4
- package/lib/index.js +22 -21
- package/lib/reducers/data/index.d.ts +2 -2
- package/lib/reducers/data/progression.d.ts +2 -3
- package/lib/reducers/data/progression.js +0 -5
- package/lib/reducers/data/slides.d.ts +3 -4
- package/lib/reducers/data/slides.js +5 -1
- package/lib/reducers/data/test/progression.test.d.ts +1 -0
- package/lib/reducers/data/test/progression.test.js +38 -0
- package/lib/reducers/data/test/skills.test.d.ts +1 -0
- package/lib/reducers/data/test/skills.test.js +12 -0
- package/lib/reducers/data/test/slides.test.d.ts +1 -0
- package/lib/reducers/data/test/slides.test.js +20 -0
- package/lib/reducers/data/test/token.test.d.ts +1 -0
- package/lib/reducers/data/test/token.test.js +11 -0
- package/lib/reducers/index.d.ts +3 -2
- package/lib/reducers/ui/answers.d.ts +4 -0
- package/lib/reducers/ui/answers.js +10 -0
- package/lib/reducers/ui/index.d.ts +7 -4
- package/lib/reducers/ui/index.js +4 -2
- package/lib/reducers/ui/slide.d.ts +8 -0
- package/lib/reducers/ui/slide.js +27 -0
- package/lib/reducers/ui/test/answers.test.d.ts +1 -0
- package/lib/reducers/ui/test/answers.test.js +27 -0
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +1 -0
- package/lib/reducers/ui/test/current-slide-ref.test.js +12 -0
- package/lib/reducers/ui/test/navigation.test.d.ts +1 -0
- package/lib/reducers/ui/test/navigation.test.js +15 -0
- package/lib/reducers/ui/test/slide.test.d.ts +1 -0
- package/lib/reducers/ui/test/slide.test.js +12 -0
- package/lib/services/fetch-slide.js +1 -1
- package/lib/services/index.js +3 -1
- package/lib/services/post-answer.d.ts +2 -0
- package/lib/services/post-answer.js +62 -0
- package/lib/services/test/fetch-slide.test.d.ts +1 -0
- package/lib/services/test/fetch-slide.test.js +76 -0
- package/lib/services/test/post-answer.test.d.ts +1 -0
- package/lib/services/test/post-answer.test.js +111 -0
- package/lib/services/test/post-progression.test.js +9 -1
- package/lib/test/util/services.mock.d.ts +2 -1
- package/lib/test/util/services.mock.js +88 -44
- package/lib/types/common.d.ts +22 -33
- package/lib/views/skills/index.d.ts +1 -1
- package/lib/views/skills/index.js +0 -3
- package/lib/views/skills/test/skills.test.d.ts +1 -0
- package/lib/views/skills/test/skills.test.js +94 -0
- package/lib/views/slides/index.d.ts +89 -2
- package/lib/views/slides/index.js +80 -10
- package/lib/views/slides/map-api-slide-to-ui.d.ts +8 -0
- package/lib/views/slides/map-api-slide-to-ui.js +179 -0
- package/lib/{helpers → views/slides}/test/fixtures/free-text.d.ts +2 -1
- package/lib/views/slides/test/fixtures/free-text.js +38 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-drag.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-drag.js +108 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm-graphic.d.ts +2 -1
- package/lib/views/slides/test/fixtures/qcm-graphic.js +88 -0
- package/lib/{helpers → views/slides}/test/fixtures/qcm.d.ts +2 -1
- package/lib/{helpers → views/slides}/test/fixtures/qcm.js +5 -1
- package/lib/{helpers → views/slides}/test/fixtures/select-template.d.ts +2 -1
- package/lib/views/slides/test/fixtures/select-template.js +92 -0
- package/lib/{helpers → views/slides}/test/fixtures/slider.d.ts +2 -1
- package/lib/views/slides/test/fixtures/slider.js +36 -0
- package/lib/{helpers → views/slides}/test/fixtures/text-template.d.ts +2 -1
- package/lib/{helpers → views/slides}/test/fixtures/text-template.js +5 -1
- package/lib/views/slides/test/index.test.d.ts +1 -0
- package/lib/views/slides/test/index.test.js +234 -0
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +1 -0
- package/lib/{helpers → views/slides}/test/map-api-slide-to-ui.test.js +19 -9
- package/package.json +6 -5
- package/src/actions/api/fetch-skills.ts +19 -12
- package/src/actions/api/fetch-slide.ts +35 -29
- package/src/actions/api/post-answer.ts +39 -0
- package/src/actions/api/post-progression.ts +22 -22
- package/src/actions/api/test/fetch-skills.test.ts +73 -0
- package/src/actions/api/test/fetch-slide.test.ts +80 -0
- package/src/actions/api/test/post-answer.test.ts +101 -0
- package/src/actions/api/test/post-progression.test.ts +122 -0
- package/src/actions/data/test/token.test.ts +29 -0
- package/src/actions/index.ts +1 -17
- package/src/actions/test/create-test-store.ts +25 -0
- package/src/actions/ui/answers.ts +63 -0
- package/src/actions/ui/slides.ts +1 -8
- package/src/actions/ui/test/answers.test.ts +103 -0
- package/src/actions/ui/test/slides.test.ts +30 -0
- package/src/common/index.ts +0 -7
- package/src/index.tsx +15 -32
- package/src/reducers/data/index.ts +1 -1
- package/src/reducers/data/progression.ts +2 -7
- package/src/reducers/data/slides.ts +12 -4
- package/src/reducers/data/test/progression.test.ts +42 -0
- package/src/reducers/data/test/skills.test.ts +14 -0
- package/src/reducers/data/test/slides.test.ts +26 -0
- package/src/reducers/data/test/token.test.ts +13 -0
- package/src/reducers/ui/answers.ts +15 -0
- package/src/reducers/ui/index.ts +6 -3
- package/src/reducers/ui/slide.ts +43 -0
- package/src/reducers/ui/test/answers.test.ts +33 -0
- package/src/reducers/ui/test/current-slide-ref.test.ts +14 -0
- package/src/reducers/ui/test/navigation.test.ts +19 -0
- package/src/reducers/ui/test/slide.test.ts +15 -0
- package/src/services/fetch-slide.ts +1 -1
- package/src/services/index.ts +3 -1
- package/src/services/post-answer.ts +27 -0
- package/src/services/test/fetch-slide.test.ts +30 -0
- package/src/services/test/post-answer.test.ts +68 -0
- package/src/services/test/post-progression.test.ts +9 -1
- package/src/test/util/services.mock.ts +93 -45
- package/src/types/common.ts +34 -44
- package/src/views/skills/index.ts +1 -5
- package/src/views/skills/test/skills.test.ts +101 -0
- package/src/views/slides/index.ts +186 -12
- package/src/views/slides/map-api-slide-to-ui.ts +251 -0
- package/src/views/slides/test/fixtures/free-text.ts +44 -0
- package/src/views/slides/test/fixtures/qcm-drag.ts +112 -0
- package/src/views/slides/test/fixtures/qcm-graphic.ts +95 -0
- package/src/{helpers → views/slides}/test/fixtures/qcm.ts +7 -2
- package/src/views/slides/test/fixtures/select-template.ts +99 -0
- package/src/views/slides/test/fixtures/slider.ts +42 -0
- package/src/{helpers → views/slides}/test/fixtures/text-template.ts +7 -2
- package/src/views/slides/test/index.test.ts +240 -0
- package/src/{helpers → views/slides}/test/map-api-slide-to-ui.test.ts +22 -10
- package/es/fixtures/qcm-slide.d.ts +0 -2
- package/es/fixtures/qcm-slide.js +0 -33
- package/es/fixtures/temp-fixture.d.ts +0 -3
- package/es/fixtures/temp-fixture.js +0 -84
- package/es/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/es/helpers/map-api-slide-to-ui.js +0 -193
- package/es/helpers/test/fixtures/free-text.js +0 -30
- package/es/helpers/test/fixtures/qcm-drag.js +0 -112
- package/es/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/es/helpers/test/fixtures/select-template.js +0 -94
- package/es/helpers/test/fixtures/slider.js +0 -33
- package/es/reducers/ui/slides.d.ts +0 -9
- package/es/reducers/ui/slides.js +0 -42
- package/es/types/views/slides.d.ts +0 -74
- package/es/types/views/slides.js +0 -6
- package/lib/fixtures/qcm-slide.d.ts +0 -2
- package/lib/fixtures/qcm-slide.js +0 -33
- package/lib/fixtures/temp-fixture.d.ts +0 -3
- package/lib/fixtures/temp-fixture.js +0 -84
- package/lib/helpers/map-api-slide-to-ui.d.ts +0 -11
- package/lib/helpers/map-api-slide-to-ui.js +0 -201
- package/lib/helpers/test/fixtures/free-text.js +0 -30
- package/lib/helpers/test/fixtures/qcm-drag.js +0 -112
- package/lib/helpers/test/fixtures/qcm-graphic.js +0 -76
- package/lib/helpers/test/fixtures/select-template.js +0 -94
- package/lib/helpers/test/fixtures/slider.js +0 -33
- package/lib/reducers/ui/slides.d.ts +0 -9
- package/lib/reducers/ui/slides.js +0 -43
- package/lib/types/views/slides.d.ts +0 -74
- package/lib/types/views/slides.js +0 -6
- package/src/fixtures/qcm-slide.ts +0 -35
- package/src/fixtures/temp-fixture.ts +0 -94
- package/src/helpers/map-api-slide-to-ui.ts +0 -279
- package/src/helpers/test/fixtures/free-text.ts +0 -33
- package/src/helpers/test/fixtures/qcm-drag.ts +0 -115
- package/src/helpers/test/fixtures/qcm-graphic.ts +0 -79
- package/src/helpers/test/fixtures/select-template.ts +0 -97
- package/src/helpers/test/fixtures/slider.ts +0 -36
- package/src/reducers/ui/slides.ts +0 -58
- package/src/types/views/slides.ts +0 -90
- /package/es/{helpers/test/map-api-slide-to-ui.test.d.ts → actions/api/test/fetch-skills.test.d.ts} +0 -0
- /package/{lib/helpers/test/map-api-slide-to-ui.test.d.ts → es/actions/api/test/fetch-slide.test.d.ts} +0 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import identity from 'lodash/fp/identity';
|
|
3
|
+
import omit from 'lodash/fp/omit';
|
|
4
|
+
import { mapStateToSlidesProps } from '..';
|
|
5
|
+
import { freeTextSlide } from './fixtures/free-text';
|
|
6
|
+
test('should create initial props when fetched slide is still not received', function (t) {
|
|
7
|
+
var state = {
|
|
8
|
+
data: {
|
|
9
|
+
progression: {
|
|
10
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
11
|
+
content: {
|
|
12
|
+
ref: '_skillref',
|
|
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
|
+
skills: [],
|
|
34
|
+
slides: {
|
|
35
|
+
sli_N1XACJobn: null
|
|
36
|
+
},
|
|
37
|
+
token: '1234'
|
|
38
|
+
},
|
|
39
|
+
ui: {
|
|
40
|
+
currentSlideRef: '',
|
|
41
|
+
navigation: ['loader', 'slides'],
|
|
42
|
+
answers: [],
|
|
43
|
+
slide: {
|
|
44
|
+
validateButton: false
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var props = mapStateToSlidesProps(state, identity);
|
|
49
|
+
t.is(props.congratsProps, undefined);
|
|
50
|
+
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
51
|
+
'aria-label': 'aria-header-wrapper',
|
|
52
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
53
|
+
mode: '__revision_mode',
|
|
54
|
+
skillName: '__agility',
|
|
55
|
+
steps: [
|
|
56
|
+
{
|
|
57
|
+
current: true,
|
|
58
|
+
icon: 'no-answer',
|
|
59
|
+
value: '1'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
current: false,
|
|
63
|
+
icon: 'no-answer',
|
|
64
|
+
value: '2'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
current: false,
|
|
68
|
+
icon: 'no-answer',
|
|
69
|
+
value: '3'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
current: false,
|
|
73
|
+
icon: 'no-answer',
|
|
74
|
+
value: '4'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
current: false,
|
|
78
|
+
icon: 'no-answer',
|
|
79
|
+
value: '5'
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
t.deepEqual(omit(['validateButton'], props.stack), {
|
|
84
|
+
correctionPopinProps: undefined,
|
|
85
|
+
endReview: false,
|
|
86
|
+
slides: {
|
|
87
|
+
'0': {
|
|
88
|
+
hidden: false,
|
|
89
|
+
position: 0,
|
|
90
|
+
loading: true
|
|
91
|
+
},
|
|
92
|
+
'1': {
|
|
93
|
+
hidden: false,
|
|
94
|
+
position: 1,
|
|
95
|
+
loading: true
|
|
96
|
+
},
|
|
97
|
+
'2': {
|
|
98
|
+
hidden: false,
|
|
99
|
+
position: 2,
|
|
100
|
+
loading: true
|
|
101
|
+
},
|
|
102
|
+
'3': {
|
|
103
|
+
hidden: false,
|
|
104
|
+
position: 3,
|
|
105
|
+
loading: true
|
|
106
|
+
},
|
|
107
|
+
'4': {
|
|
108
|
+
hidden: false,
|
|
109
|
+
position: 4,
|
|
110
|
+
loading: true
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
test('should create initial props when the slide is on the state', function (t) {
|
|
116
|
+
var state = {
|
|
117
|
+
data: {
|
|
118
|
+
progression: {
|
|
119
|
+
_id: '62b1d1087aa12f00253f40ee',
|
|
120
|
+
content: {
|
|
121
|
+
ref: '_skillref',
|
|
122
|
+
type: 'skill'
|
|
123
|
+
},
|
|
124
|
+
engine: {
|
|
125
|
+
ref: 'review'
|
|
126
|
+
},
|
|
127
|
+
state: {
|
|
128
|
+
allAnswers: [],
|
|
129
|
+
isCorrect: true,
|
|
130
|
+
nextContent: {
|
|
131
|
+
ref: 'sli_N1XACJobn',
|
|
132
|
+
type: 'slide'
|
|
133
|
+
},
|
|
134
|
+
pendingSlides: [],
|
|
135
|
+
slides: [],
|
|
136
|
+
step: {
|
|
137
|
+
current: 1
|
|
138
|
+
},
|
|
139
|
+
stars: 0
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
skills: [],
|
|
143
|
+
slides: {
|
|
144
|
+
sli_N1XACJobn: freeTextSlide
|
|
145
|
+
},
|
|
146
|
+
token: '1234'
|
|
147
|
+
},
|
|
148
|
+
ui: {
|
|
149
|
+
currentSlideRef: 'sli_N1XACJobn',
|
|
150
|
+
navigation: ['loader', 'slides'],
|
|
151
|
+
answers: ['My value'],
|
|
152
|
+
slide: {
|
|
153
|
+
validateButton: true
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
var props = mapStateToSlidesProps(state, identity);
|
|
158
|
+
t.is(props.congratsProps, undefined);
|
|
159
|
+
t.deepEqual(omit(['onQuitClick'], props.header), {
|
|
160
|
+
'aria-label': 'aria-header-wrapper',
|
|
161
|
+
closeButtonAriaLabel: 'aria-close-button',
|
|
162
|
+
mode: '__revision_mode',
|
|
163
|
+
skillName: '__agility',
|
|
164
|
+
steps: [
|
|
165
|
+
{
|
|
166
|
+
current: true,
|
|
167
|
+
icon: 'no-answer',
|
|
168
|
+
value: '1'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
current: false,
|
|
172
|
+
icon: 'no-answer',
|
|
173
|
+
value: '2'
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
current: false,
|
|
177
|
+
icon: 'no-answer',
|
|
178
|
+
value: '3'
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
current: false,
|
|
182
|
+
icon: 'no-answer',
|
|
183
|
+
value: '4'
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
current: false,
|
|
187
|
+
icon: 'no-answer',
|
|
188
|
+
value: '5'
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
});
|
|
192
|
+
t.deepEqual(omit(['validateButton', 'slides'], props.stack), {
|
|
193
|
+
correctionPopinProps: undefined,
|
|
194
|
+
endReview: false
|
|
195
|
+
});
|
|
196
|
+
t.false(props.stack.validateButton.disabled);
|
|
197
|
+
t.deepEqual(omit('answerUI', props.stack.slides['0']), {
|
|
198
|
+
hidden: false,
|
|
199
|
+
position: 0,
|
|
200
|
+
loading: false,
|
|
201
|
+
parentContentTitle: 'From "Developing the review app" course',
|
|
202
|
+
questionText: 'Which term is used to describe the act of asking what the usual salary is for the position you are applying for?'
|
|
203
|
+
});
|
|
204
|
+
t.deepEqual(omit('model.onChange', props.stack.slides['0'].answerUI), {
|
|
205
|
+
help: 'Type your answer.',
|
|
206
|
+
model: {
|
|
207
|
+
placeholder: 'Type here',
|
|
208
|
+
type: 'freeText',
|
|
209
|
+
value: 'My value'
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
t.deepEqual(omit(['0'], props.stack.slides), {
|
|
213
|
+
'1': {
|
|
214
|
+
hidden: false,
|
|
215
|
+
position: 1,
|
|
216
|
+
loading: true
|
|
217
|
+
},
|
|
218
|
+
'2': {
|
|
219
|
+
hidden: false,
|
|
220
|
+
position: 2,
|
|
221
|
+
loading: true
|
|
222
|
+
},
|
|
223
|
+
'3': {
|
|
224
|
+
hidden: false,
|
|
225
|
+
position: 3,
|
|
226
|
+
loading: true
|
|
227
|
+
},
|
|
228
|
+
'4': {
|
|
229
|
+
hidden: false,
|
|
230
|
+
position: 4,
|
|
231
|
+
loading: true
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -10,6 +10,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import test from 'ava';
|
|
13
|
+
import identity from 'lodash/fp/identity';
|
|
13
14
|
import { mapApiSlideToUi } from '../map-api-slide-to-ui';
|
|
14
15
|
import { qcmUISlide, qcmSlide } from './fixtures/qcm';
|
|
15
16
|
import { qcmDragUISlide, qcmDragSlide } from './fixtures/qcm-drag';
|
|
@@ -18,26 +19,35 @@ import { qcmGraphicUISlide, qcmGraphicSlide } from './fixtures/qcm-graphic';
|
|
|
18
19
|
import { textTemplateSlide, textTemplateUISlide } from './fixtures/text-template';
|
|
19
20
|
import { selectTemplateSlide, selectTemplateUISlide } from './fixtures/select-template';
|
|
20
21
|
import { sliderSlide, sliderUISlide } from './fixtures/slider';
|
|
21
|
-
var _mapApiSlideToUi = mapApiSlideToUi(
|
|
22
|
+
var _mapApiSlideToUi = mapApiSlideToUi(identity);
|
|
22
23
|
var macro = test.macro({
|
|
23
24
|
title: function (providedTitle) {
|
|
24
25
|
return "should handle ".concat(providedTitle, " conversion").trim();
|
|
25
26
|
},
|
|
26
27
|
exec: function (t, arg) {
|
|
27
|
-
t.deepEqual(JSON.parse(JSON.stringify(_mapApiSlideToUi(arg.slide))), JSON.parse(JSON.stringify(arg.expectedUiSlide)));
|
|
28
|
+
t.deepEqual(JSON.parse(JSON.stringify(_mapApiSlideToUi(arg.slide, arg.answers))), JSON.parse(JSON.stringify(arg.expectedUiSlide)));
|
|
28
29
|
}
|
|
29
30
|
});
|
|
30
|
-
test('qcm', macro, { slide: qcmSlide, expectedUiSlide: qcmUISlide });
|
|
31
|
-
test('qcm drag', macro, { slide: qcmDragSlide, expectedUiSlide: qcmDragUISlide });
|
|
32
|
-
test('qcm graphic', macro, {
|
|
33
|
-
|
|
31
|
+
test('qcm', macro, { slide: qcmSlide, answers: [], expectedUiSlide: qcmUISlide });
|
|
32
|
+
test('qcm drag', macro, { slide: qcmDragSlide, answers: [], expectedUiSlide: qcmDragUISlide });
|
|
33
|
+
test('qcm graphic', macro, {
|
|
34
|
+
slide: qcmGraphicSlide,
|
|
35
|
+
answers: [],
|
|
36
|
+
expectedUiSlide: qcmGraphicUISlide
|
|
37
|
+
});
|
|
38
|
+
test('text template', macro, {
|
|
39
|
+
slide: textTemplateSlide,
|
|
40
|
+
answers: [],
|
|
41
|
+
expectedUiSlide: textTemplateUISlide
|
|
42
|
+
});
|
|
34
43
|
test('select template', macro, {
|
|
35
44
|
slide: selectTemplateSlide,
|
|
45
|
+
answers: [],
|
|
36
46
|
expectedUiSlide: selectTemplateUISlide
|
|
37
47
|
});
|
|
38
|
-
test('free text', macro, { slide: freeTextSlide, expectedUiSlide: freeTextUISlide });
|
|
39
|
-
test('slider', macro, { slide: sliderSlide, expectedUiSlide: sliderUISlide });
|
|
48
|
+
test('free text', macro, { slide: freeTextSlide, answers: [], expectedUiSlide: freeTextUISlide });
|
|
49
|
+
test('slider', macro, { slide: sliderSlide, answers: [], expectedUiSlide: sliderUISlide });
|
|
40
50
|
test('should throw an error if the question type can not be handled', function (t) {
|
|
41
51
|
var faultySlide = __assign(__assign({}, qcmSlide), { question: { type: 'lol' } });
|
|
42
|
-
t.throws(function () { return _mapApiSlideToUi(faultySlide); });
|
|
52
|
+
t.throws(function () { return _mapApiSlideToUi(faultySlide, []); });
|
|
43
53
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coorpacademy/app-review",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.15.0"
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"clean:es": "rm -rf es",
|
|
19
19
|
"clean": "concurrently \"npm run clean:commonjs\" \"npm run clean:es\"",
|
|
20
20
|
"typecheck": "tsc --noEmit",
|
|
21
|
-
"
|
|
21
|
+
"ava": "ava",
|
|
22
|
+
"test:unit": "nyc npm run ava",
|
|
22
23
|
"lint": "eslint '**/*' --cache --ext .js --ext .jsx --ext .ts --ext .tsx --ext .json",
|
|
23
24
|
"lint:fix": "npm run lint -- --fix",
|
|
24
25
|
"test": "npm run lint && npm run typecheck && npm run test:unit"
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"./package.json": "./package.json"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@coorpacademy/components": "10.22.
|
|
44
|
+
"@coorpacademy/components": "10.22.11",
|
|
44
45
|
"@coorpacademy/redux-task": "^1.1.5",
|
|
45
46
|
"cross-fetch": "^3.1.5",
|
|
46
47
|
"jwt-decode": "^3.1.2",
|
|
@@ -74,8 +75,8 @@
|
|
|
74
75
|
"nock": "^13.2.9",
|
|
75
76
|
"postcss-modules-values-replace": "^3.4.0",
|
|
76
77
|
"react-dom": "^17.0.2",
|
|
77
|
-
"ts-node": "^10.
|
|
78
|
+
"ts-node": "^10.9.1",
|
|
78
79
|
"typescript": "^4.7.4"
|
|
79
80
|
},
|
|
80
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "7191ac405f4eebce61c459722595014ea973818c"
|
|
81
82
|
}
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import buildTask from '@coorpacademy/redux-task';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import get from 'lodash/fp/get';
|
|
3
|
+
import type {Dispatch} from 'redux';
|
|
4
4
|
import type {StoreState} from '../../reducers';
|
|
5
|
-
import {Options, Skill} from '../../types/common';
|
|
5
|
+
import type {Options, Skill} from '../../types/common';
|
|
6
6
|
|
|
7
7
|
export const SKILLS_FETCH_REQUEST = '@@skills/FETCH_REQUEST' as const;
|
|
8
8
|
export const SKILLS_FETCH_SUCCESS = '@@skills/FETCH_SUCCESS' as const;
|
|
9
9
|
export const SKILLS_FETCH_FAILURE = '@@skills/FETCH_FAILURE' as const;
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export type ReceivedSkills = {
|
|
12
12
|
type: '@@skills/FETCH_SUCCESS';
|
|
13
13
|
payload: Skill[];
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
export const fetchSkills = async (
|
|
17
|
+
dispatch: Dispatch,
|
|
18
|
+
getState: () => StoreState,
|
|
19
|
+
{services}: Options
|
|
20
|
+
): Promise<void> => {
|
|
21
|
+
const action = buildTask({
|
|
21
22
|
types: [SKILLS_FETCH_REQUEST, SKILLS_FETCH_SUCCESS, SKILLS_FETCH_FAILURE],
|
|
22
|
-
task: (
|
|
23
|
-
|
|
23
|
+
task: () => {
|
|
24
|
+
const state = getState();
|
|
25
|
+
const token = get('data.token', state);
|
|
26
|
+
return services.fetchSkills(token);
|
|
27
|
+
}
|
|
24
28
|
});
|
|
29
|
+
|
|
30
|
+
await dispatch(action);
|
|
31
|
+
};
|
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
|
|
1
|
+
import type {Dispatch} from 'redux';
|
|
3
2
|
import buildTask from '@coorpacademy/redux-task';
|
|
4
3
|
import get from 'lodash/fp/get';
|
|
5
4
|
import has from 'lodash/fp/has';
|
|
6
5
|
import isEmpty from 'lodash/fp/isEmpty';
|
|
7
6
|
import type {StoreState} from '../../reducers';
|
|
8
|
-
import type {Options,
|
|
7
|
+
import type {Options, SlideFromAPI} from '../../types/common';
|
|
9
8
|
import {setCurrentSlide} from '../ui/slides';
|
|
10
9
|
|
|
11
10
|
export const SLIDE_FETCH_REQUEST = '@@slides/FETCH_REQUEST' as const;
|
|
12
11
|
export const SLIDE_FETCH_SUCCESS = '@@slides/FETCH_SUCCESS' as const;
|
|
13
12
|
export const SLIDE_FETCH_FAILURE = '@@slides/FETCH_FAILURE' as const;
|
|
14
13
|
|
|
15
|
-
export
|
|
14
|
+
export type FetchSlide = {
|
|
15
|
+
type: typeof SLIDE_FETCH_REQUEST;
|
|
16
|
+
meta: {slideRef: string};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type ReceivedSlide = {
|
|
16
20
|
type: typeof SLIDE_FETCH_SUCCESS;
|
|
17
21
|
payload: SlideFromAPI;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type FetchSlideAction = ThunkAction<Promise<SlideFromAPI>, StoreState, Options, AnyAction>;
|
|
21
|
-
type Dispatch = ThunkDispatch<StoreState, Options, AnyAction>;
|
|
22
|
+
meta: {slideRef: string};
|
|
23
|
+
};
|
|
22
24
|
|
|
23
|
-
export const fetchSlide =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) => {
|
|
34
|
-
const {ref: slideRef} = get('state.nextContent', progressionFromAPI);
|
|
35
|
-
return services.fetchSlide(slideRef, token).then((slideFromAPI: SlideFromAPI | void) => {
|
|
36
|
-
if (!slideFromAPI) throw new Error('Slide not found');
|
|
25
|
+
export const fetchSlide =
|
|
26
|
+
(slideRef: string) =>
|
|
27
|
+
async (dispatch: Dispatch, getState: () => StoreState, {services}: Options): Promise<void> => {
|
|
28
|
+
const action = buildTask({
|
|
29
|
+
types: [SLIDE_FETCH_REQUEST, SLIDE_FETCH_SUCCESS, SLIDE_FETCH_FAILURE],
|
|
30
|
+
bailout: (state: StoreState): boolean => {
|
|
31
|
+
return has(`data.slide.${slideRef}`, state);
|
|
32
|
+
},
|
|
33
|
+
task: () => {
|
|
37
34
|
const state = getState();
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
const token = get('data.token', state);
|
|
36
|
+
return services.fetchSlide(slideRef, token);
|
|
37
|
+
},
|
|
38
|
+
meta: {slideRef}
|
|
39
|
+
});
|
|
40
|
+
const response = await dispatch(action);
|
|
41
|
+
|
|
42
|
+
if (response.type === SLIDE_FETCH_SUCCESS) {
|
|
43
|
+
const slideFromAPI = response.payload;
|
|
44
|
+
if (!slideFromAPI) throw new Error('Slide not found');
|
|
45
|
+
const state = getState();
|
|
46
|
+
const slides = get('data.progression.state.slides', state);
|
|
47
|
+
if (isEmpty(slides)) {
|
|
48
|
+
dispatch(setCurrentSlide(slideFromAPI));
|
|
49
|
+
}
|
|
44
50
|
}
|
|
45
|
-
}
|
|
51
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type {Dispatch} from 'redux';
|
|
2
|
+
import buildTask from '@coorpacademy/redux-task';
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import type {Options} from '../../types/common';
|
|
5
|
+
import type {StoreState} from '../../reducers';
|
|
6
|
+
import {fetchSlide} from './fetch-slide';
|
|
7
|
+
|
|
8
|
+
export const POST_ANSWER_REQUEST = '@@answer/POST_REQUEST' as const;
|
|
9
|
+
export const POST_ANSWER_SUCCESS = '@@answer/POST_SUCCESS' as const;
|
|
10
|
+
export const POST_ANSWER_FAILURE = '@@answer/POST_FAILURE' as const;
|
|
11
|
+
|
|
12
|
+
export type PostAnswerRequestAction = {
|
|
13
|
+
type: typeof POST_ANSWER_REQUEST;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const postAnswer = async (
|
|
17
|
+
dispatch: Dispatch,
|
|
18
|
+
getState: () => StoreState,
|
|
19
|
+
{services}: Options
|
|
20
|
+
): Promise<void> => {
|
|
21
|
+
const action = buildTask({
|
|
22
|
+
types: [POST_ANSWER_REQUEST, POST_ANSWER_SUCCESS, POST_ANSWER_FAILURE],
|
|
23
|
+
task: () => {
|
|
24
|
+
const state = getState();
|
|
25
|
+
const token = get('data.token', state);
|
|
26
|
+
const answer = get('ui.answers', state);
|
|
27
|
+
const progressionId = get('data.progression._id', state);
|
|
28
|
+
const skillRef = get('data.progression.content.ref', state);
|
|
29
|
+
return services.postAnswer(skillRef, token, progressionId, answer);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const response = await dispatch(action);
|
|
33
|
+
|
|
34
|
+
if (response.type === POST_ANSWER_SUCCESS) {
|
|
35
|
+
const progression = response.payload;
|
|
36
|
+
const slideRef = progression.state.nextContent.ref;
|
|
37
|
+
await dispatch(fetchSlide(slideRef));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {ThunkAction, ThunkDispatch} from 'redux-thunk';
|
|
1
|
+
import type {Dispatch} from 'redux';
|
|
3
2
|
import buildTask from '@coorpacademy/redux-task';
|
|
4
|
-
import
|
|
3
|
+
import get from 'lodash/fp/get';
|
|
4
|
+
import type {Options, ProgressionFromAPI} from '../../types/common';
|
|
5
5
|
import type {StoreState} from '../../reducers';
|
|
6
6
|
import {fetchSlide} from './fetch-slide';
|
|
7
7
|
|
|
@@ -9,27 +9,27 @@ export const POST_PROGRESSION_REQUEST = '@@progression/POST_REQUEST' as const;
|
|
|
9
9
|
export const POST_PROGRESSION_SUCCESS = '@@progression/POST_SUCCESS' as const;
|
|
10
10
|
export const POST_PROGRESSION_FAILURE = '@@progression/POST_FAILURE' as const;
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export type ReceivedProgression = {
|
|
13
13
|
type: typeof POST_PROGRESSION_SUCCESS;
|
|
14
14
|
payload: ProgressionFromAPI;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
StoreState,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
export const postProgression =
|
|
18
|
+
(skillRef: string) =>
|
|
19
|
+
async (dispatch: Dispatch, getState: () => StoreState, {services}: Options): Promise<void> => {
|
|
20
|
+
const state = getState();
|
|
21
|
+
const token = get('data.token', state);
|
|
22
|
+
const action = buildTask({
|
|
23
|
+
types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
|
|
24
|
+
task: () => {
|
|
25
|
+
return services.postProgression(skillRef, token);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const response = await dispatch(action);
|
|
23
29
|
|
|
24
|
-
type
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
types: [POST_PROGRESSION_REQUEST, POST_PROGRESSION_SUCCESS, POST_PROGRESSION_FAILURE],
|
|
29
|
-
task: (dispatch: Dispatch, getState: () => StoreState, {services}: Options) => {
|
|
30
|
-
return services.postProgression(skillRef, token).then((progression: ProgressionFromAPI) => {
|
|
31
|
-
dispatch(fetchSlide(progression, token));
|
|
32
|
-
return progression;
|
|
33
|
-
});
|
|
30
|
+
if (response.type === POST_PROGRESSION_SUCCESS) {
|
|
31
|
+
const progression = response.payload;
|
|
32
|
+
const slideRef = progression.state.nextContent.ref;
|
|
33
|
+
await dispatch(fetchSlide(slideRef));
|
|
34
34
|
}
|
|
35
|
-
}
|
|
35
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import test from 'ava';
|
|
2
|
+
import type {Services} from '../../../types/common';
|
|
3
|
+
import type {StoreState} from '../../../reducers';
|
|
4
|
+
import {
|
|
5
|
+
fetchSkills,
|
|
6
|
+
SKILLS_FETCH_FAILURE,
|
|
7
|
+
SKILLS_FETCH_REQUEST,
|
|
8
|
+
SKILLS_FETCH_SUCCESS
|
|
9
|
+
} from '../fetch-skills';
|
|
10
|
+
import {services as mockedServices} from '../../../test/util/services.mock';
|
|
11
|
+
import {createTestStore} from '../../test/create-test-store';
|
|
12
|
+
|
|
13
|
+
const initialState: StoreState = {
|
|
14
|
+
data: {
|
|
15
|
+
progression: null,
|
|
16
|
+
slides: {},
|
|
17
|
+
skills: [],
|
|
18
|
+
token: '1234'
|
|
19
|
+
},
|
|
20
|
+
ui: {
|
|
21
|
+
currentSlideRef: '',
|
|
22
|
+
navigation: [],
|
|
23
|
+
answers: [],
|
|
24
|
+
slide: {
|
|
25
|
+
validateButton: false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
test('should dispatch SKILLS_FETCH_SUCCESS actions when fetchSkills return a list of skills', async t => {
|
|
31
|
+
const services: Services = {
|
|
32
|
+
...mockedServices,
|
|
33
|
+
fetchSkills: token => {
|
|
34
|
+
t.is(token, '1234');
|
|
35
|
+
return Promise.resolve([]);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const expectedActions = [
|
|
40
|
+
{type: SKILLS_FETCH_REQUEST},
|
|
41
|
+
{
|
|
42
|
+
type: SKILLS_FETCH_SUCCESS,
|
|
43
|
+
payload: []
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
48
|
+
|
|
49
|
+
await dispatch(fetchSkills);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('should dispatch SKILLS_FETCH_FAILURE action when fetchSkills fails', async t => {
|
|
53
|
+
const services: Services = {
|
|
54
|
+
...mockedServices,
|
|
55
|
+
fetchSkills: token => {
|
|
56
|
+
t.is(token, '1234');
|
|
57
|
+
return Promise.reject(new Error('unexpected'));
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const expectedActions = [
|
|
62
|
+
{type: SKILLS_FETCH_REQUEST},
|
|
63
|
+
{
|
|
64
|
+
type: SKILLS_FETCH_FAILURE,
|
|
65
|
+
payload: new Error('unexpected'),
|
|
66
|
+
error: true
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
const {dispatch} = createTestStore(t, initialState, services, expectedActions);
|
|
71
|
+
|
|
72
|
+
await dispatch(fetchSkills);
|
|
73
|
+
});
|