"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _immutable = require("immutable");

var _ui = _interopRequireDefault(require("../ui"));

var actions = _interopRequireWildcard(require("../../actions/ui"));

describe('ui reducer', function () {
  describe('toggle', function () {
    it('adds new keys', function () {
      var initialState = (0, _immutable.Map)();
      var action = actions.toggle('my_key');
      var nextState = (0, _ui.default)(initialState, action);
      expect(nextState.get('my_key')).to.eq(true);
    });
    it('updates existing keys', function () {
      var initialState = (0, _immutable.Map)({
        my_key: true
      });
      var action = actions.toggle('my_key');
      var nextState = (0, _ui.default)(initialState, action);
      expect(nextState.get('my_key')).to.eq(false);
    });
  });
  describe('set', function () {
    it('sets value', function () {
      var initialState = (0, _immutable.Map)({
        my_key: 'some_value'
      });
      var action = actions.set('my_key', 'a_different_value');
      var nextState = (0, _ui.default)(initialState, action);
      expect(nextState.get('my_key')).to.eq('a_different_value');
    });
  });
  describe('merge', function () {
    it('adds new keys', function () {
      var initialState = (0, _immutable.Map)();
      var action = actions.merge('my_key', {
        my: {
          nested: 'object'
        }
      });
      var nextState = (0, _ui.default)(initialState, action);
      expect(nextState.get('my_key').toJS()).to.eql({
        my: {
          nested: 'object'
        }
      });
    });
    it('merges with existing keys', function () {
      var initialState = (0, _immutable.Map)({
        my_key: (0, _immutable.Map)({
          my: (0, _immutable.Map)({
            nested: 'object'
          })
        })
      });
      var action = actions.merge('my_key', {
        my: {
          sibling: 'object'
        }
      });
      var nextState = (0, _ui.default)(initialState, action);
      expect(nextState.get('my_key').toJS()).to.eql({
        my: {
          nested: 'object',
          sibling: 'object'
        }
      });
    });
  });
  describe('occludeQuizEntries', function () {
    it('should add quizEntriesOccluded to state', function () {
      var initialState = (0, _immutable.Map)();
      var action = actions.occludeQuizEntries(true);
      var nextState = (0, _ui.default)(initialState, action);
      var occluded = nextState.get('quizEntriesOccluded');
      expect(occluded).to.equal(true);
    });
  });
  it('handles ACTIVE_BANK_ENTRY_CHANGE', function () {
    var initialState = (0, _immutable.Map)({
      activeBankEntryId: '900'
    });
    var action = actions.newActiveBankEntry('1900');
    var nextState = (0, _ui.default)(initialState, action);
    expect(nextState.get('activeBankEntryId')).to.equal('1900');
  });
  it('handles ACTIVE_BANK_CHANGE', function () {
    var initialState = (0, _immutable.Map)({
      activeBankId: '800'
    });
    var action = actions.newActiveBank('1200');
    var nextState = (0, _ui.default)(initialState, action);
    expect(nextState.get('activeBankId')).to.equal('1200');
  });
});