"use strict";

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

var _immutable = require("immutable");

var _scrolling = _interopRequireDefault(require("../scrolling"));

var _scrolling2 = require("../../actions/scrolling");

describe('scrolling reducer', function () {
  it('returns the original state with bad action', function () {
    var initialState = (0, _immutable.Map)({
      isOpen: false
    });
    var action = (0, _immutable.Map)({
      type: 'something else'
    });
    var nextState = (0, _scrolling.default)(initialState, action);
    expect(nextState).to.equal(initialState);
  });
  it('handles SCROLL_TO_COMPONENT without scrollingFocus', function () {
    var initialState = (0, _immutable.Map)({
      scrolledComponentKey: '3'
    });
    var action = (0, _scrolling2.scrollToItem)('5');
    var nextState = (0, _scrolling.default)(initialState, action);
    expect(nextState.get('scrolledComponentKey')).to.equal('5');
    expect(nextState.get('scrollingFocus')).to.equal(true);
  });
  it('handles SCROLL_TO_COMPONENT with scrollingFocus false', function () {
    var initialState = (0, _immutable.Map)({
      scrolledComponentKey: '3'
    });
    var action = (0, _scrolling2.scrollToItem)('5', false);
    var nextState = (0, _scrolling.default)(initialState, action);
    expect(nextState.get('scrolledComponentKey')).to.equal('5');
    expect(nextState.get('scrollingFocus')).to.equal(false);
  });
  it('handles CLEAR_SCROLLED_COMPONENT', function () {
    var initialState = (0, _immutable.Map)({
      scrolledComponentKey: '3'
    });
    var action = (0, _scrolling2.clearsScrolledComponentKey)();
    var nextState = (0, _scrolling.default)(initialState, action);
    expect(nextState.get('scrolledComponentKey')).to.equal(null);
    expect(nextState.get('scrollingFocus')).to.equal(null);
  });
});