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

Commit

Permalink
fix(style): reduce nested callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Aug 29, 2016
1 parent 13ace4f commit 33f5fb3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,18 +210,22 @@ describe('valid Connection', () => {
listener.listen(ma, () => {
const conn = ws.dial(ma)

conn.on('end', () => {
conn.on('end', onEnd)

function onEnd () {
conn.getObservedAddrs((err, addrs) => {
expect(err).to.not.exist
listenerObsAddrs = addrs

listener.close(() => {
listener.close(onClose)

function onClose () {
expect(listenerObsAddrs[0]).to.deep.equal(ma)
expect(dialerObsAddrs.length).to.equal(0)
done()
})
}
})
})
}
conn.resume()
conn.end()
})
Expand All @@ -243,12 +247,14 @@ describe('valid Connection', () => {
listener.listen(ma, () => {
const conn = ws.dial(ma)

conn.on('end', () => {
conn.on('end', onEnd)

function onEnd () {
conn.getPeerInfo((err, peerInfo) => {
expect(err).to.exit
listener.close(done)
})
})
}
conn.resume()
conn.end()
})
Expand All @@ -269,7 +275,8 @@ describe('valid Connection', () => {
conn.pipe(conn)
})

listener.listen(ma, () => {
listener.listen(ma, onListen)
function onListen () {
const conn = ws.dial(ma)
conn.setPeerInfo('b')

Expand All @@ -282,7 +289,7 @@ describe('valid Connection', () => {
})
conn.resume()
conn.end()
})
}
})
})

Expand Down

0 comments on commit 33f5fb3

Please sign in to comment.