UNPKG

@age/quantum

Version:
73 lines (70 loc) 2.88 kB
"use strict"; var _pagination = _interopRequireDefault(require("./pagination")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } describe('Pagination', function () { describe('How pages are displayed', function () { describe('Without params', function () { it('should return [1] when pagination is called without arguments', function () { expect((0, _pagination.default)()).toEqual([1]); }); }); describe('When totalPages are', function () { describe('Less or equal 5 pages', function () { it('should return [1] when totalPages is 1', function () { expect((0, _pagination.default)({ totalPages: 1 })).toEqual([1]); }); it('should return [1, 2, 3, 4 ,5] when totalPages is 5', function () { expect((0, _pagination.default)({ totalPages: 5 })).toEqual([1, 2, 3, 4, 5]); }); }); describe('More than 5 pages', function () { it('should return [1, 2, 3, 4, 5, 6] when totalPages is 6', function () { expect((0, _pagination.default)({ totalPages: 6 })).toEqual([1, 2, 3, 4, 5, 6]); }); it('should return [1, 2, 3, 4, "...", 7] when totalPages is 7', function () { expect((0, _pagination.default)({ totalPages: 7 })).toEqual([1, 2, 3, 4, '...', 7]); }); }); }); describe('With activePage', function () { it('should return [1, "...", 49, 50, 51, "...", 100] when activePage are 50 and totalPages are 100', function () { expect((0, _pagination.default)({ totalPages: 100, activePage: 50 })).toEqual([1, '...', 49, 50, 51, '...', 100]); }); it('should return [1, "...", 96, 97, 98, 99, 100] when activePage is 97 and totalPages are 100', function () { expect((0, _pagination.default)({ totalPages: 100, activePage: 97 })).toEqual([1, '...', 96, 97, 98, 99, 100]); }); it('should return [1, "...", 97, 98, 99, 100] when activePage is 98 and totalPages are 100', function () { expect((0, _pagination.default)({ totalPages: 100, activePage: 98 })).toEqual([1, '...', 97, 98, 99, 100]); }); it('should return [1, "...", 97, 98, 99, 100] when activePage is 99 and totalPages are 100', function () { expect((0, _pagination.default)({ totalPages: 100, activePage: 99 })).toEqual([1, '...', 97, 98, 99, 100]); }); it('should return [1, "...", 97, 98, 99, 100] when activePage is 100 and totalPages are 100', function () { expect((0, _pagination.default)({ totalPages: 100, activePage: 100 })).toEqual([1, '...', 97, 98, 99, 100]); }); }); }); });