Skip to content

Commit

Permalink
[tools] throttle.test.ts: Introduce 0.2ms tolerance (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrHeinz authored Aug 5, 2024
1 parent 2a61dda commit a4b4f0b
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 a4b4f0b

Please sign in to comment.