Skip to content

Commit

Permalink
fixup! refactor: refactor test code using sinon
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jun 21, 2024
1 parent 9a52230 commit c1dbfa8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ 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 @@ -652,6 +653,7 @@ 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 @@ -676,6 +678,7 @@ 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 @@ -706,6 +709,7 @@ 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 @@ -736,6 +740,7 @@ describe('server', function () {
})

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

send(generate(packet))
Expand All @@ -756,6 +761,7 @@ 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 @@ -877,6 +883,8 @@ 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 c1dbfa8

Please sign in to comment.