"use strict";

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

var _immutable = require("immutable");

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

var _qtiImports = _interopRequireDefault(require("../qtiImports"));

describe('qtiImports reducer', function () {
  describe('adding imports', function () {
    it('adds imports to the store indexed by id', function () {
      var firstImport = {
        id: 1,
        status: 'completed',
        parentId: '1'
      };
      var secondImport = {
        id: 9,
        status: 'started',
        parentId: '1'
      };
      var qtiImports = [firstImport, secondImport];
      var action = {
        type: _constants.ADD_QTI_IMPORTS,
        payload: qtiImports
      };
      var nextState = (0, _qtiImports.default)((0, _immutable.Map)(), action);
      var expectedNextState = (0, _immutable.fromJS)({
        1: firstImport,
        9: secondImport
      });
      expect((0, _immutable.is)(nextState, expectedNextState)).to.be.true();
    });
  });
  describe('clearing imports', function () {
    it('clears all imports', function () {
      var firstImport = {
        id: 1,
        status: 'completed',
        parentId: '1'
      };
      var secondImport = {
        id: 9,
        status: 'started',
        parentId: '1'
      };
      var initialState = {
        1: firstImport,
        2: secondImport
      };
      var action = {
        type: _constants.CLEAR_QTI_IMPORTS
      };
      var nextState = (0, _qtiImports.default)(initialState, action);
      var expectedNextState = (0, _immutable.fromJS)({});
      expect(nextState).to.deep.eq(expectedNextState);
    });
  });
});