Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Commit 987f4fa

Browse files
committed
100% coverage
1 parent 17a4101 commit 987f4fa

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ peer-info JavaScript implementation
44
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
55
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
66
[![Build Status](https://travis-ci.org/diasdavid/js-peer-info.svg?style=flat-square)](https://travis-ci.org/diasdavid/js-peer-info)
7+
![](https://img.shields.io/badge/coverage-100%25-brightgreen.svg?style=flat-square)
78
[![Dependency Status](https://david-dm.org/diasdavid/js-peer-info.svg?style=flat-square)](https://david-dm.org/diasdavid/js-peer-info)
89
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
910

test/peer-info.spec.js

+38
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ describe('peer-info', function () {
2525
done()
2626
})
2727

28+
it('create without "new"', (done) => {
29+
const pi = PeerInfo()
30+
expect(pi).to.exist
31+
expect(pi.id).to.exist
32+
done()
33+
})
34+
2835
it('add multiaddr', (done) => {
2936
const pi = new PeerInfo()
3037
expect(pi).to.exist
@@ -60,10 +67,15 @@ describe('peer-info', function () {
6067
const pi = new PeerInfo()
6168
expect(pi).to.exist
6269
const mh = Multiaddr('/ip4/127.0.0.1/tcp/5001')
70+
const mh2 = Multiaddr('/ip4/127.0.0.1/tcp/9002')
71+
const mh3 = Multiaddr('/ip4/127.0.0.1/tcp/9009')
6372
pi.multiaddr.addSafe(mh)
6473
expect(pi.multiaddrs.length).to.equal(0)
6574
pi.multiaddr.addSafe(mh)
6675
expect(pi.multiaddrs.length).to.equal(1)
76+
pi.multiaddr.addSafe(mh2)
77+
pi.multiaddr.addSafe(mh3)
78+
expect(pi.multiaddrs.length).to.equal(1)
6779
done()
6880
})
6981

@@ -93,4 +105,30 @@ describe('peer-info', function () {
93105

94106
done()
95107
})
108+
109+
it('replace multiaddr (no arrays)', (done) => {
110+
const pi = new PeerInfo()
111+
expect(pi).to.exist
112+
const mh1 = Multiaddr('/ip4/127.0.0.1/tcp/5001')
113+
const mh2 = Multiaddr('/ip4/127.0.0.1/tcp/5002')
114+
const mh3 = Multiaddr('/ip4/127.0.0.1/tcp/5003')
115+
const mh4 = Multiaddr('/ip4/127.0.0.1/tcp/5004')
116+
const mh5 = Multiaddr('/ip4/127.0.0.1/tcp/5005')
117+
118+
pi.multiaddr.add(mh1)
119+
pi.multiaddr.add(mh2)
120+
pi.multiaddr.add(mh3)
121+
pi.multiaddr.add(mh4)
122+
123+
expect(pi.multiaddrs.length).to.equal(4)
124+
125+
const old = mh2
126+
const fresh = mh5
127+
128+
pi.multiaddr.replace(old, fresh)
129+
130+
expect(pi.multiaddrs.length).to.equal(4)
131+
132+
done()
133+
})
96134
})

0 commit comments

Comments
 (0)