'use strict';

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _reactTestRenderer = require('react-test-renderer');

var _reactTestRenderer2 = _interopRequireDefault(_reactTestRenderer);

var _Pagination = require('./Pagination.component');

var _Pagination2 = _interopRequireDefault(_Pagination);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

jest.mock('react-dom');

describe('Pagination', function () {
	it('should render', function () {
		// given
		var props = {
			startIndex: 6,
			totalResults: 17,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should render id if provided', function () {
		// given
		var props = {
			id: 'toolbar-pagination',
			startIndex: 6,
			totalResults: 17,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should not render navigation when show all items', function () {
		// given
		var props = {
			totalResults: 17,
			itemsPerPage: -1,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should render menu item with "All" title when size is -1', function () {
		// given
		var props = {
			itemsPerPage: -1,
			itemsPerPageOptions: [5, 10, 20, -1],
			totalResults: 17,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should disable first and previous buttons for first page', function () {
		// given
		var props = {
			startIndex: 1,
			totalResults: 6,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should disable next and last buttons for last page', function () {
		// given
		var props = {
			startIndex: 6,
			totalResults: 10,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should not show navigation when there is only one page', function () {
		// given
		var props = {
			startIndex: 1,
			totalResults: 5,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});

	it('should not show navigation when there is no items', function () {
		// given
		var props = {
			startItems: 1,
			totalResults: 0,
			onChange: jest.fn()
		};
		// when
		var wrapper = _reactTestRenderer2.default.create(_react2.default.createElement(_Pagination2.default, props)).toJSON();
		// then
		expect(wrapper).toMatchSnapshot();
	});
});