From 306e40fca0c9ec939f7158917b829804d752013a Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Mon, 5 Aug 2024 13:27:11 +0200 Subject: [PATCH] Subtract -1 on the delay tests as the setTimeout resolution behaves weird and causes tests to fail sometimes --- test/basics.spec.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/basics.spec.js b/test/basics.spec.js index 4a46066..8786800 100644 --- a/test/basics.spec.js +++ b/test/basics.spec.js @@ -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); }) ]); }); @@ -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); }) ]); }); @@ -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); }), @@ -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); }) ]); });