"use strict";

var _immutable = require("immutable");

var _index = require("../index");

describe('connected PaginatedCollection', function () {
  var fakeState = (0, _immutable.fromJS)({
    ui: {
      COMPONENT_KEY: {
        total: 2,
        current: 1,
        contents: {
          1: [1, 2, 3]
        }
      }
    }
  });
  var fakeProps = {
    stateKey: 'COMPONENT_KEY'
  };
  describe('mapStateToProps', function () {
    it('maps stateKey to pagination data', function () {
      var props = (0, _index.mapStateToProps)(fakeState, fakeProps);
      expect(props.totalPages).to.eq(2);
      expect(props.currentPage).to.eq(1);
      expect(props.contents.toJS()).to.eql({
        1: [1, 2, 3]
      });
    });
    it('has reasonable defaults when pagination data is not present', function () {
      var props = (0, _index.mapStateToProps)(fakeState, 'ANOTHER_KEY');
      expect(props.totalPages).to.eq(0);
      expect(props.currentPage).to.eq(1);
      expect(props.contents.toJS()).to.eql({});
    });
  });
});