@coorpacademy/app-review 0.1.5 → 0.1.8
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 +10 -0
- package/es/actions/api/fetch-skills.js +8 -0
- package/es/actions/api/fetch-slide.d.ts +10 -0
- package/es/actions/api/fetch-slide.js +8 -0
- package/es/actions/api/post-progression.d.ts +10 -0
- package/es/actions/api/post-progression.js +15 -0
- package/es/actions/data/slides.d.ts +7 -24
- package/es/actions/data/slides.js +0 -6
- package/es/actions/data/token.d.ts +2 -2
- package/es/actions/data/token.js +1 -1
- package/es/actions/index.d.ts +5 -3
- package/es/actions/ui/navigation.d.ts +0 -1
- package/es/actions/ui/navigation.js +0 -4
- package/es/actions/ui/step-items.d.ts +2 -8
- package/es/actions/ui/step-items.js +0 -6
- package/es/configure-store.d.ts +3 -34
- package/es/configure-store.js +4 -4
- package/es/fixtures/qcm-slide.d.ts +2 -2
- package/es/index.d.ts +1 -1
- package/es/index.js +78 -42
- package/es/reducers/data/index.d.ts +16 -5
- package/es/reducers/data/progression.d.ts +14 -9
- package/es/reducers/data/progression.js +18 -58
- package/es/reducers/data/skills.d.ts +4 -5
- package/es/reducers/data/skills.js +3 -6
- package/es/reducers/data/slides.d.ts +2 -1
- package/es/reducers/data/slides.js +14 -9
- package/es/reducers/data/token.d.ts +0 -1
- package/es/reducers/data/token.js +1 -5
- package/es/reducers/index.d.ts +9 -3
- package/es/reducers/ui/finished-slides.d.ts +0 -1
- package/es/reducers/ui/finished-slides.js +1 -3
- package/es/reducers/ui/index.d.ts +14 -4
- package/es/reducers/ui/navigation.d.ts +0 -1
- package/es/reducers/ui/navigation.js +1 -3
- package/es/reducers/ui/review-status.d.ts +0 -1
- package/es/reducers/ui/review-status.js +1 -4
- package/es/reducers/ui/step-items.d.ts +5 -5
- package/es/reducers/ui/step-items.js +0 -1
- package/es/services/fetch-skills.d.ts +2 -8
- package/es/services/fetch-skills.js +3 -16
- package/es/services/fetch-slide.d.ts +2 -0
- package/es/services/fetch-slide.js +11 -0
- package/es/services/index.d.ts +2 -0
- package/es/services/index.js +8 -0
- package/es/services/post-progression.d.ts +2 -0
- package/es/services/post-progression.js +21 -0
- package/es/services/test/fetch-skills.test.js +29 -0
- package/es/services/test/post-progression.test.js +35 -0
- package/es/services/tools/fetch-responses.d.ts +1 -1
- package/es/services/tools/sleep.d.ts +1 -0
- package/es/services/tools/sleep.js +3 -0
- package/es/{index.test.js → test/index.test.js} +18 -7
- package/es/test/util/services.mock.d.ts +2 -0
- package/es/test/util/services.mock.js +68 -0
- package/es/types/common.d.ts +66 -2
- package/es/types/common.js +5 -0
- package/es/types/slides.d.ts +1 -1
- package/es/types/ui-progression.d.ts +10 -0
- package/es/types/views/slides.d.ts +1 -1
- package/lib/actions/api/fetch-skills.d.ts +10 -0
- package/lib/actions/api/fetch-skills.js +13 -0
- package/lib/actions/api/fetch-slide.d.ts +10 -0
- package/lib/actions/api/fetch-slide.js +13 -0
- package/lib/actions/api/post-progression.d.ts +10 -0
- package/lib/actions/api/post-progression.js +18 -0
- package/lib/actions/data/slides.d.ts +7 -24
- package/lib/actions/data/slides.js +0 -6
- package/lib/actions/data/token.d.ts +2 -2
- package/lib/actions/data/token.js +1 -1
- package/lib/actions/index.d.ts +5 -3
- package/lib/actions/ui/navigation.d.ts +0 -1
- package/lib/actions/ui/navigation.js +0 -4
- package/lib/actions/ui/step-items.d.ts +2 -8
- package/lib/actions/ui/step-items.js +0 -6
- package/lib/configure-store.d.ts +3 -34
- package/lib/configure-store.js +4 -4
- package/lib/fixtures/qcm-slide.d.ts +2 -2
- package/lib/index.d.ts +1 -1
- package/lib/index.js +78 -86
- package/lib/reducers/data/index.d.ts +16 -5
- package/lib/reducers/data/progression.d.ts +14 -9
- package/lib/reducers/data/progression.js +18 -58
- package/lib/reducers/data/skills.d.ts +4 -5
- package/lib/reducers/data/skills.js +3 -6
- package/lib/reducers/data/slides.d.ts +2 -1
- package/lib/reducers/data/slides.js +14 -9
- package/lib/reducers/data/token.d.ts +0 -1
- package/lib/reducers/data/token.js +1 -5
- package/lib/reducers/index.d.ts +9 -3
- package/lib/reducers/ui/finished-slides.d.ts +0 -1
- package/lib/reducers/ui/finished-slides.js +1 -3
- package/lib/reducers/ui/index.d.ts +14 -4
- package/lib/reducers/ui/navigation.d.ts +0 -1
- package/lib/reducers/ui/navigation.js +1 -3
- package/lib/reducers/ui/review-status.d.ts +0 -1
- package/lib/reducers/ui/review-status.js +1 -4
- package/lib/reducers/ui/step-items.d.ts +5 -5
- package/lib/reducers/ui/step-items.js +0 -1
- package/lib/services/fetch-skills.d.ts +2 -8
- package/lib/services/fetch-skills.js +5 -20
- package/lib/services/fetch-slide.d.ts +2 -0
- package/lib/services/fetch-slide.js +57 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.js +8 -0
- package/lib/services/post-progression.d.ts +2 -0
- package/lib/services/post-progression.js +65 -0
- package/lib/services/{fetch-skills.test.js → test/fetch-skills.test.js} +23 -16
- package/lib/services/test/post-progression.test.js +89 -0
- package/lib/services/tools/fetch-responses.d.ts +1 -1
- package/lib/services/tools/sleep.d.ts +1 -0
- package/lib/services/tools/sleep.js +5 -0
- package/lib/test/index.test.d.ts +1 -0
- package/lib/{index.test.js → test/index.test.js} +23 -15
- package/lib/test/util/services.mock.d.ts +2 -0
- package/lib/test/util/services.mock.js +68 -0
- package/lib/types/common.d.ts +66 -2
- package/lib/types/common.js +5 -0
- package/lib/types/slides.d.ts +1 -1
- package/lib/types/ui-progression.d.ts +10 -0
- package/lib/types/ui-progression.js +1 -0
- package/lib/types/views/slides.d.ts +1 -1
- package/package.json +6 -5
- package/readme.md +4 -5
- package/src/actions/api/fetch-skills.ts +20 -0
- package/src/actions/api/fetch-slide.ts +20 -0
- package/src/actions/api/post-progression.ts +26 -0
- package/src/actions/data/slides.ts +8 -32
- package/src/actions/data/token.ts +2 -2
- package/src/actions/index.ts +7 -10
- package/src/actions/ui/navigation.ts +0 -5
- package/src/actions/ui/step-items.ts +2 -14
- package/src/configure-store.ts +6 -45
- package/src/fixtures/qcm-slide.ts +2 -2
- package/src/index.tsx +94 -45
- package/src/reducers/data/index.ts +12 -4
- package/src/reducers/data/progression.ts +34 -79
- package/src/reducers/data/skills.ts +5 -10
- package/src/reducers/data/slides.ts +16 -15
- package/src/reducers/data/token.ts +1 -11
- package/src/reducers/index.ts +7 -2
- package/src/reducers/ui/finished-slides.ts +1 -7
- package/src/reducers/ui/index.ts +11 -4
- package/src/reducers/ui/navigation.ts +1 -6
- package/src/reducers/ui/review-status.ts +1 -8
- package/src/reducers/ui/step-items.ts +5 -14
- package/src/services/fetch-skills.ts +4 -30
- package/src/services/fetch-slide.ts +15 -0
- package/src/services/index.ts +10 -0
- package/src/services/post-progression.ts +28 -0
- package/src/services/test/fetch-skills.test.ts +39 -0
- package/src/services/test/post-progression.test.ts +45 -0
- package/src/services/tools/fetch-responses.ts +1 -1
- package/src/services/tools/sleep.ts +4 -0
- package/src/{index.test.tsx → test/index.test.tsx} +16 -10
- package/src/test/util/services.mock.ts +70 -0
- package/src/types/common.ts +78 -2
- package/src/types/globals.d.ts +2 -0
- package/src/types/slides.ts +1 -1
- package/src/types/ui-progression.ts +25 -0
- package/src/types/views/slides.ts +1 -1
- package/es/actions/data/skills.d.ts +0 -13
- package/es/actions/data/skills.js +0 -10
- package/es/middlewares/on-start-app.d.ts +0 -5
- package/es/middlewares/on-start-app.js +0 -29
- package/es/services/fetch-skills.mock.d.ts +0 -3
- package/es/services/fetch-skills.mock.js +0 -17
- package/es/services/fetch-skills.test.js +0 -22
- package/es/services/tools/fetch.mocks.d.ts +0 -8
- package/es/services/tools/fetch.mocks.js +0 -13
- package/es/types/skills.d.ts +0 -7
- package/lib/actions/data/skills.d.ts +0 -13
- package/lib/actions/data/skills.js +0 -10
- package/lib/middlewares/on-start-app.d.ts +0 -5
- package/lib/middlewares/on-start-app.js +0 -34
- package/lib/services/fetch-skills.mock.d.ts +0 -3
- package/lib/services/fetch-skills.mock.js +0 -17
- package/lib/services/tools/fetch.mocks.d.ts +0 -8
- package/lib/services/tools/fetch.mocks.js +0 -35
- package/lib/types/skills.d.ts +0 -7
- package/src/actions/data/skills.ts +0 -24
- package/src/middlewares/on-start-app.ts +0 -42
- package/src/services/fetch-skills.mock.ts +0 -21
- package/src/services/fetch-skills.test.ts +0 -32
- package/src/services/tools/fetch.mocks.ts +0 -41
- package/src/types/skills.ts +0 -8
- /package/es/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
- /package/es/{index.test.d.ts → services/test/post-progression.test.d.ts} +0 -0
- /package/{lib → es/test}/index.test.d.ts +0 -0
- /package/es/types/{skills.js → ui-progression.js} +0 -0
- /package/lib/services/{fetch-skills.test.d.ts → test/fetch-skills.test.d.ts} +0 -0
- /package/lib/{types/skills.js → services/test/post-progression.test.d.ts} +0 -0
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import { fetchSkills } from './fetch-skills';
|
|
3
|
-
import { okJSONResponse, token } from './tools/fetch.mocks';
|
|
4
|
-
test('should fetch skills with success', async (t) => {
|
|
5
|
-
const result = [
|
|
6
|
-
{
|
|
7
|
-
slidesToReview: 1,
|
|
8
|
-
name: 'skill-test',
|
|
9
|
-
custom: false,
|
|
10
|
-
skillRef: '_skill-ref'
|
|
11
|
-
}
|
|
12
|
-
];
|
|
13
|
-
const mockedFetchSkills = fetchSkills(okJSONResponse(result));
|
|
14
|
-
const skills = await mockedFetchSkills(token);
|
|
15
|
-
t.deepEqual(result, skills);
|
|
16
|
-
});
|
|
17
|
-
test('should reject bad token', async (t) => {
|
|
18
|
-
const badToken = 'token is not a jwt';
|
|
19
|
-
const mockedFetchSkills = fetchSkills(okJSONResponse([]));
|
|
20
|
-
const error = await t.throwsAsync(() => mockedFetchSkills(badToken));
|
|
21
|
-
t.is(error?.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
22
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
export declare const toResponse: (statusCode: number, statusText: string, body: string) => Promise<Response>;
|
|
3
|
-
export declare const okJSONResponse: (body: unknown) => typeof crossFetch;
|
|
4
|
-
export declare const internalServerErrorJSONResponse: (body: unknown) => typeof crossFetch;
|
|
5
|
-
export declare const notFoundJSONResponse: (body: unknown) => typeof crossFetch;
|
|
6
|
-
export declare const okTextResponse: (body: string) => typeof crossFetch;
|
|
7
|
-
export declare const internalServerErrorTextResponse: (body: string) => typeof crossFetch;
|
|
8
|
-
export declare const token: string;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const toResponse = (statusCode, statusText, body) => Promise.resolve({
|
|
2
|
-
ok: statusCode < 400,
|
|
3
|
-
status: statusCode,
|
|
4
|
-
statusText,
|
|
5
|
-
json: () => Promise.resolve(body).then(JSON.parse),
|
|
6
|
-
text: () => Promise.resolve(body)
|
|
7
|
-
});
|
|
8
|
-
export const okJSONResponse = (body) => () => toResponse(200, 'OK', JSON.stringify(body));
|
|
9
|
-
export const internalServerErrorJSONResponse = (body) => () => toResponse(500, 'InternalServerError', JSON.stringify(body));
|
|
10
|
-
export const notFoundJSONResponse = (body) => () => toResponse(404, 'Not Found', JSON.stringify(body));
|
|
11
|
-
export const okTextResponse = (body) => () => toResponse(200, 'OK', body);
|
|
12
|
-
export const internalServerErrorTextResponse = (body) => () => toResponse(500, 'InternalServerError', body);
|
|
13
|
-
export const token = process.env.API_TEST_TOKEN || 'no-API_TEST_TOKEN';
|
package/es/types/skills.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Skills } from '../../types/skills';
|
|
2
|
-
export declare const RECEIVED_SKILLS = "@@data/skills/RECEIVED_SKILLS";
|
|
3
|
-
export declare const ERROR_FETCHING_SKILLS = "@@data/skills/ERROR_FETCHING_SKILLS";
|
|
4
|
-
export declare type ReceivedSkills = {
|
|
5
|
-
type: '@@data/skills/RECEIVED_SKILLS';
|
|
6
|
-
payload: Skills;
|
|
7
|
-
};
|
|
8
|
-
export declare type ErrorFetchingSkills = {
|
|
9
|
-
type: '@@data/skills/ERROR_FETCHING_SKILLS';
|
|
10
|
-
payload: Error;
|
|
11
|
-
};
|
|
12
|
-
export declare const receivedSkills: (skills: Skills) => ReceivedSkills;
|
|
13
|
-
export declare const errorFetchingSkills: (error: Error) => ErrorFetchingSkills;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export var RECEIVED_SKILLS = '@@data/skills/RECEIVED_SKILLS';
|
|
2
|
-
export var ERROR_FETCHING_SKILLS = '@@data/skills/ERROR_FETCHING_SKILLS';
|
|
3
|
-
export var receivedSkills = function (skills) { return ({
|
|
4
|
-
type: RECEIVED_SKILLS,
|
|
5
|
-
payload: skills
|
|
6
|
-
}); };
|
|
7
|
-
export var errorFetchingSkills = function (error) { return ({
|
|
8
|
-
type: ERROR_FETCHING_SKILLS,
|
|
9
|
-
payload: error
|
|
10
|
-
}); };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { VIEWS } from '../common';
|
|
2
|
-
import { storeToken } from '../actions/data/token';
|
|
3
|
-
import { receivedSkills, errorFetchingSkills } from '../actions/data/skills';
|
|
4
|
-
import { storeFirstSlide } from '../actions/data/slides';
|
|
5
|
-
import { navigateTo, START_APP } from '../actions/ui/navigation';
|
|
6
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
7
|
-
import fetchSkills from '../services/fetch-skills';
|
|
8
|
-
var onStartApp = function (_a) {
|
|
9
|
-
var dispatch = _a.dispatch;
|
|
10
|
-
return function (next) {
|
|
11
|
-
return function (action) {
|
|
12
|
-
if (action.type === START_APP) {
|
|
13
|
-
var _a = action.payload, slide = _a.slide, token = _a.token;
|
|
14
|
-
dispatch(storeToken(token));
|
|
15
|
-
if (slide) {
|
|
16
|
-
dispatch(storeFirstSlide(slide));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
fetchSkills(token)
|
|
20
|
-
.then(function (skills) {
|
|
21
|
-
return dispatch(receivedSkills(skills));
|
|
22
|
-
})
|
|
23
|
-
.catch(function (err) {
|
|
24
|
-
return dispatch(errorFetchingSkills(err));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
var initialView = slide ? VIEWS.slides : VIEWS.skills;
|
|
28
|
-
dispatch(navigateTo(initialView));
|
|
29
|
-
}
|
|
30
|
-
return next(action);
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
export default onStartApp;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { okJSONResponse } from './tools/fetch.mocks';
|
|
2
|
-
var result = [
|
|
3
|
-
{
|
|
4
|
-
skillRef: '_skill-ref',
|
|
5
|
-
slidesToReview: 2,
|
|
6
|
-
name: 'skill-test',
|
|
7
|
-
custom: false
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
skillRef: '_skill-ref-2',
|
|
11
|
-
slidesToReview: 2,
|
|
12
|
-
name: 'skill-test-2',
|
|
13
|
-
custom: true
|
|
14
|
-
}
|
|
15
|
-
];
|
|
16
|
-
var mockFetchSkills = okJSONResponse(result);
|
|
17
|
-
export default mockFetchSkills;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
export declare const toResponse: (statusCode: number, statusText: string, body: string) => Promise<Response>;
|
|
3
|
-
export declare const okJSONResponse: (body: unknown) => typeof crossFetch;
|
|
4
|
-
export declare const internalServerErrorJSONResponse: (body: unknown) => typeof crossFetch;
|
|
5
|
-
export declare const notFoundJSONResponse: (body: unknown) => typeof crossFetch;
|
|
6
|
-
export declare const okTextResponse: (body: string) => typeof crossFetch;
|
|
7
|
-
export declare const internalServerErrorTextResponse: (body: string) => typeof crossFetch;
|
|
8
|
-
export declare const token: string;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export var toResponse = function (statusCode, statusText, body) {
|
|
2
|
-
return Promise.resolve({
|
|
3
|
-
ok: statusCode < 400,
|
|
4
|
-
status: statusCode,
|
|
5
|
-
statusText: statusText,
|
|
6
|
-
json: function () { return Promise.resolve(body).then(JSON.parse); },
|
|
7
|
-
text: function () { return Promise.resolve(body); }
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export var okJSONResponse = function (body) {
|
|
11
|
-
return function () {
|
|
12
|
-
return toResponse(200, 'OK', JSON.stringify(body));
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
export var internalServerErrorJSONResponse = function (body) {
|
|
16
|
-
return function () {
|
|
17
|
-
return toResponse(500, 'InternalServerError', JSON.stringify(body));
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export var notFoundJSONResponse = function (body) {
|
|
21
|
-
return function () {
|
|
22
|
-
return toResponse(404, 'Not Found', JSON.stringify(body));
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export var okTextResponse = function (body) {
|
|
26
|
-
return function () {
|
|
27
|
-
return toResponse(200, 'OK', body);
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
export var internalServerErrorTextResponse = function (body) {
|
|
31
|
-
return function () {
|
|
32
|
-
return toResponse(500, 'InternalServerError', body);
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export var token = process.env.API_TEST_TOKEN || 'no-API_TEST_TOKEN';
|
package/lib/types/skills.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {Skills} from '../../types/skills';
|
|
2
|
-
|
|
3
|
-
export const RECEIVED_SKILLS = '@@data/skills/RECEIVED_SKILLS';
|
|
4
|
-
export const ERROR_FETCHING_SKILLS = '@@data/skills/ERROR_FETCHING_SKILLS';
|
|
5
|
-
|
|
6
|
-
export type ReceivedSkills = {
|
|
7
|
-
type: '@@data/skills/RECEIVED_SKILLS';
|
|
8
|
-
payload: Skills;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type ErrorFetchingSkills = {
|
|
12
|
-
type: '@@data/skills/ERROR_FETCHING_SKILLS';
|
|
13
|
-
payload: Error;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const receivedSkills = (skills: Skills): ReceivedSkills => ({
|
|
17
|
-
type: RECEIVED_SKILLS,
|
|
18
|
-
payload: skills
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
export const errorFetchingSkills = (error: Error): ErrorFetchingSkills => ({
|
|
22
|
-
type: ERROR_FETCHING_SKILLS,
|
|
23
|
-
payload: error
|
|
24
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type {Middleware, Store} from 'redux';
|
|
2
|
-
import {Dispatch} from 'redux';
|
|
3
|
-
|
|
4
|
-
import {VIEWS} from '../common';
|
|
5
|
-
import {Action} from '../actions';
|
|
6
|
-
import {storeToken} from '../actions/data/token';
|
|
7
|
-
import {receivedSkills, errorFetchingSkills} from '../actions/data/skills';
|
|
8
|
-
import {storeFirstSlide} from '../actions/data/slides';
|
|
9
|
-
import {navigateTo, START_APP, ViewPath} from '../actions/ui/navigation';
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
12
|
-
import fetchSkills from '../services/fetch-skills';
|
|
13
|
-
|
|
14
|
-
const onStartApp: Middleware<{}, Store, Dispatch<Action>> =
|
|
15
|
-
({dispatch}) =>
|
|
16
|
-
next =>
|
|
17
|
-
(action: Action) => {
|
|
18
|
-
if (action.type === START_APP) {
|
|
19
|
-
const {slide, token} = action.payload;
|
|
20
|
-
|
|
21
|
-
dispatch(storeToken(token));
|
|
22
|
-
|
|
23
|
-
if (slide) {
|
|
24
|
-
dispatch(storeFirstSlide(slide));
|
|
25
|
-
} else {
|
|
26
|
-
fetchSkills(token)
|
|
27
|
-
.then(skills => {
|
|
28
|
-
return dispatch(receivedSkills(skills));
|
|
29
|
-
})
|
|
30
|
-
.catch(err => {
|
|
31
|
-
return dispatch(errorFetchingSkills(err));
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const initialView: ViewPath = slide ? VIEWS.slides : VIEWS.skills;
|
|
36
|
-
dispatch(navigateTo(initialView));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return next(action);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default onStartApp;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
import {Skills} from '../types/skills';
|
|
3
|
-
import {okJSONResponse} from './tools/fetch.mocks';
|
|
4
|
-
|
|
5
|
-
const result: Skills = [
|
|
6
|
-
{
|
|
7
|
-
skillRef: '_skill-ref',
|
|
8
|
-
slidesToReview: 2,
|
|
9
|
-
name: 'skill-test',
|
|
10
|
-
custom: false
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
skillRef: '_skill-ref-2',
|
|
14
|
-
slidesToReview: 2,
|
|
15
|
-
name: 'skill-test-2',
|
|
16
|
-
custom: true
|
|
17
|
-
}
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const mockFetchSkills: typeof crossFetch = okJSONResponse(result);
|
|
21
|
-
export default mockFetchSkills;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import {Skills} from '../types/skills';
|
|
3
|
-
import {fetchSkills} from './fetch-skills';
|
|
4
|
-
import {okJSONResponse, token} from './tools/fetch.mocks';
|
|
5
|
-
|
|
6
|
-
test('should fetch skills with success', async t => {
|
|
7
|
-
const result: Skills = [
|
|
8
|
-
{
|
|
9
|
-
slidesToReview: 1,
|
|
10
|
-
name: 'skill-test',
|
|
11
|
-
custom: false,
|
|
12
|
-
skillRef: '_skill-ref'
|
|
13
|
-
}
|
|
14
|
-
];
|
|
15
|
-
|
|
16
|
-
const mockedFetchSkills = fetchSkills(okJSONResponse(result));
|
|
17
|
-
const skills = await mockedFetchSkills(token);
|
|
18
|
-
|
|
19
|
-
t.deepEqual(result, skills);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('should reject bad token', async t => {
|
|
23
|
-
const badToken = 'token is not a jwt';
|
|
24
|
-
const mockedFetchSkills = fetchSkills(okJSONResponse([]));
|
|
25
|
-
|
|
26
|
-
const error = await t.throwsAsync(() => mockedFetchSkills(badToken));
|
|
27
|
-
|
|
28
|
-
t.is(
|
|
29
|
-
error?.message,
|
|
30
|
-
"Invalid token specified: Cannot read properties of undefined (reading 'replace')"
|
|
31
|
-
);
|
|
32
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import crossFetch from 'cross-fetch';
|
|
2
|
-
|
|
3
|
-
export const toResponse = (
|
|
4
|
-
statusCode: number,
|
|
5
|
-
statusText: string,
|
|
6
|
-
body: string
|
|
7
|
-
): Promise<Response> =>
|
|
8
|
-
Promise.resolve({
|
|
9
|
-
ok: statusCode < 400,
|
|
10
|
-
status: statusCode,
|
|
11
|
-
statusText,
|
|
12
|
-
json: (): Promise<unknown> => Promise.resolve(body).then(JSON.parse),
|
|
13
|
-
text: (): Promise<string> => Promise.resolve(body)
|
|
14
|
-
} as Response);
|
|
15
|
-
|
|
16
|
-
export const okJSONResponse =
|
|
17
|
-
(body: unknown): typeof crossFetch =>
|
|
18
|
-
() =>
|
|
19
|
-
toResponse(200, 'OK', JSON.stringify(body));
|
|
20
|
-
|
|
21
|
-
export const internalServerErrorJSONResponse =
|
|
22
|
-
(body: unknown): typeof crossFetch =>
|
|
23
|
-
() =>
|
|
24
|
-
toResponse(500, 'InternalServerError', JSON.stringify(body));
|
|
25
|
-
|
|
26
|
-
export const notFoundJSONResponse =
|
|
27
|
-
(body: unknown): typeof crossFetch =>
|
|
28
|
-
() =>
|
|
29
|
-
toResponse(404, 'Not Found', JSON.stringify(body));
|
|
30
|
-
|
|
31
|
-
export const okTextResponse =
|
|
32
|
-
(body: string): typeof crossFetch =>
|
|
33
|
-
() =>
|
|
34
|
-
toResponse(200, 'OK', body);
|
|
35
|
-
|
|
36
|
-
export const internalServerErrorTextResponse =
|
|
37
|
-
(body: string): typeof crossFetch =>
|
|
38
|
-
() =>
|
|
39
|
-
toResponse(500, 'InternalServerError', body);
|
|
40
|
-
|
|
41
|
-
export const token: string = process.env.API_TEST_TOKEN || 'no-API_TEST_TOKEN';
|
package/src/types/skills.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|