@coorpacademy/app-review 0.2.12 → 0.3.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/actions/api/fetch-correction.js +1 -1
- package/es/actions/api/post-answer.d.ts +6 -0
- package/es/actions/api/post-answer.js +3 -1
- package/es/actions/ui/answers.d.ts +3 -0
- package/es/actions/ui/answers.js +3 -1
- package/es/reducers/index.d.ts +1 -1
- package/es/reducers/ui/answers.d.ts +4 -2
- package/es/reducers/ui/answers.js +6 -3
- package/es/reducers/ui/index.d.ts +4 -4
- package/es/reducers/ui/slide.d.ts +6 -4
- package/es/reducers/ui/slide.js +12 -4
- package/es/views/slides/index.js +4 -4
- package/lib/actions/api/fetch-correction.js +1 -1
- package/lib/actions/api/post-answer.d.ts +6 -0
- package/lib/actions/api/post-answer.js +4 -2
- package/lib/actions/ui/answers.d.ts +3 -0
- package/lib/actions/ui/answers.js +3 -1
- package/lib/reducers/index.d.ts +1 -1
- package/lib/reducers/ui/answers.d.ts +4 -2
- package/lib/reducers/ui/answers.js +6 -3
- package/lib/reducers/ui/index.d.ts +4 -4
- package/lib/reducers/ui/slide.d.ts +6 -4
- package/lib/reducers/ui/slide.js +12 -4
- package/lib/views/slides/index.js +4 -4
- package/package.json +4 -4
- package/src/actions/api/fetch-correction.ts +1 -1
- package/src/actions/api/post-answer.ts +5 -1
- package/src/actions/api/test/fetch-correction.test.ts +6 -2
- package/src/actions/api/test/fetch-rank.test.ts +2 -4
- package/src/actions/api/test/fetch-skills.test.ts +2 -4
- package/src/actions/api/test/fetch-slide.test.ts +2 -4
- package/src/actions/api/test/post-answer.test.ts +52 -13
- package/src/actions/api/test/post-progression.test.ts +2 -4
- package/src/actions/data/test/token.test.ts +2 -4
- package/src/actions/ui/answers.ts +4 -1
- package/src/actions/ui/test/answers.test.ts +38 -14
- package/src/actions/ui/test/next-slide.test.ts +8 -4
- package/src/actions/ui/test/slides.test.ts +2 -4
- package/src/reducers/data/test/progression.test.ts +1 -0
- package/src/reducers/ui/answers.ts +11 -5
- package/src/reducers/ui/index.ts +2 -2
- package/src/reducers/ui/slide.ts +30 -9
- package/src/reducers/ui/test/answers.test.ts +61 -13
- package/src/reducers/ui/test/slide.test.ts +36 -7
- package/src/views/skills/test/skills.test.ts +4 -8
- package/src/views/slides/index.ts +4 -4
- package/src/views/slides/test/index.test.ts +173 -28
- package/src/views/slides/test/slide.free-text.on-change.test.ts +7 -2
- package/src/views/slides/test/slide.qcm-drag.on-click.test.ts +7 -2
- package/src/views/slides/test/slide.qcm-graphic.on-click.test.ts +7 -2
- package/src/views/slides/test/slide.qcm.on-click.test.ts +7 -2
- package/src/views/slides/test/slide.slider.on-change.test.ts +7 -2
- package/src/views/slides/test/slide.slider.on-slider-change.test.ts +7 -2
- package/src/views/slides/test/slide.template.on-change.test.ts +12 -4
- package/es/actions/api/test/fetch-correction.test.d.ts +0 -1
- package/es/actions/api/test/fetch-correction.test.js +0 -91
- package/es/actions/api/test/fetch-rank.test.d.ts +0 -1
- package/es/actions/api/test/fetch-rank.test.js +0 -100
- package/es/actions/api/test/fetch-skills.test.d.ts +0 -1
- package/es/actions/api/test/fetch-skills.test.js +0 -61
- package/es/actions/api/test/fetch-slide.test.d.ts +0 -1
- package/es/actions/api/test/fetch-slide.test.js +0 -68
- package/es/actions/api/test/post-answer.test.d.ts +0 -1
- package/es/actions/api/test/post-answer.test.js +0 -172
- package/es/actions/api/test/post-progression.test.d.ts +0 -1
- package/es/actions/api/test/post-progression.test.js +0 -109
- package/es/actions/data/test/token.test.d.ts +0 -1
- package/es/actions/data/test/token.test.js +0 -27
- package/es/actions/ui/test/answers.test.d.ts +0 -1
- package/es/actions/ui/test/answers.test.js +0 -117
- package/es/actions/ui/test/next-slide.test.d.ts +0 -1
- package/es/actions/ui/test/next-slide.test.js +0 -63
- package/es/actions/ui/test/slides.test.d.ts +0 -1
- package/es/actions/ui/test/slides.test.js +0 -28
- package/es/reducers/data/test/corrections.test.d.ts +0 -1
- package/es/reducers/data/test/corrections.test.js +0 -27
- package/es/reducers/data/test/progression.test.d.ts +0 -1
- package/es/reducers/data/test/progression.test.js +0 -24
- package/es/reducers/data/test/rank.test.d.ts +0 -1
- package/es/reducers/data/test/rank.test.js +0 -59
- package/es/reducers/data/test/skills.test.d.ts +0 -1
- package/es/reducers/data/test/skills.test.js +0 -12
- package/es/reducers/data/test/slides.test.d.ts +0 -1
- package/es/reducers/data/test/slides.test.js +0 -21
- package/es/reducers/data/test/token.test.d.ts +0 -1
- package/es/reducers/data/test/token.test.js +0 -11
- package/es/reducers/ui/test/answers.test.d.ts +0 -1
- package/es/reducers/ui/test/answers.test.js +0 -31
- package/es/reducers/ui/test/current-slide-ref.test.d.ts +0 -1
- package/es/reducers/ui/test/current-slide-ref.test.js +0 -12
- package/es/reducers/ui/test/navigation.test.d.ts +0 -1
- package/es/reducers/ui/test/navigation.test.js +0 -15
- package/es/reducers/ui/test/slide.test.d.ts +0 -1
- package/es/reducers/ui/test/slide.test.js +0 -24
- package/es/services/test/fetch-correction.test.d.ts +0 -1
- package/es/services/test/fetch-correction.test.js +0 -39
- package/es/services/test/fetch-rank.test.d.ts +0 -1
- package/es/services/test/fetch-rank.test.js +0 -24
- package/es/services/test/fetch-skills.test.d.ts +0 -1
- package/es/services/test/fetch-skills.test.js +0 -29
- package/es/services/test/fetch-slide.test.d.ts +0 -1
- package/es/services/test/fetch-slide.test.js +0 -22
- package/es/services/test/post-answer.test.d.ts +0 -1
- package/es/services/test/post-answer.test.js +0 -88
- package/es/services/test/post-progression.test.d.ts +0 -1
- package/es/services/test/post-progression.test.js +0 -56
- package/es/views/skills/test/skills.test.d.ts +0 -1
- package/es/views/skills/test/skills.test.js +0 -98
- package/es/views/slides/test/index.test.d.ts +0 -1
- package/es/views/slides/test/index.test.js +0 -979
- package/es/views/slides/test/map-api-slide-to-ui.test.d.ts +0 -1
- package/es/views/slides/test/map-api-slide-to-ui.test.js +0 -36
- package/es/views/slides/test/slide.free-text.on-change.test.d.ts +0 -1
- package/es/views/slides/test/slide.free-text.on-change.test.js +0 -72
- package/es/views/slides/test/slide.qcm-drag.on-click.test.d.ts +0 -1
- package/es/views/slides/test/slide.qcm-drag.on-click.test.js +0 -72
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +0 -1
- package/es/views/slides/test/slide.qcm-graphic.on-click.test.js +0 -72
- package/es/views/slides/test/slide.qcm.on-click.test.d.ts +0 -1
- package/es/views/slides/test/slide.qcm.on-click.test.js +0 -74
- package/es/views/slides/test/slide.slider.on-change.test.d.ts +0 -1
- package/es/views/slides/test/slide.slider.on-change.test.js +0 -73
- package/es/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
- package/es/views/slides/test/slide.slider.on-slider-change.test.js +0 -63
- package/es/views/slides/test/slide.template.on-change.test.d.ts +0 -1
- package/es/views/slides/test/slide.template.on-change.test.js +0 -85
- package/lib/actions/api/test/fetch-correction.test.d.ts +0 -1
- package/lib/actions/api/test/fetch-correction.test.js +0 -151
- package/lib/actions/api/test/fetch-rank.test.d.ts +0 -1
- package/lib/actions/api/test/fetch-rank.test.js +0 -171
- package/lib/actions/api/test/fetch-skills.test.d.ts +0 -1
- package/lib/actions/api/test/fetch-skills.test.js +0 -120
- package/lib/actions/api/test/fetch-slide.test.d.ts +0 -1
- package/lib/actions/api/test/fetch-slide.test.js +0 -127
- package/lib/actions/api/test/post-answer.test.d.ts +0 -1
- package/lib/actions/api/test/post-answer.test.js +0 -254
- package/lib/actions/api/test/post-progression.test.d.ts +0 -1
- package/lib/actions/api/test/post-progression.test.js +0 -167
- package/lib/actions/data/test/token.test.d.ts +0 -1
- package/lib/actions/data/test/token.test.js +0 -72
- package/lib/actions/ui/test/answers.test.d.ts +0 -1
- package/lib/actions/ui/test/answers.test.js +0 -233
- package/lib/actions/ui/test/next-slide.test.d.ts +0 -1
- package/lib/actions/ui/test/next-slide.test.js +0 -64
- package/lib/actions/ui/test/slides.test.d.ts +0 -1
- package/lib/actions/ui/test/slides.test.js +0 -73
- package/lib/reducers/data/test/corrections.test.d.ts +0 -1
- package/lib/reducers/data/test/corrections.test.js +0 -28
- package/lib/reducers/data/test/progression.test.d.ts +0 -1
- package/lib/reducers/data/test/progression.test.js +0 -24
- package/lib/reducers/data/test/rank.test.d.ts +0 -1
- package/lib/reducers/data/test/rank.test.js +0 -59
- package/lib/reducers/data/test/skills.test.d.ts +0 -1
- package/lib/reducers/data/test/skills.test.js +0 -12
- package/lib/reducers/data/test/slides.test.d.ts +0 -1
- package/lib/reducers/data/test/slides.test.js +0 -22
- package/lib/reducers/data/test/token.test.d.ts +0 -1
- package/lib/reducers/data/test/token.test.js +0 -11
- package/lib/reducers/ui/test/answers.test.d.ts +0 -1
- package/lib/reducers/ui/test/answers.test.js +0 -31
- package/lib/reducers/ui/test/current-slide-ref.test.d.ts +0 -1
- package/lib/reducers/ui/test/current-slide-ref.test.js +0 -12
- package/lib/reducers/ui/test/navigation.test.d.ts +0 -1
- package/lib/reducers/ui/test/navigation.test.js +0 -15
- package/lib/reducers/ui/test/slide.test.d.ts +0 -1
- package/lib/reducers/ui/test/slide.test.js +0 -24
- package/lib/services/test/fetch-correction.test.d.ts +0 -1
- package/lib/services/test/fetch-correction.test.js +0 -95
- package/lib/services/test/fetch-rank.test.d.ts +0 -1
- package/lib/services/test/fetch-rank.test.js +0 -78
- package/lib/services/test/fetch-skills.test.d.ts +0 -1
- package/lib/services/test/fetch-skills.test.js +0 -83
- package/lib/services/test/fetch-slide.test.d.ts +0 -1
- package/lib/services/test/fetch-slide.test.js +0 -76
- package/lib/services/test/post-answer.test.d.ts +0 -1
- package/lib/services/test/post-answer.test.js +0 -142
- package/lib/services/test/post-progression.test.d.ts +0 -1
- package/lib/services/test/post-progression.test.js +0 -110
- package/lib/views/skills/test/skills.test.d.ts +0 -1
- package/lib/views/skills/test/skills.test.js +0 -98
- package/lib/views/slides/test/index.test.d.ts +0 -1
- package/lib/views/slides/test/index.test.js +0 -990
- package/lib/views/slides/test/map-api-slide-to-ui.test.d.ts +0 -1
- package/lib/views/slides/test/map-api-slide-to-ui.test.js +0 -47
- package/lib/views/slides/test/slide.free-text.on-change.test.d.ts +0 -1
- package/lib/views/slides/test/slide.free-text.on-change.test.js +0 -74
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.d.ts +0 -1
- package/lib/views/slides/test/slide.qcm-drag.on-click.test.js +0 -74
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.d.ts +0 -1
- package/lib/views/slides/test/slide.qcm-graphic.on-click.test.js +0 -74
- package/lib/views/slides/test/slide.qcm.on-click.test.d.ts +0 -1
- package/lib/views/slides/test/slide.qcm.on-click.test.js +0 -76
- package/lib/views/slides/test/slide.slider.on-change.test.d.ts +0 -1
- package/lib/views/slides/test/slide.slider.on-change.test.js +0 -75
- package/lib/views/slides/test/slide.slider.on-slider-change.test.d.ts +0 -1
- package/lib/views/slides/test/slide.slider.on-slider-change.test.js +0 -65
- package/lib/views/slides/test/slide.template.on-change.test.d.ts +0 -1
- package/lib/views/slides/test/slide.template.on-change.test.js +0 -88
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import test from 'ava';
|
|
2
|
-
import reducer, { initialState } from '../slide';
|
|
3
|
-
import { EDIT_BASIC } from '../../../actions/ui/answers';
|
|
4
|
-
import { CORRECTION_FETCH_SUCCESS } from '../../../actions/api/fetch-correction';
|
|
5
|
-
test('should use initial state if no answers are found when an EditAnswerAction is received', function (t) {
|
|
6
|
-
var state = reducer(undefined, { type: EDIT_BASIC, payload: [''] });
|
|
7
|
-
t.truthy(state);
|
|
8
|
-
t.false(state.validateButton);
|
|
9
|
-
t.falsy(state.animateCorrectionPopin);
|
|
10
|
-
});
|
|
11
|
-
test('should set animateCorrectionPopin to true if CORRECTION_FETCH_SUCCESS is received', function (t) {
|
|
12
|
-
var state = reducer(undefined, {
|
|
13
|
-
type: CORRECTION_FETCH_SUCCESS,
|
|
14
|
-
payload: undefined,
|
|
15
|
-
meta: { slideRef: '1234' }
|
|
16
|
-
});
|
|
17
|
-
t.truthy(state);
|
|
18
|
-
t.false(state.validateButton);
|
|
19
|
-
t.true(state.animateCorrectionPopin);
|
|
20
|
-
});
|
|
21
|
-
test('should return state directly when there is no corresponding action handler + have an initial state', function (t) {
|
|
22
|
-
var state = reducer(undefined, { type: 'NOPE' });
|
|
23
|
-
t.deepEqual(state, initialState);
|
|
24
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import test from 'ava';
|
|
38
|
-
import nock from 'nock';
|
|
39
|
-
import { fetchCorrection } from '../fetch-correction';
|
|
40
|
-
var progressionId = '123456789123';
|
|
41
|
-
var slideRef = 'sli_123546';
|
|
42
|
-
var answer = ['Lister vos tâches pour vous libérer l’esprit', '15 jours à Bora Bora'];
|
|
43
|
-
var correction = {
|
|
44
|
-
correctAnswer: ['15 jours à Bora Bora'],
|
|
45
|
-
corrections: [
|
|
46
|
-
{
|
|
47
|
-
answer: answer[0],
|
|
48
|
-
isCorrect: false
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
answer: answer[1],
|
|
52
|
-
isCorrect: true
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
};
|
|
56
|
-
test.before(function () {
|
|
57
|
-
nock('http://localhost:3000')
|
|
58
|
-
.post("/api/v2/progressions/".concat(progressionId, "/answers/").concat(slideRef), JSON.stringify({
|
|
59
|
-
answer: answer
|
|
60
|
-
}))
|
|
61
|
-
.reply(200, correction);
|
|
62
|
-
});
|
|
63
|
-
test.after(function () {
|
|
64
|
-
nock.cleanAll();
|
|
65
|
-
});
|
|
66
|
-
test('should fetch the correction of the slide for the specified progression successfully', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
67
|
-
var token, response;
|
|
68
|
-
return __generator(this, function (_a) {
|
|
69
|
-
switch (_a.label) {
|
|
70
|
-
case 0:
|
|
71
|
-
token = process.env.API_TEST_TOKEN || '';
|
|
72
|
-
return [4 /*yield*/, fetchCorrection(slideRef, token, progressionId, answer)];
|
|
73
|
-
case 1:
|
|
74
|
-
response = _a.sent();
|
|
75
|
-
t.deepEqual(correction, response);
|
|
76
|
-
return [2 /*return*/];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}); });
|
|
80
|
-
test('should reject if a bad token is passed', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
81
|
-
var badToken, error;
|
|
82
|
-
return __generator(this, function (_a) {
|
|
83
|
-
switch (_a.label) {
|
|
84
|
-
case 0:
|
|
85
|
-
badToken = 'token is not a jwt';
|
|
86
|
-
return [4 /*yield*/, t.throwsAsync(function () {
|
|
87
|
-
return fetchCorrection(slideRef, badToken, progressionId, answer);
|
|
88
|
-
})];
|
|
89
|
-
case 1:
|
|
90
|
-
error = _a.sent();
|
|
91
|
-
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
92
|
-
return [2 /*return*/];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import test from 'ava';
|
|
38
|
-
import nock from 'nock';
|
|
39
|
-
import { fetchRank } from '../fetch-rank';
|
|
40
|
-
var result = {
|
|
41
|
-
rank: 93
|
|
42
|
-
};
|
|
43
|
-
test.before(function () {
|
|
44
|
-
nock('http://localhost:3000')
|
|
45
|
-
.get('/api/v1/leaderboard/rank/592d830b240b923f00bffba6?group=ALL')
|
|
46
|
-
.reply(200, result);
|
|
47
|
-
});
|
|
48
|
-
test.after(function () {
|
|
49
|
-
nock.cleanAll();
|
|
50
|
-
});
|
|
51
|
-
test('should fetch rank with success', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
-
var token, rank;
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0:
|
|
56
|
-
token = process.env.API_TEST_TOKEN || '';
|
|
57
|
-
return [4 /*yield*/, fetchRank(token)];
|
|
58
|
-
case 1:
|
|
59
|
-
rank = _a.sent();
|
|
60
|
-
t.deepEqual(result, rank);
|
|
61
|
-
return [2 /*return*/];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}); });
|
|
65
|
-
test('should reject bad token', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
66
|
-
var badToken, error;
|
|
67
|
-
return __generator(this, function (_a) {
|
|
68
|
-
switch (_a.label) {
|
|
69
|
-
case 0:
|
|
70
|
-
badToken = 'token is not a jwt';
|
|
71
|
-
return [4 /*yield*/, t.throwsAsync(function () { return fetchRank(badToken); })];
|
|
72
|
-
case 1:
|
|
73
|
-
error = _a.sent();
|
|
74
|
-
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
75
|
-
return [2 /*return*/];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import test from 'ava';
|
|
38
|
-
import nock from 'nock';
|
|
39
|
-
import { fetchSkills } from '../fetch-skills';
|
|
40
|
-
var result = [
|
|
41
|
-
{
|
|
42
|
-
slidesToReview: 1,
|
|
43
|
-
name: 'skill-test',
|
|
44
|
-
custom: false,
|
|
45
|
-
skillRef: '_skill-ref'
|
|
46
|
-
}
|
|
47
|
-
];
|
|
48
|
-
test.before(function () {
|
|
49
|
-
nock('http://localhost:3000')
|
|
50
|
-
.get('/api/v2/skills/review/user/592d830b240b923f00bffba6')
|
|
51
|
-
.reply(200, result);
|
|
52
|
-
});
|
|
53
|
-
test.after(function () {
|
|
54
|
-
nock.cleanAll();
|
|
55
|
-
});
|
|
56
|
-
test('should fetch skills with success', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
57
|
-
var token, skills;
|
|
58
|
-
return __generator(this, function (_a) {
|
|
59
|
-
switch (_a.label) {
|
|
60
|
-
case 0:
|
|
61
|
-
token = process.env.API_TEST_TOKEN || '';
|
|
62
|
-
return [4 /*yield*/, fetchSkills(token)];
|
|
63
|
-
case 1:
|
|
64
|
-
skills = _a.sent();
|
|
65
|
-
t.deepEqual(result, skills);
|
|
66
|
-
return [2 /*return*/];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); });
|
|
70
|
-
test('should reject bad token', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
var badToken, error;
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
badToken = 'token is not a jwt';
|
|
76
|
-
return [4 /*yield*/, t.throwsAsync(function () { return fetchSkills(badToken); })];
|
|
77
|
-
case 1:
|
|
78
|
-
error = _a.sent();
|
|
79
|
-
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
80
|
-
return [2 /*return*/];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import test from 'ava';
|
|
38
|
-
import nock from 'nock';
|
|
39
|
-
import { qcmDragSlide } from '../../views/slides/test/fixtures/qcm-drag';
|
|
40
|
-
import { fetchSlide } from '../fetch-slide';
|
|
41
|
-
test.before(function () {
|
|
42
|
-
nock('http://localhost:3000')
|
|
43
|
-
.get('/api/v1/slides/sli_123546/parentContentTitle')
|
|
44
|
-
.reply(200, qcmDragSlide);
|
|
45
|
-
});
|
|
46
|
-
test.after(function () {
|
|
47
|
-
nock.cleanAll();
|
|
48
|
-
});
|
|
49
|
-
test('should fetch a slide with the parentTitleContent info successfully', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
-
var token, slide;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
token = process.env.API_TEST_TOKEN || '';
|
|
55
|
-
return [4 /*yield*/, fetchSlide('sli_123546', token)];
|
|
56
|
-
case 1:
|
|
57
|
-
slide = _a.sent();
|
|
58
|
-
t.deepEqual(qcmDragSlide, slide);
|
|
59
|
-
return [2 /*return*/];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}); });
|
|
63
|
-
test('should reject if a bad token is passed', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
-
var badToken, error;
|
|
65
|
-
return __generator(this, function (_a) {
|
|
66
|
-
switch (_a.label) {
|
|
67
|
-
case 0:
|
|
68
|
-
badToken = 'token is not a jwt';
|
|
69
|
-
return [4 /*yield*/, t.throwsAsync(function () { return fetchSlide('sli_123546', badToken); })];
|
|
70
|
-
case 1:
|
|
71
|
-
error = _a.sent();
|
|
72
|
-
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
73
|
-
return [2 /*return*/];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import test from 'ava';
|
|
38
|
-
import nock from 'nock';
|
|
39
|
-
import { postAnswer } from '../post-answer';
|
|
40
|
-
var skillRef = '_skill-ref';
|
|
41
|
-
var answer = ['Lister vos tâches pour vous libérer l’esprit', 'Vous isoler dans un lieu calme'];
|
|
42
|
-
var initProgression = {
|
|
43
|
-
content: {
|
|
44
|
-
type: 'skill',
|
|
45
|
-
ref: skillRef
|
|
46
|
-
},
|
|
47
|
-
engine: {
|
|
48
|
-
ref: 'review'
|
|
49
|
-
},
|
|
50
|
-
_id: '123456123456',
|
|
51
|
-
state: {
|
|
52
|
-
allAnswers: [],
|
|
53
|
-
isCorrect: true,
|
|
54
|
-
nextContent: {
|
|
55
|
-
type: 'slide',
|
|
56
|
-
ref: 'sli_NkvrWPFF2'
|
|
57
|
-
},
|
|
58
|
-
pendingSlides: [],
|
|
59
|
-
slides: [],
|
|
60
|
-
step: {
|
|
61
|
-
current: 1
|
|
62
|
-
},
|
|
63
|
-
stars: 0
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
var result = {
|
|
67
|
-
content: {
|
|
68
|
-
type: 'skill',
|
|
69
|
-
ref: skillRef
|
|
70
|
-
},
|
|
71
|
-
engine: {
|
|
72
|
-
ref: 'review'
|
|
73
|
-
},
|
|
74
|
-
_id: '123456123456',
|
|
75
|
-
state: {
|
|
76
|
-
allAnswers: [
|
|
77
|
-
{
|
|
78
|
-
slideRef: 'sli_NkvrWPFF2',
|
|
79
|
-
isCorrect: true,
|
|
80
|
-
answer: answer
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
isCorrect: true,
|
|
84
|
-
nextContent: {
|
|
85
|
-
type: 'slide',
|
|
86
|
-
ref: 'sli_NJ3m5KtWh'
|
|
87
|
-
},
|
|
88
|
-
pendingSlides: [],
|
|
89
|
-
slides: ['sli_NkvrWPFF2'],
|
|
90
|
-
content: {
|
|
91
|
-
ref: 'sli_NkvrWPFF2',
|
|
92
|
-
type: 'slide'
|
|
93
|
-
},
|
|
94
|
-
step: {
|
|
95
|
-
current: 2
|
|
96
|
-
},
|
|
97
|
-
stars: 4
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
test.before(function () {
|
|
101
|
-
var moocApi = nock('http://localhost:3000');
|
|
102
|
-
moocApi
|
|
103
|
-
.post('/api/v2/progressions/123456123456/answers', {
|
|
104
|
-
content: {
|
|
105
|
-
ref: 'sli_NkvrWPFF2',
|
|
106
|
-
type: 'slide'
|
|
107
|
-
},
|
|
108
|
-
answer: answer
|
|
109
|
-
})
|
|
110
|
-
.reply(200, result);
|
|
111
|
-
});
|
|
112
|
-
test.after(function () {
|
|
113
|
-
nock.cleanAll();
|
|
114
|
-
});
|
|
115
|
-
test('should post the answers successfully', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
116
|
-
var token, progression;
|
|
117
|
-
return __generator(this, function (_a) {
|
|
118
|
-
switch (_a.label) {
|
|
119
|
-
case 0:
|
|
120
|
-
token = process.env.API_TEST_TOKEN || '';
|
|
121
|
-
return [4 /*yield*/, postAnswer(initProgression, token, answer)];
|
|
122
|
-
case 1:
|
|
123
|
-
progression = _a.sent();
|
|
124
|
-
t.deepEqual(result, progression);
|
|
125
|
-
return [2 /*return*/];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}); });
|
|
129
|
-
test('should reject bad token', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
-
var badToken, error;
|
|
131
|
-
return __generator(this, function (_a) {
|
|
132
|
-
switch (_a.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
badToken = 'token is not a jwt';
|
|
135
|
-
return [4 /*yield*/, t.throwsAsync(function () { return postAnswer(initProgression, badToken, answer); })];
|
|
136
|
-
case 1:
|
|
137
|
-
error = _a.sent();
|
|
138
|
-
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
139
|
-
return [2 /*return*/];
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
}); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import test from 'ava';
|
|
38
|
-
import nock from 'nock';
|
|
39
|
-
import { postProgression } from '../post-progression';
|
|
40
|
-
var skillRef = '_skill-ref';
|
|
41
|
-
var result = {
|
|
42
|
-
_id: '123456123456',
|
|
43
|
-
content: {
|
|
44
|
-
ref: '_skill-ref',
|
|
45
|
-
type: 'skill'
|
|
46
|
-
},
|
|
47
|
-
engine: {
|
|
48
|
-
ref: 'review'
|
|
49
|
-
},
|
|
50
|
-
state: {
|
|
51
|
-
allAnswers: [],
|
|
52
|
-
isCorrect: true,
|
|
53
|
-
nextContent: {
|
|
54
|
-
type: 'slide',
|
|
55
|
-
ref: 'sli_NJ3m5KtWh'
|
|
56
|
-
},
|
|
57
|
-
pendingSlides: [],
|
|
58
|
-
slides: [],
|
|
59
|
-
step: {
|
|
60
|
-
current: 1
|
|
61
|
-
},
|
|
62
|
-
stars: 0
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
test.before(function () {
|
|
66
|
-
var moocApi = nock('http://localhost:3000');
|
|
67
|
-
moocApi
|
|
68
|
-
.post('/api/v2/progressions', {
|
|
69
|
-
content: {
|
|
70
|
-
ref: '_skill-ref',
|
|
71
|
-
type: 'skill'
|
|
72
|
-
},
|
|
73
|
-
engine: {
|
|
74
|
-
ref: 'review',
|
|
75
|
-
version: '1'
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
.reply(200, result);
|
|
79
|
-
});
|
|
80
|
-
test.after(function () {
|
|
81
|
-
nock.cleanAll();
|
|
82
|
-
});
|
|
83
|
-
test('should create progression with success', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
-
var token, progression;
|
|
85
|
-
return __generator(this, function (_a) {
|
|
86
|
-
switch (_a.label) {
|
|
87
|
-
case 0:
|
|
88
|
-
token = process.env.API_TEST_TOKEN || '';
|
|
89
|
-
return [4 /*yield*/, postProgression(skillRef, token)];
|
|
90
|
-
case 1:
|
|
91
|
-
progression = _a.sent();
|
|
92
|
-
t.deepEqual(result, progression);
|
|
93
|
-
return [2 /*return*/];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
}); });
|
|
97
|
-
test('should reject bad token', function (t) { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
-
var badToken, error;
|
|
99
|
-
return __generator(this, function (_a) {
|
|
100
|
-
switch (_a.label) {
|
|
101
|
-
case 0:
|
|
102
|
-
badToken = 'token is not a jwt';
|
|
103
|
-
return [4 /*yield*/, t.throwsAsync(function () { return postProgression(skillRef, badToken); })];
|
|
104
|
-
case 1:
|
|
105
|
-
error = _a.sent();
|
|
106
|
-
t.is(error === null || error === void 0 ? void 0 : error.message, "Invalid token specified: Cannot read properties of undefined (reading 'replace')");
|
|
107
|
-
return [2 /*return*/];
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}); });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|