Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.

Commit 33f5fb3

Browse files
committed
fix(style): reduce nested callbacks
1 parent 13ace4f commit 33f5fb3

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

test/node.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,22 @@ describe('valid Connection', () => {
210210
listener.listen(ma, () => {
211211
const conn = ws.dial(ma)
212212

213-
conn.on('end', () => {
213+
conn.on('end', onEnd)
214+
215+
function onEnd () {
214216
conn.getObservedAddrs((err, addrs) => {
215217
expect(err).to.not.exist
216218
listenerObsAddrs = addrs
217219

218-
listener.close(() => {
220+
listener.close(onClose)
221+
222+
function onClose () {
219223
expect(listenerObsAddrs[0]).to.deep.equal(ma)
220224
expect(dialerObsAddrs.length).to.equal(0)
221225
done()
222-
})
226+
}
223227
})
224-
})
228+
}
225229
conn.resume()
226230
conn.end()
227231
})
@@ -243,12 +247,14 @@ describe('valid Connection', () => {
243247
listener.listen(ma, () => {
244248
const conn = ws.dial(ma)
245249

246-
conn.on('end', () => {
250+
conn.on('end', onEnd)
251+
252+
function onEnd () {
247253
conn.getPeerInfo((err, peerInfo) => {
248254
expect(err).to.exit
249255
listener.close(done)
250256
})
251-
})
257+
}
252258
conn.resume()
253259
conn.end()
254260
})
@@ -269,7 +275,8 @@ describe('valid Connection', () => {
269275
conn.pipe(conn)
270276
})
271277

272-
listener.listen(ma, () => {
278+
listener.listen(ma, onListen)
279+
function onListen () {
273280
const conn = ws.dial(ma)
274281
conn.setPeerInfo('b')
275282

@@ -282,7 +289,7 @@ describe('valid Connection', () => {
282289
})
283290
conn.resume()
284291
conn.end()
285-
})
292+
}
286293
})
287294
})
288295

0 commit comments

Comments
 (0)