UNPKG

@coorpacademy/progression-engine

Version:

52 lines (51 loc) 2.69 kB
"use strict"; var _set2 = _interopRequireDefault(require("lodash/fp/set")); var _pipe2 = _interopRequireDefault(require("lodash/fp/pipe")); var _ava = _interopRequireDefault(require("ava")); var _config = require("../../config"); var _stars = _interopRequireDefault(require("../stars")); var _actions = require("./fixtures/actions"); var _engines = require("./fixtures/engines"); var _states = require("./fixtures/states"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const config = (0, _config.getConfig)(_engines.microlearning); (0, _ava.default)('should return updated stars when action type is answer with isCorrect true', t => { const action = (0, _set2.default)('payload.isCorrect', true, _actions.answerAction); const result = (0, _stars.default)(config)(0, action, _states.stateForSecondSlide); t.is(result, 4); }); (0, _ava.default)('should not change stars when action has instructions and its type is answer with isCorrect true', t => { const action = (0, _pipe2.default)((0, _set2.default)('payload.isCorrect', true), (0, _set2.default)('payload.instructions', [{ value: 1, type: 'add', field: 'A' }]))(_actions.answerAction); const result = (0, _stars.default)(config)(0, action, _states.stateForSecondSlide); t.is(result, 0); }); (0, _ava.default)('should not update stars when action type is answer with isCorrect false', t => { const result = (0, _stars.default)(config)(0, _actions.answerAction, _states.stateForSecondSlide); t.is(result, 0); }); (0, _ava.default)('should return updated stars when action type is clue and slide is not in state', t => { const result = (0, _stars.default)(config)(5, _actions.askClueAction, _states.stateForSecondSlide); t.is(result, 4); }); (0, _ava.default)('should not update stars when action type is clue and slide is already in state', t => { const state = (0, _set2.default)('requestedClues', '1.A1.2', _states.stateForSecondSlide); const result = (0, _stars.default)(config)(5, _actions.askClueAction, state); t.is(result, 5); }); (0, _ava.default)('should return updated stars when action type is resource and content ref is not in state', t => { const result = (0, _stars.default)(config)(5, _actions.resourceAction, _states.stateForSecondSlide); t.is(result, 9); }); (0, _ava.default)('should not update stars when action type is resource and slide is already in state', t => { const state = (0, _set2.default)('viewedResources', [{ ref: '1.A1', type: 'chapter' }], _states.stateForSecondSlide); const result = (0, _stars.default)(config)(5, _actions.resourceAction, state); t.is(result, 5); }); //# sourceMappingURL=stars.js.map