From d4638ffc15b1c62f7a960499838d42735aeb12c9 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Thu, 24 Nov 2016 22:56:42 +0300 Subject: [PATCH] fix test dont turn single pages into ... --- src/pagination.js | 4 +++- test/pagination.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pagination.js b/src/pagination.js index 5f2d679c58..ba7dbc8436 100644 --- a/src/pagination.js +++ b/src/pagination.js @@ -46,7 +46,9 @@ pagination.create = function (currentPage, pageCount, queryObj) { }); for (i = pages.length - 1; i > 0; --i) { - if (pages[i - 1].page !== pages[i].page - 1) { + if (pages[i].page - 2 === pages[i - 1].page) { + pages.splice(i, 0, {page: pages[i].page - 1, active: false, qs: qs.stringify(queryObj)}); + } else if (pages[i].page - 1 !== pages[i - 1].page) { pages.splice(i, 0, {separator: true}); } } diff --git a/test/pagination.js b/test/pagination.js index 114759b79a..b3c50e57f2 100644 --- a/test/pagination.js +++ b/test/pagination.js @@ -18,8 +18,8 @@ describe('Pagination', function () { it('should create pagination for 10 pages', function (done) { var data = pagination.create(2, 10); - // [1, (2), 3, 4, separator, 9, 10] - assert.equal(data.pages.length, 7); + // [1, (2), 3, 4, 5, separator, 9, 10] + assert.equal(data.pages.length, 8); assert.equal(data.rel.length, 2); assert.equal(data.pageCount, 10); assert.equal(data.prev.page, 1);