#69 : Add unit tests

This commit is contained in:
Vadim
2021-09-13 21:31:32 +03:00
parent c21f7fe111
commit c121f91693

View File

@@ -1,5 +1,4 @@
import { import {
getPartialPageSize,
getPartialPageSize, getPartialPageSize,
_getCurrentPageIndexByCurrentParticleIndexInfinite, _getCurrentPageIndexByCurrentParticleIndexInfinite,
_getCurrentPageIndexByCurrentParticleIndexLimited, _getCurrentPageIndexByCurrentParticleIndexLimited,
@@ -291,3 +290,78 @@ describe('_getCurrentPageIndexByCurrentParticleIndexInfinite', () => {
}) })
}) })
}) })
describe('_getCurrentPageIndexByCurrentParticleIndexLimited particlesCount: 5', () => {
it('returns result as expected if particlesToScroll: 2 (particlesToShow: 2)', () => {
const testCases = [{
currentParticleIndex: 0,
particlesToScroll: 2,
expected: 0,
}, {
currentParticleIndex: 2,
particlesToScroll: 2,
expected: 1,
}, {
currentParticleIndex: 4,
particlesToScroll: 2,
expected: 2,
}]
testCases.forEach(({
currentParticleIndex,
particlesToScroll,
expected,
}) => {
expect(_getCurrentPageIndexByCurrentParticleIndexLimited({
currentParticleIndex,
particlesToScroll,
})).toBe(expected)
})
})
it('returns result as expected if particlesToScroll: 2 (particlesToShow: 3)', () => {
const testCases = [{
currentParticleIndex: 0,
particlesToScroll: 2,
expected: 0,
}, {
currentParticleIndex: 2,
particlesToScroll: 2,
expected: 1,
}]
testCases.forEach(({
currentParticleIndex,
particlesToScroll,
expected,
}) => {
expect(_getCurrentPageIndexByCurrentParticleIndexLimited({
currentParticleIndex,
particlesToScroll,
})).toBe(expected)
})
})
it('returns result as expected if particlesToScroll: 3 (particlesToShow: 2)', () => {
const testCases = [{
currentParticleIndex: 0,
particlesToScroll: 3,
expected: 0,
}, {
currentParticleIndex: 3,
particlesToScroll: 3,
expected: 1,
}]
testCases.forEach(({
currentParticleIndex,
particlesToScroll,
expected,
}) => {
expect(_getCurrentPageIndexByCurrentParticleIndexLimited({
currentParticleIndex,
particlesToScroll,
})).toBe(expected)
})
})
})