"use strict";

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

var _immutable = require("immutable");

var _chai = require("chai");

var _calls = _interopRequireDefault(require("../calls"));

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

describe('calls reducer', function () {
  var nextStateEquals = function nextStateEquals(nextState, stateExpectations) {
    (0, _chai.expect)((0, _immutable.fromJS)(nextState).equals((0, _immutable.fromJS)(stateExpectations))).to.be.true();
  };

  describe('call status', function () {
    it('should be able to set callStatus on an empty call', function () {
      var initialState = (0, _immutable.fromJS)({});
      var action = {
        type: _constants.CALL_STATUS,
        payload: {
          call: 'quizSaveCall',
          status: 'calling'
        }
      };
      nextStateEquals((0, _calls.default)(initialState, action), {
        quizSaveCall: {
          requestStatus: 'calling'
        }
      });
    });
    it('should be able to set callStatus on an call with a value', function () {
      var initialState = (0, _immutable.fromJS)({
        quizSaveCall: {
          requestStatus: 'calling'
        }
      });
      var action = {
        type: _constants.CALL_STATUS,
        payload: {
          call: 'quizSaveCall',
          status: 'success'
        }
      };
      nextStateEquals((0, _calls.default)(initialState, action), {
        quizSaveCall: {
          requestStatus: 'success'
        }
      });
    });
  });
  describe('callback status', function () {
    it('sets callback status properly', function () {
      var initialState = (0, _immutable.fromJS)({});
      var action = {
        type: _constants.SET_CALLBACKS_STATUS,
        payload: {
          call: 'quizSaveCall',
          status: 'completed'
        }
      };
      nextStateEquals((0, _calls.default)(initialState, action), {
        quizSaveCall: {
          callbackStatus: 'completed'
        }
      });
    });
  });
});