Skip to content

Commit

Permalink
fixup! refactor: simply use of siinon fake timers
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Apr 21, 2024
1 parent 06410c5 commit 45a5990
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions test/request.ts
Original file line number Diff line number Diff line change
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 45a5990

Please sign in to comment.