Skip to content

Commit

Permalink
Subtract -1 on the delay tests as the setTimeout resolution behaves w…
Browse files Browse the repository at this point in the history
…eird and causes tests to fail sometimes
  • Loading branch information
marcbachmann committed Aug 5, 2024
1 parent ab4bb17 commit 306e40f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/basics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,14 @@ describe("MockAdapter basics", function () {
var totalTime = end - start;

expect(response.status).to.equal(success);
expect(totalTime).greaterThanOrEqual(firstDelay);
expect(totalTime).greaterThanOrEqual(firstDelay - 1);
}),
instance.get("/bar").then(function (response) {
var end = performance.now();
var totalTime = end - start;

expect(response.status).to.equal(success);
expect(totalTime).greaterThanOrEqual(secondDelay);
expect(totalTime).greaterThanOrEqual(secondDelay - 1);
})
]);
});
Expand All @@ -613,14 +613,14 @@ describe("MockAdapter basics", function () {
var totalTime = end - start;

expect(response.status).to.equal(success);
expect(totalTime).greaterThanOrEqual(firstDelay);
expect(totalTime).greaterThanOrEqual(firstDelay - 1);
}),
instance.get("/bar").then(function (response) {
var end = performance.now();
var totalTime = end - start;

expect(response.status).to.equal(success);
expect(totalTime).greaterThanOrEqual(secondDelay);
expect(totalTime).greaterThanOrEqual(secondDelay - 1);
})
]);
});
Expand All @@ -642,7 +642,7 @@ describe("MockAdapter basics", function () {
var totalTime = end - start;

expect(response.status).to.equal(success);
expect(totalTime).greaterThanOrEqual(requestDelay);
expect(totalTime).greaterThanOrEqual(requestDelay - 1);
//Ensure global delay is not applied
expect(totalTime).lessThan(globalDelay);
}),
Expand All @@ -651,7 +651,7 @@ describe("MockAdapter basics", function () {
var totalTime = end - start;

expect(response.status).to.equal(success);
expect(totalTime).greaterThanOrEqual(globalDelay);
expect(totalTime).greaterThanOrEqual(globalDelay - 1);
})
]);
});
Expand Down

0 comments on commit 306e40f

Please sign in to comment.