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 766266c commit 3e53f98
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/share-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ describe('share-socket', function () {
let server: Server
let port: number
let originalGlobalAgent: Agent
let clock: sinon.SinonFakeTimers

beforeEach(function (done) {
clock = sinon.useFakeTimers()
port = nextPort()
server = createServer()
originalGlobalAgent = globalAgent
Expand All @@ -41,6 +43,7 @@ describe('share-socket', function () {
})

afterEach(function (done) {
clock.restore()
this.timeout(500)
setTimeout(() => {
server.close(done)
Expand Down Expand Up @@ -438,7 +441,6 @@ describe('share-socket', function () {
})

it('should error after ~247 seconds', function (done) {
const clock = sinon.useFakeTimers()
const req = request(`coap://localhost:${port + 1}`)
req.end()

Expand All @@ -451,7 +453,6 @@ describe('share-socket', function () {

req.on('error', (err) => {
expect(err).to.have.property('message', 'No reply in 247 seconds.')
clock.restore()
done()
})

Expand Down

0 comments on commit 3e53f98

Please sign in to comment.