From d8e5971764145f0e2962180e9a5fe7bf84d7c794 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Wed, 23 Nov 2022 18:31:17 +0100 Subject: [PATCH] chore(devdeps): update sinon --- package.json | 2 +- test/request.ts | 57 +++---------------------------------------------- 2 files changed, 4 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 0d3cf2dd..bbb53f5a 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "mocha": "^10.1.0", "c8": "^7.12.0", "pre-commit": "1.2.2", - "sinon": "^12.0.1", + "sinon": "^15.0.1", "source-map-support": "^0.5.21", "timekeeper": "^2.2.0", "ts-node": "^10.9.1", diff --git a/test/request.ts b/test/request.ts index 61a4f809..b05b1398 100644 --- a/test/request.ts +++ b/test/request.ts @@ -12,7 +12,7 @@ import { request, createServer, Server, globalAgent } from '../index' import { toBinary } from '../lib/option_converter' import { parse, generate } from 'coap-packet' import { createSocket, Socket } from 'dgram' -import { useFakeTimers } from 'sinon' +import { SinonFakeTimers, useFakeTimers } from 'sinon' import BufferListStream from 'bl' import OutgoingMessage from '../lib/outgoing_message' import { AddressInfo } from 'net' @@ -21,7 +21,7 @@ const originalSetImmediate = setImmediate describe('request', function () { let server: Socket | Server | null let server2: Socket | null - let clock: any + let clock: SinonFakeTimers let port: number beforeEach(function (done) { @@ -45,7 +45,7 @@ describe('request', function () { clock.restore() }) - function fastForward (increase, max): void { + function fastForward (increase: number, max: number): void { clock.tick(increase) if (increase < max) { originalSetImmediate(fastForward.bind(null, increase, max - increase)) @@ -998,16 +998,6 @@ describe('request', function () { }) describe('non-confirmable retries', function () { - let clock - - beforeEach(function () { - clock = useFakeTimers() - }) - - afterEach(function () { - clock.restore() - }) - function doReq (): OutgoingMessage { return request({ port, @@ -1015,13 +1005,6 @@ describe('request', function () { }).end() } - function fastForward (increase, max): void { - clock.tick(increase) - if (increase < max) { - originalSetImmediate(fastForward.bind(null, increase, max - increase)) - } - } - it('should timeout after ~202 seconds', function (done) { const req = doReq() @@ -1111,16 +1094,6 @@ describe('request', function () { }) describe('confirmable retries', function () { - let clock - - beforeEach(function () { - clock = useFakeTimers() - }) - - afterEach(function () { - clock.restore() - }) - function doReq (): OutgoingMessage { return request({ port, @@ -1128,13 +1101,6 @@ describe('request', function () { }).end() } - function fastForward (increase, max): void { - clock.tick(increase) - if (increase < max) { - originalSetImmediate(fastForward.bind(null, increase, max - increase)) - } - } - it('should error after ~247 seconds', function (done) { const req = doReq() @@ -1603,23 +1569,6 @@ describe('request', function () { }) describe('token', function () { - let clock - - beforeEach(function () { - clock = useFakeTimers() - }) - - afterEach(function () { - clock.restore() - }) - - function fastForward (increase, max): void { - clock.tick(increase) - if (increase < max) { - originalSetImmediate(fastForward.bind(null, increase, max - increase)) - } - } - it('should timeout if the response token size doesn\'t match the request\'s', function (done) { const req = request({ port