mirror of
https://github.com/fluencelabs/js-libp2p-websockets
synced 2025-04-02 20:51:04 +00:00
fix(style): reduce nested callbacks
This commit is contained in:
parent
13ace4fcea
commit
33f5fb300b
23
test/node.js
23
test/node.js
@ -210,18 +210,22 @@ describe('valid Connection', () => {
|
|||||||
listener.listen(ma, () => {
|
listener.listen(ma, () => {
|
||||||
const conn = ws.dial(ma)
|
const conn = ws.dial(ma)
|
||||||
|
|
||||||
conn.on('end', () => {
|
conn.on('end', onEnd)
|
||||||
|
|
||||||
|
function onEnd () {
|
||||||
conn.getObservedAddrs((err, addrs) => {
|
conn.getObservedAddrs((err, addrs) => {
|
||||||
expect(err).to.not.exist
|
expect(err).to.not.exist
|
||||||
listenerObsAddrs = addrs
|
listenerObsAddrs = addrs
|
||||||
|
|
||||||
listener.close(() => {
|
listener.close(onClose)
|
||||||
|
|
||||||
|
function onClose () {
|
||||||
expect(listenerObsAddrs[0]).to.deep.equal(ma)
|
expect(listenerObsAddrs[0]).to.deep.equal(ma)
|
||||||
expect(dialerObsAddrs.length).to.equal(0)
|
expect(dialerObsAddrs.length).to.equal(0)
|
||||||
done()
|
done()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
})
|
|
||||||
conn.resume()
|
conn.resume()
|
||||||
conn.end()
|
conn.end()
|
||||||
})
|
})
|
||||||
@ -243,12 +247,14 @@ describe('valid Connection', () => {
|
|||||||
listener.listen(ma, () => {
|
listener.listen(ma, () => {
|
||||||
const conn = ws.dial(ma)
|
const conn = ws.dial(ma)
|
||||||
|
|
||||||
conn.on('end', () => {
|
conn.on('end', onEnd)
|
||||||
|
|
||||||
|
function onEnd () {
|
||||||
conn.getPeerInfo((err, peerInfo) => {
|
conn.getPeerInfo((err, peerInfo) => {
|
||||||
expect(err).to.exit
|
expect(err).to.exit
|
||||||
listener.close(done)
|
listener.close(done)
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
conn.resume()
|
conn.resume()
|
||||||
conn.end()
|
conn.end()
|
||||||
})
|
})
|
||||||
@ -269,7 +275,8 @@ describe('valid Connection', () => {
|
|||||||
conn.pipe(conn)
|
conn.pipe(conn)
|
||||||
})
|
})
|
||||||
|
|
||||||
listener.listen(ma, () => {
|
listener.listen(ma, onListen)
|
||||||
|
function onListen () {
|
||||||
const conn = ws.dial(ma)
|
const conn = ws.dial(ma)
|
||||||
conn.setPeerInfo('b')
|
conn.setPeerInfo('b')
|
||||||
|
|
||||||
@ -282,7 +289,7 @@ describe('valid Connection', () => {
|
|||||||
})
|
})
|
||||||
conn.resume()
|
conn.resume()
|
||||||
conn.end()
|
conn.end()
|
||||||
})
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user