Skip to content

Commit

Permalink
fix: add test for batching
Browse files Browse the repository at this point in the history
  • Loading branch information
infloop committed Nov 21, 2023
1 parent 89dd289 commit d8c7488
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/common/registry/fetch/utils/batches.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ describe('makeBatches util', () => {
]);
});

test('should create batches with limit not fully divisible by batch size', () => {
const batchSize = 501;
const offset = 297;
const limit = 2125;

const result = makeBatches(batchSize, offset, limit);

expect(result).toEqual([
{ offset: 297, batchSize: 501 },
{ offset: 798, batchSize: 501 },
{ offset: 1299, batchSize: 501 },
{ offset: 1800, batchSize: 501 },
{ offset: 2301, batchSize: 121 },
]);
});

test('should create a single batch when limit is less than batchSize', () => {
const batchSize = 10;
const offset = 2;
Expand Down

0 comments on commit d8c7488

Please sign in to comment.