"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

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

var _immutable = require("immutable");

var _constants = require("@instructure/quiz-common/lib/constants");

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

var _ImportModal = require("../../../../common/components/ImportModal");

var calls = function calls() {
  var _fromJS;

  var call1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'success';
  var call2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'success';
  var call3 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'success';
  return (0, _immutable.fromJS)((_fromJS = {}, (0, _defineProperty2.default)(_fromJS, _constants.CREATE_QTI_IMPORT, {
    requestStatus: call1
  }), (0, _defineProperty2.default)(_fromJS, _constants.FILE_UPLOAD_URL_CALL, {
    requestStatus: call2
  }), (0, _defineProperty2.default)(_fromJS, _constants.FILE_UPLOAD_CALL, {
    requestStatus: call3
  }), _fromJS));
};

var callsToCheck = [_constants.CREATE_QTI_IMPORT, _constants.FILE_UPLOAD_CALL, _constants.FILE_UPLOAD_URL_CALL];

var qtiRecordStub = function qtiRecordStub(pvNum) {
  return {
    progressNumber: function progressNumber() {
      return pvNum;
    },
    message: 'hi'
  };
};

describe('QTIImportModal', function () {
  describe('.mapStateToProps', function () {
    it('returns the expected props', function () {
      var props = (0, _index.mapStateToProps)({
        get: function get() {
          return (0, _immutable.Map)();
        }
      }, {
        qtiImport: qtiRecordStub(0)
      });
      expect(props).to.deep.equal({
        acceptFileType: '.zip',
        failureMessage: 'hi',
        importMessage: 'QTI 1.2 and 2.x (.zip) files only',
        importModalId: 'qtiImport',
        progressValue: (0, _ImportModal.progressValue)(qtiRecordStub(0).progressNumber(), calls(false, false, false), callsToCheck)
      });
    });
  });
  describe('.mapDispatchToProps', function () {
    it('returns the correct props', function () {
      var dispatch = sinon.stub();
      var mdtp = (0, _index.mapDispatchToProps)(dispatch, {
        parentId: 1,
        parentType: 'Bank'
      });
      expect(mdtp.fileUpload).to.be.a('function');
      expect(mdtp.onContinue).to.be.a('function');
    });
  });
  describe('QTIImportModal Rendering', function () {
    var testbed = createTestbed(withContext(_index.default), {
      qtiImport: qtiRecordStub(0)
    });
    shouldRenderComponent(testbed, {}, _index.default);
  });
});