From 89b32eda32e7e4ef4433aa907c1adbcf15e9f878 Mon Sep 17 00:00:00 2001 From: Vadim Date: Sun, 12 Sep 2021 17:24:08 +0300 Subject: [PATCH] #69 : Remove unnecessary tests --- src/utils/page.test.js | 150 ++--------------------------------------- 1 file changed, 4 insertions(+), 146 deletions(-) diff --git a/src/utils/page.test.js b/src/utils/page.test.js index 49ff92e..ce4b134 100644 --- a/src/utils/page.test.js +++ b/src/utils/page.test.js @@ -1,153 +1,11 @@ import { - getNextParticleIndexLimited, - getNextParticleIndexInfinte, - getPrevParticleIndexLimited, - getPrevParticleIndexInfinte, getPartialPageSize, + // getCurrentPageIndex, + // getPagesCountByParticlesCount, + // getParticleIndexByPageIndexInfinite, + // getParticleIndexByPageIndexLimited, } from './page.js' -describe('getNextParticleIndexLimited', () => { - it('returns next page index as expected', () => { - const testCases = [ - { currentParticleIndex: -5, particlesCount: 7, particlesToScroll: 2, particlesToShow: 2, expected: 0 }, - { currentParticleIndex: 0, particlesCount: 7, particlesToScroll: 2, particlesToShow: 2, expected: 2 }, - { currentParticleIndex: 2, particlesCount: 7, particlesToScroll: 2, particlesToShow: 2, expected: 4 }, - { currentParticleIndex: 7, particlesCount: 7, particlesToScroll: 2, particlesToShow: 2, expected: 5 }, - ] - testCases.forEach(({ - currentParticleIndex, - particlesCount, - particlesToScroll, - particlesToShow, - expected, - }) => { - expect(getNextParticleIndexLimited({ - currentParticleIndex, - particlesCount, - particlesToScroll, - particlesToShow, - })).toBe(expected) - }) - }) - it('throws error if particlesCount is less than 1', () => { - const currentParticleIndex = 5 - const particlesCount = 0 - const particlesToScroll = 1 - expect( - () => getNextParticleIndexLimited({ - currentParticleIndex, - particlesCount, - particlesToScroll, - }) - ).toThrowError('particlesCount must be at least 1') - }) -}) - -describe('getNextParticleIndexInfinte', () => { - it('returns next page index as expected', () => { - const testCases = [ - { currentParticleIndex: -5, particlesCount: 7, particlesToScroll: 2, clonesCountTail: 3, expected: 2 }, - { currentParticleIndex: 0, particlesCount: 7, particlesToScroll: 2, clonesCountTail: 3, expected: 2 }, - { currentParticleIndex: 2, particlesCount: 7, particlesToScroll: 2, clonesCountTail: 3, expected: 4 }, - { currentParticleIndex: 7, particlesCount: 7, particlesToScroll: 2, clonesCountTail: 3, expected: 4 }, - ] - testCases.forEach(({ - currentParticleIndex, - particlesCount, - particlesToScroll, - clonesCountTail, - expected, - }) => { - expect(getNextParticleIndexInfinte({ - currentParticleIndex, - particlesCount, - particlesToScroll, - clonesCountTail, - })).toBe(expected) - }) - }) - it('throws error if particlesCount is less than 1', () => { - const currentParticleIndex = 5 - const particlesCount = 0 - expect( - () => getNextParticleIndexInfinte({ - currentParticleIndex, - particlesCount, - }) - ).toThrowError('particlesCount must be at least 1') - }) -}) - -describe('getPrevParticleIndexLimited', () => { - it('returns prev page index as expected', () => { - const testCases = [ - { currentParticleIndex: -5, particlesCount: 7, particlesToScroll: 2, expected: 0 }, - { currentParticleIndex: 0, particlesCount: 7, particlesToScroll: 2, expected: 0 }, - { currentParticleIndex: 2, particlesCount: 7, particlesToScroll: 2, expected: 0 }, - { currentParticleIndex: 4, particlesCount: 7, particlesToScroll: 2, expected: 2 }, - { currentParticleIndex: 10, particlesCount: 7, particlesToScroll: 2, expected: 6 }, - ] - testCases.forEach(({ - currentParticleIndex, - particlesCount, - particlesToScroll, - expected, - }) => { - expect(getPrevParticleIndexLimited({ - currentParticleIndex, - particlesCount, - particlesToScroll, - })).toBe(expected) - }) - }) - it('throws error if particlesCount is less than 1', () => { - const currentParticleIndex = 5 - const particlesCount = 0 - expect( - () => getPrevParticleIndexLimited({ - currentParticleIndex, - particlesCount, - }) - ).toThrowError('particlesCount must be at least 1') - }) -}) - -describe('getPrevParticleIndexInfinte', () => { - it('returns prev page index as expected', () => { - const testCases = [ - { currentParticleIndex: -5, particlesCount: 7, particlesToScroll: 2, expected: 0 }, - { currentParticleIndex: 2, particlesCount: 7, particlesToScroll: 2, expected: 0 }, - { currentParticleIndex: 2, particlesCount: 7, particlesToScroll: 2, expected: 0 }, - { currentParticleIndex: 10, particlesCount: 7, particlesToScroll: 2, expected: 4 }, - ] - testCases.forEach(({ - currentParticleIndex, - particlesCount, - particlesToScroll, - expected, - }) => { - expect(getPrevParticleIndexInfinte({ - currentParticleIndex, - particlesCount, - particlesToScroll, - })).toBe(expected) - }) - }) - it('throws error if particlesCount is less than 1', () => { - const currentParticleIndex = 2 - const particlesCount = 0 - const particlesToScroll = 2 - - expect( - () => getPrevParticleIndexInfinte({ - currentParticleIndex, - particlesCount, - particlesToScroll, - }) - ).toThrowError('particlesCount must be at least 1') - }) -}) - describe('getPartialPageSize', () => { it('returns result as expected if particlesToShow <= particlesToScroll', () => { const testCases = [{