Skip to content

Commit 29bdf59

Browse files
committed
chore: Fix tests to handle multiple Mocha.Done() calls
1 parent 184403a commit 29bdf59

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/test/proxy.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ describe('ProxyConnect', () => {
1818
let testSocket: Socket
1919
let msgs: ProxyMessages
2020

21+
function doneOnce(done: Mocha.Done): Mocha.Done {
22+
let fired = false
23+
return (err?: any) => {
24+
if (!fired) {
25+
fired = true
26+
done(err)
27+
}
28+
}
29+
}
30+
2131
beforeEach(() => {
2232
testSocket = new Socket()
2333
testSocket.connect = (...param): Socket => {
@@ -57,6 +67,7 @@ describe('ProxyConnect', () => {
5767
})
5868

5969
it('should request registration', (done: Mocha.Done) => {
70+
done = doneOnce(done)
6071
conn.on('log_request', (str: string) => {
6172
assert.equal(str, msgs.registerInfo)
6273
done()

0 commit comments

Comments
 (0)