UNPKG

@coorpacademy/progression-engine

Version:

59 lines (58 loc) 2.8 kB
"use strict"; var _set2 = _interopRequireDefault(require("lodash/fp/set")); var _ava = _interopRequireDefault(require("ava")); var _config = require("../../config"); var _lives = _interopRequireDefault(require("../lives")); 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.learner); (0, _ava.default)('should return config lives when livesDisabled is true on state', t => { const state = (0, _set2.default)('livesDisabled', true, _states.stateForSecondSlide); const result = (0, _lives.default)(config)(3, _actions.answerAction, state); t.is(result, 3); }); (0, _ava.default)('should return updated lives when action type is answer with isCorrect false', t => { const result = (0, _lives.default)(config)(3, _actions.answerAction, _states.stateForSecondSlide); t.is(result, 2); }); (0, _ava.default)('should not change lives when action has instructions and its type is answer with isCorrect false', t => { const action = (0, _set2.default)('payload.instructions', [{ value: 1, type: 'add', field: 'A' }], _actions.answerAction); const result = (0, _lives.default)(config)(3, action, _states.stateForSecondSlide); t.is(result, 3); }); (0, _ava.default)('should not modify lives when action type is answer with isCorrect true', t => { const action = (0, _set2.default)('payload.isCorrect', true, _actions.answerAction); const result = (0, _lives.default)(config)(1, action, _states.stateForSecondSlide); t.is(result, 1); }); (0, _ava.default)('should update lives when action type is extraLifeAccepted', t => { const result = (0, _lives.default)(config)(0, _actions.extraLifeAcceptedAction, _states.stateForSecondSlide); t.is(result, 1); }); (0, _ava.default)('should not change lives when action has instructions and its type is extraLifeAccepted', t => { const action = (0, _set2.default)('payload.instructions', [{ value: 1, type: 'add', field: 'A' }], _actions.extraLifeAcceptedAction); const result = (0, _lives.default)(config)(0, action, _states.stateForSecondSlide); t.is(result, 0); }); (0, _ava.default)('should not modify lives for any other type of action', t => { const result = (0, _lives.default)(config)(5, _actions.askClueAction, _states.stateForSecondSlide); t.is(result, 5); }); (0, _ava.default)('should not increment lives counter if there are no more remainingLifeRequests', t => { const result = (0, _lives.default)(config)(0, _actions.extraLifeAcceptedAction, { ..._states.stateForSecondSlide, remainingLifeRequests: 0 }); t.is(result, 0); }); //# sourceMappingURL=lives.js.map