"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _LearnosityCalculator = _interopRequireDefault(require("../../../../LearnosityCalculator"));

var _index = _interopRequireDefault(require("../index"));

var _withContext = _interopRequireDefault(require("../../../../../../../tests/util/withContext"));

var _reduxStore = require("../../../../../../reduxStore");

var _immutable = require("immutable");

describe('Calculator', function () {
  var calculatorType = 'basic';
  var activeQuizId = '42';
  var quizSessionId = 24;
  var activeCalculatorId = 'abc';
  var state = {
    quizzes: (0, _defineProperty2.default)({
      activeQuizId: activeQuizId
    }, activeQuizId, {
      id: activeQuizId,
      calculatorType: calculatorType
    }),
    quizSessions: {
      activeQuizSessionId: quizSessionId
    },
    ui: {
      activeCalculatorId: activeCalculatorId
    }
  };
  var testbed = createTestbed((0, _withContext.default)(_index.default, state));
  beforeEach(function () {
    (0, _reduxStore.setFakeStore)((0, _immutable.fromJS)(state));
  });
  afterEach(function () {
    (0, _reduxStore.unsetFakeStore)();
  });
  it('correctly maps props from state',
  /*#__PURE__*/
  (0, _asyncToGenerator2.default)(
  /*#__PURE__*/
  _regenerator.default.mark(function _callee() {
    var learnosityCalculator;
    return _regenerator.default.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            testbed.render();
            learnosityCalculator = testbed.findChildByType(_LearnosityCalculator.default);
            expect(learnosityCalculator.props).to.contain({
              activeCalculatorId: activeCalculatorId,
              calculatorType: calculatorType,
              quizSessionId: quizSessionId
            });

          case 3:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  })));
});