"use strict";

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

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

describe('modal action creators', function () {
  describe('withConfirm', function () {
    it('returns sane default options', function () {
      var cb = function cb() {};

      var opts = {
        text: 'Are you sure?'
      };
      var withConfirmAction = (0, _modal.withConfirm)(cb, opts);
      expect(withConfirmAction.payload.options.confirmation).to.be.equal(true);
      expect(withConfirmAction.payload.options.onContinue).to.be.equal(cb);
      expect(withConfirmAction.payload.options.text).to.be.equal('Are you sure?');
      expect(withConfirmAction.payload.options.title).to.be.undefined();
      expect(withConfirmAction.payload.options.onCancel).to.be.undefined();
      expect(withConfirmAction.payload.options.continueText).to.be.undefined();
      expect(withConfirmAction.payload.options.cancelText).to.be.undefined();
    });
    it('overrides default options', function () {
      var cb = function cb() {};

      var opts = {
        text: 'This overrides the default',
        onCancel: cb
      };
      var withConfirmAction = (0, _modal.withConfirm)(cb, opts);
      expect(withConfirmAction.payload.options.confirmation).to.be.equal(true);
      expect(withConfirmAction.payload.options.text).to.be.equal('This overrides the default');
      expect(withConfirmAction.payload.options.onCancel).to.be.equal(cb);
    });
    it('returns a properly typed action', function () {
      var cb = function cb() {};

      var withConfirmAction = (0, _modal.withConfirm)(cb, {});
      expect(withConfirmAction.type).to.be.equal(_constants.OPEN_MODAL);
    });
  });
  describe('openDeleteStimulusModal', function () {
    it('returns a properly types action', function () {
      var openDeleteStimulusModalAction = (0, _modal.openDeleteStimulusModal)({
        x: 1
      });
      expect(openDeleteStimulusModalAction.type).to.be.equal(_constants.OPEN_DELETE_STIMULUS_MODAL);
      expect(openDeleteStimulusModalAction.payload.entry).to.be.eql({
        x: 1
      });
    });
  });
  describe('openAddContentModal', function () {
    it('returns a properly types action', function () {
      var openAddContentModalAction = (0, _modal.openAddContentModal)({
        allowStimulusCreation: true,
        parentEntryId: 'parent123',
        position: 56,
        quizId: 'quiz123',
        stimulusId: 'stimulus123'
      });
      expect(openAddContentModalAction.type).to.be.equal(_constants.OPEN_ADD_CONTENT_MODAL);
      expect(openAddContentModalAction.payload).to.be.eql({
        allowStimulusCreation: true,
        parentEntryId: 'parent123',
        position: 56,
        quizId: 'quiz123',
        stimulusId: 'stimulus123'
      });
    });
  });
  describe('closeModal', function () {
    it('returns a properly typed action', function () {
      var closeModalAction = (0, _modal.closeModal)();
      expect(closeModalAction.type).to.be.equal(_constants.CLOSE_MODAL);
    });
  });
  describe('openModal', function () {
    it('returns a properly typed action', function () {
      var openModalAction = (0, _modal.openModal)();
      expect(openModalAction.type).to.be.equal(_constants.OPEN_MODAL);
    });
  });
});