Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(devdeps): update sinon #362

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading