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 Jan 2, 2023
1 parent 784ab9a commit 2ad2a77
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 @@ -51,7 +51,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",
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 @@ -998,30 +998,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 @@ -1111,30 +1094,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 @@ -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
Expand Down

0 comments on commit 2ad2a77

Please sign in to comment.