"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _enzyme = require("enzyme");

var _Pagination = require("@instructure/ui-pagination/lib/components/Pagination");

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

describe('Paginator', function () {
  var sandbox = sinon.createSandbox();
  var props = {
    currentPage: 2,
    onPageChange: sandbox.spy(),
    totalPages: 4
  };
  var wrapper;
  beforeEach(function () {
    wrapper = (0, _enzyme.shallow)(_react.default.createElement(_index.default, props, "PAGE"), {
      disableLifecycleMethods: true
    });
  });
  afterEach(function () {
    sandbox.resetHistory();
  });
  it('renders children', function () {
    expect(wrapper.text()).to.include('PAGE');
  });
  it('renders pagination controls', function () {
    var buttons = wrapper.find(_Pagination.PaginationButton);
    expect(buttons.map(function (button) {
      return button.children().text();
    })).to.deep.equal(['1', '2', '3', '4']);
  });
  it('highlights the current page', function () {
    var selected = wrapper.find(_Pagination.PaginationButton).find({
      current: true
    });
    expect(selected.children().text()).to.equal('2');
  });
  it('calls onPageChange when a pagination control is clicked', function () {
    wrapper.find(_Pagination.PaginationButton).at(3).simulate('click');
    expect(props.onPageChange).to.have.been.calledWith(4);
  });
});