From a203637456408c6a19c0ea82516243f57d2c6e22 Mon Sep 17 00:00:00 2001 From: Vadim Date: Mon, 13 Sep 2021 21:54:07 +0300 Subject: [PATCH] #69 : Add unit tests --- src/utils/page.js | 2 +- src/utils/page.test.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/page.js b/src/utils/page.js index f66051f..d0e0a98 100644 --- a/src/utils/page.js +++ b/src/utils/page.js @@ -157,7 +157,7 @@ export function getPartialPageSize({ while(true) { const diff = particlesCountWithoutClones - particlesCount - overlap if (diff < particlesToShow) { - return diff + return Math.max(diff, 0) // show: 2; scroll: 3, n: 5 => -1 } particlesCount += particlesToShow + overlap } diff --git a/src/utils/page.test.js b/src/utils/page.test.js index 6fad144..4c451ea 100644 --- a/src/utils/page.test.js +++ b/src/utils/page.test.js @@ -40,6 +40,11 @@ describe('getPartialPageSize', () => { particlesToShow: 2, particlesToScroll: 2, expected: 0, + }, { + particlesCountWithoutClones: 5, + particlesToShow: 2, + particlesToScroll: 3, + expected: 0, }] testCases.forEach(({