#69 : Remove unnecessary tests

This commit is contained in:
Vadim
2021-09-12 17:24:08 +03:00
parent a18f1d64d5
commit 89b32eda32

View File

@@ -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 = [{