From 7266566d540807395c6ec69033acb07cc74491c6 Mon Sep 17 00:00:00 2001 From: Vadim Date: Mon, 13 Sep 2021 21:59:06 +0300 Subject: [PATCH] #69 : Add unit tests --- src/utils/page.test.js | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/utils/page.test.js b/src/utils/page.test.js index 4c451ea..4bdf332 100644 --- a/src/utils/page.test.js +++ b/src/utils/page.test.js @@ -429,3 +429,62 @@ describe('_getPagesCountByParticlesCountInfinite', () => { }) }) }) + +describe('_getPagesCountByParticlesCountLimited', () => { + it('returns result as expected if particlesCountWithoutClones: 5; particlesToScroll: 2 (particlesToShow: 3)', () => { + const testCases = [{ + particlesCountWithoutClones: 5, + particlesToScroll: 2, + expected: 3, + }] + + testCases.forEach(({ + particlesCountWithoutClones, + particlesToScroll, + expected, + }) => { + expect(_getPagesCountByParticlesCountLimited({ + particlesCountWithoutClones, + particlesToScroll, + })).toBe(expected) + }) + }) + + it('returns result as expected if particlesCountWithoutClones: 6; particlesToScroll: 2 (particlesToShow: 2)', () => { + const testCases = [{ + particlesCountWithoutClones: 6, + particlesToScroll: 2, + expected: 3, + }] + + testCases.forEach(({ + particlesCountWithoutClones, + particlesToScroll, + expected, + }) => { + expect(_getPagesCountByParticlesCountLimited({ + particlesCountWithoutClones, + particlesToScroll, + })).toBe(expected) + }) + }) + + it('returns result as expected if particlesCountWithoutClones: 5; particlesToScroll: 3 (particlesToShow: 2)', () => { + const testCases = [{ + particlesCountWithoutClones: 5, + particlesToScroll: 3, + expected: 2, + }] + + testCases.forEach(({ + particlesCountWithoutClones, + particlesToScroll, + expected, + }) => { + expect(_getPagesCountByParticlesCountLimited({ + particlesCountWithoutClones, + particlesToScroll, + })).toBe(expected) + }) + }) +})