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 ed7e9cd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/share-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ describe('share-socket', function () {
request(`coap://localhost:${port}/abcd/ef/gh/?foo=bar&beep=bop`).end()
server.on('request', (req) => {
expect(req.url).to.eql('/abcd/ef/gh?foo=bar&beep=bop')
setImmediate(done)
done()
})
})

it('should return code 2.05 by default', function (done) {
const req = request(`coap://localhost:${port}/abcd/ef/gh/?foo=bar&beep=bop`).end()
req.on('response', (res: IncomingMessage) => {
expect(res.code).to.eql('2.05')
setImmediate(done)
done()
})

server.on('request', (req, res) => {
Expand All @@ -80,7 +80,7 @@ describe('share-socket', function () {
request(`coap://localhost:${port}`)
.on('response', (res: IncomingMessage) => {
expect(res.code).to.eql('4.04')
setImmediate(done)
done()
})
.end()

Expand All @@ -94,7 +94,7 @@ describe('share-socket', function () {
request(`coap://localhost:${port}`)
.on('response', (res: IncomingMessage) => {
expect(res.code).to.eql('4.04')
setImmediate(done)
done()
})
.end()

Expand Down Expand Up @@ -337,9 +337,9 @@ describe('share-socket', function () {

server.on('request', (req, res) => {
res.write('hello')
setTimeout(() => {
originalSetImmediate(() => {
res.end('world')
}, 10)
})
})

;[req1, req2].forEach((req) => {
Expand Down Expand Up @@ -403,7 +403,7 @@ describe('share-socket', function () {
})

req1.on('response', () => {
setImmediate(() => {
originalSetImmediate(() => {
request({
port,
method: 'GET',
Expand Down

0 comments on commit ed7e9cd

Please sign in to comment.