"use strict";

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

var _immutable = require("immutable");

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

var _modal = _interopRequireDefault(require("../modal"));

describe('modal reducer', function () {
  describe('OPEN_ADD_CONTENT_MODAL', function () {
    it('sets isOpen to ADD_CONTENT_MODAL', function () {
      var initialState = (0, _immutable.Map)({
        isOpen: false
      });
      var nextState = (0, _modal.default)(initialState, {
        type: _constants.OPEN_ADD_CONTENT_MODAL,
        payload: {
          x: 1
        }
      });
      expect(nextState.get('isOpen')).to.eql(_constants.ADD_CONTENT_MODAL);
      expect(nextState.get(_constants.OPEN_ADD_CONTENT_MODAL_DATA)).to.eql((0, _immutable.Map)({
        x: 1
      }));
    });
  });
  describe('OPEN_DELETE_STIMULUS_MODAL', function () {
    it('sets isOpen to DELETE_STIMULUS_MODAL', function () {
      var initialState = (0, _immutable.Map)({
        isOpen: false
      });
      var nextState = (0, _modal.default)(initialState, {
        type: _constants.OPEN_DELETE_STIMULUS_MODAL
      });
      expect(nextState.get('isOpen')).to.eql(_constants.DELETE_STIMULUS_MODAL);
    });
  });
  describe('OPEN_MODAL', function () {
    var title = 'Title';
    var options = {
      example: 'options'
    };
    var exampleOpenAction = {
      type: _constants.OPEN_MODAL,
      payload: {
        options: options,
        title: title
      }
    };
    it('sets isOpen to true', function () {
      var initialState = (0, _immutable.Map)({
        isOpen: false
      });
      var nextState = (0, _modal.default)(initialState, exampleOpenAction);
      expect(nextState.get('isOpen')).to.eql(title);
    });
    it('sets the options to the payload options', function () {
      var initialState = (0, _immutable.Map)({
        isOpen: false
      });
      var nextState = (0, _modal.default)(initialState, exampleOpenAction);
      expect(nextState.get('options')).to.be.eql((0, _immutable.fromJS)(options));
    });
  });
  describe('CLOSE_MODAL', function () {
    var exampleCloseAction = {
      type: _constants.CLOSE_MODAL
    };
    it('sets isOpen to false', function () {
      var initialState = (0, _immutable.Map)({
        isOpen: true
      });
      var nextState = (0, _modal.default)(initialState, exampleCloseAction);
      expect(nextState.get('isOpen')).to.be.false();
    });
  });
});