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 3e53f98 commit 5626498
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions test/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ describe('server', function () {
clock

beforeEach(function (done) {
clock = sinon.useFakeTimers()
port = nextPort()
server = createServer()
server.listen(port, 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 @@ -713,8 +708,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 @@ -745,8 +738,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 @@ -767,7 +758,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) => {
Expand Down Expand Up @@ -890,8 +880,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 5626498

Please sign in to comment.