Skip to content

Commit

Permalink
chore(devdeps): update sinon
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Nov 24, 2023
1 parent 5014206 commit c49a6b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 55 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
57 changes: 3 additions & 54 deletions test/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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) {
Expand All @@ -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))
Expand Down Expand Up @@ -1022,30 +1022,13 @@ describe('request', function () {
})

describe('non-confirmable retries', function () {
let clock

beforeEach(function () {
clock = useFakeTimers()
})

afterEach(function () {
clock.restore()
})

function doReq (): OutgoingMessage {
return request({
port,
confirmable: false
}).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()

Expand Down Expand Up @@ -1135,30 +1118,13 @@ describe('request', function () {
})

describe('confirmable retries', function () {
let clock

beforeEach(function () {
clock = useFakeTimers()
})

afterEach(function () {
clock.restore()
})

function doReq (): OutgoingMessage {
return request({
port,
confirmable: true
}).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()

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c49a6b2

Please sign in to comment.