From c49a6b2ba5fcd6fb67a7d79d555694415d6358f0 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 79987d08..34ae9e23 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "eslint-plugin-promise": "^6.1.0", "mocha": "^10.1.0", "c8": "^8.0.1", - "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 6dc1c39e..ad481380 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)) @@ -1022,16 +1022,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, @@ -1039,13 +1029,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() @@ -1135,16 +1118,6 @@ describe('request', function () { }) describe('confirmable retries', function () { - let clock - - beforeEach(function () { - clock = useFakeTimers() - }) - - afterEach(function () { - clock.restore() - }) - function doReq (): OutgoingMessage { return request({ port, @@ -1152,13 +1125,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() @@ -1627,23 +1593,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