Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jun 21, 2024
1 parent 00439b1 commit daca14e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
10 changes: 6 additions & 4 deletions test/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import { nextPort } from './common'
import { expect } from 'chai'
import { parse, generate } from 'coap-packet'
import { request, createServer, Server } from '../index'
import { request, createServer } from '../index'
import type { Server } from '../index'
import dgram from 'dgram'
import tk from 'timekeeper'
import sinon from 'sinon'
import OutgoingMessage from '../lib/outgoing_message'
import IncomingMessage from '../lib/incoming_message'
import type OutgoingMessage from '../lib/outgoing_message'
import type IncomingMessage from '../lib/incoming_message'

describe('proxy', function () {
let server: Server,
Expand Down Expand Up @@ -213,7 +214,8 @@ describe('proxy', function () {
expect(res.code).to.eql('5.00')
expect(res.payload.toString()).to.match(/ENOTFOUND|EAI_AGAIN/)
} catch (err) {
return done(err)
done(err)
return
}
done()
})
Expand Down
22 changes: 12 additions & 10 deletions test/share-socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ describe('share-socket', function () {
})
})

it.skip('should support multiple observe to the same destination', function (done) {
it('should support multiple observe to the same destination', function (done) {
const req1 = request({
port,
method: 'GET',
Expand All @@ -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,11 +403,13 @@ describe('share-socket', function () {
})

req1.on('response', () => {
request({
port,
method: 'GET',
pathname: '/b'
}).end()
originalSetImmediate(() => {
request({
port,
method: 'GET',
pathname: '/b'
}).end()
})
})
})

Expand Down Expand Up @@ -442,10 +444,10 @@ describe('share-socket', function () {
const req = request(`coap://localhost:${port + 1}`)
req.end()

function fastForward (increase, max): void {
function fastForward (increase: number, max: number): void {
clock.tick(increase)
if (increase < max) {
fastForward(increase, max - increase)
originalSetImmediate(fastForward.bind(null, increase, max - increase))
}
}

Expand Down

0 comments on commit daca14e

Please sign in to comment.