nestjs-api-tools
Version:
Wrappers for convenient API development including validation, logging and i18n wrappers
22 lines (18 loc) • 651 B
text/typescript
import {pageAndSizeToSkipAndTake} from './pagination';
describe('pageAndSizeToSkipAndTake', () => {
const DEFAULT_SIZE = 900;
describe.each([
[1, 15, 0, 15],
[7, 15, 90, 15],
[-1, 15, 0, 15],
[null, 15, 0, 15],
[1, -1, 0, DEFAULT_SIZE],
[1, null, 0, null],
])('page %o, size %o, skip %o, take %o', (page: number, size: number, skip: number, take: number) => {
it('should transform page and size to offset and limit', () => {
const [actualSkip, actualTake] = pageAndSizeToSkipAndTake(page, size, DEFAULT_SIZE);
expect(actualSkip).toEqual(skip);
expect(actualTake).toEqual(take);
});
});
});