Skip to content

Commit

Permalink
[tools] throttle.test.ts: Introduce 0.2ms tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrHeinz committed Jul 31, 2024
1 parent e3d1caf commit 5ccae41
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/tools/src/batch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ describe("batch tests", () => {

// Expect time to have taken at least this long...
const expectedTime = ((numberOfLogs / batchSize) * throttleResolveAfter) / maxThrottle;
const toleranceMilliseconds = 0.2;

expect(end).toBeGreaterThanOrEqual(expectedTime);
expect(end).toBeGreaterThanOrEqual(expectedTime - toleranceMilliseconds);
});

it("should send after flush (with long timeout)", async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/tools/src/throttle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ describe("Throttle tests", () => {

// Expect time to have taken (numberOfPromises / max) * throttleTime
const expectedTime = (numberOfPromises / max) * throttleTime;
const toleranceMilliseconds = 0.2;

expect(end).toBeGreaterThanOrEqual(expectedTime);
expect(end).toBeGreaterThanOrEqual(expectedTime - toleranceMilliseconds);
});

it("should handle rejections", async () => {
Expand Down

0 comments on commit 5ccae41

Please sign in to comment.