Skip to content

Commit

Permalink
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 91858f6 commit 5b6208f
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions test/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('server', function () {
port = nextPort()
server = createServer()
server.listen(port, done)
clock = sinon.useFakeTimers()
})

beforeEach(function (done) {
Expand Down Expand Up @@ -595,8 +596,6 @@ describe('server', function () {
})

it('should not retry sending the response', function (done) {
clock = sinon.useFakeTimers()

let messages = 0

send(generate(packet))
Expand Down Expand Up @@ -655,8 +654,6 @@ describe('server', function () {
})

it('should reply with a confirmable after an ack', function (done) {
clock = sinon.useFakeTimers()

send(generate(packet))
server.on('request', (req, res) => {
setTimeout(() => {
Expand All @@ -681,8 +678,6 @@ describe('server', function () {
})

it('should retry sending the response if it does not receive an ack four times before 45s', function (done) {
clock = sinon.useFakeTimers()

let messages = 0

send(generate(packet))
Expand Down Expand Up @@ -712,8 +707,6 @@ describe('server', function () {
})

it('should stop resending after it receives an ack', function (done) {
clock = sinon.useFakeTimers()

let messages = 0

send(generate(packet))
Expand Down Expand Up @@ -744,8 +737,6 @@ describe('server', function () {
})

it('should not resend with a piggyback response', function (done) {
clock = sinon.useFakeTimers()

let messages = 0

send(generate(packet))
Expand All @@ -766,8 +757,6 @@ describe('server', function () {
})

it('should error if it does not receive an ack four times before ~247s', function (done) {
clock = sinon.useFakeTimers()

send(generate(packet))
server.on('request', (req, res) => {
// needed to avoid sending a piggyback response
Expand Down Expand Up @@ -889,8 +878,6 @@ describe('server', function () {
})

it('should emit a \'finish\' if the client do not ack for ~247s', function (done) {
clock = sinon.useFakeTimers()

doObserve()

server.on('request', (req, res) => {
Expand Down

0 comments on commit 5b6208f

Please sign in to comment.