"use strict";

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

var _immutable = require("immutable");

var _chai = require("chai");

var _InteractionType = _interopRequireDefault(require("quiz-interactions/lib/records/InteractionType"));

var _interactionTypes = _interopRequireDefault(require("../interactionTypes"));

var _addInteractionTypes = require("../../actions/addInteractionTypes");

describe('interaction types reducer', function () {
  it('should add new types with ADD_INTERACTION_TYPES action', function () {
    var initialState = (0, _immutable.fromJS)({});
    var action = (0, _addInteractionTypes.addInteractionTypes)([{
      id: 1,
      slug: 'qi'
    }]);
    var nextState = (0, _interactionTypes.default)(initialState, action);
    var nextItem = nextState.get('1').get('slug');
    (0, _chai.expect)(nextItem).to.equal('qi');
  });
  it('should replace types with ADD_INTERACTION_TYPES action', function () {
    var initialState = (0, _immutable.fromJS)({
      1: new _InteractionType.default({
        id: 1,
        slug: 'initial'
      })
    });
    var action = (0, _addInteractionTypes.addInteractionTypes)([{
      id: 1,
      slug: 'nextOne'
    }, {
      id: 2,
      slug: 'nextTwo'
    }]);
    var nextState = (0, _interactionTypes.default)(initialState, action);
    var nextItemOne = nextState.get('1').get('slug');
    (0, _chai.expect)(nextItemOne).to.equal('nextOne');
    var nextItemTwo = nextState.get('2').get('slug');
    (0, _chai.expect)(nextItemTwo).to.equal('nextTwo');
  });
});