From 5b6208f0a22a019097a96acab412a75700631993 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Sun, 21 Apr 2024 15:50:45 +0200 Subject: [PATCH] refactor: simply use of siinon fake timers --- test/server.ts | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/test/server.ts b/test/server.ts index 9240ba50..5d7ea456 100644 --- a/test/server.ts +++ b/test/server.ts @@ -32,6 +32,7 @@ describe('server', function () { port = nextPort() server = createServer() server.listen(port, done) + clock = sinon.useFakeTimers() }) beforeEach(function (done) { @@ -595,8 +596,6 @@ describe('server', function () { }) it('should not retry sending the response', function (done) { - clock = sinon.useFakeTimers() - let messages = 0 send(generate(packet)) @@ -655,8 +654,6 @@ describe('server', function () { }) it('should reply with a confirmable after an ack', function (done) { - clock = sinon.useFakeTimers() - send(generate(packet)) server.on('request', (req, res) => { setTimeout(() => { @@ -681,8 +678,6 @@ describe('server', function () { }) it('should retry sending the response if it does not receive an ack four times before 45s', function (done) { - clock = sinon.useFakeTimers() - let messages = 0 send(generate(packet)) @@ -712,8 +707,6 @@ describe('server', function () { }) it('should stop resending after it receives an ack', function (done) { - clock = sinon.useFakeTimers() - let messages = 0 send(generate(packet)) @@ -744,8 +737,6 @@ describe('server', function () { }) it('should not resend with a piggyback response', function (done) { - clock = sinon.useFakeTimers() - let messages = 0 send(generate(packet)) @@ -766,8 +757,6 @@ describe('server', function () { }) it('should error if it does not receive an ack four times before ~247s', function (done) { - clock = sinon.useFakeTimers() - send(generate(packet)) server.on('request', (req, res) => { // needed to avoid sending a piggyback response @@ -889,8 +878,6 @@ describe('server', function () { }) it('should emit a \'finish\' if the client do not ack for ~247s', function (done) { - clock = sinon.useFakeTimers() - doObserve() server.on('request', (req, res) => {