16 lines
520 B
TypeScript
16 lines
520 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { clampLimit, computeNextExpectedSeq } from './pagination.util';
|
|
|
|
describe('pagination utils', () => {
|
|
it('clamps limit safely', () => {
|
|
expect(clampLimit(undefined, 50, 200)).toBe(50);
|
|
expect(clampLimit('500', 50, 200)).toBe(200);
|
|
expect(clampLimit('-1', 50, 200)).toBe(50);
|
|
});
|
|
|
|
it('computes next expected seq', () => {
|
|
expect(computeNextExpectedSeq(1, [1, 2, 3])).toBe(4);
|
|
expect(computeNextExpectedSeq(1, [1, 3, 4])).toBe(2);
|
|
});
|
|
});
|