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

Commit

Permalink
Merge pull request #13 from noffle/circle
Browse files Browse the repository at this point in the history
CircleCI and 100% coverage.
  • Loading branch information
daviddias committed Apr 13, 2016
2 parents 46fd7e1 + 987f4fa commit 0b0bcaf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ peer-info JavaScript implementation
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Build Status](https://travis-ci.org/diasdavid/js-peer-info.svg?style=flat-square)](https://travis-ci.org/diasdavid/js-peer-info)
![](https://img.shields.io/badge/coverage-100%25-brightgreen.svg?style=flat-square)
[![Dependency Status](https://david-dm.org/diasdavid/js-peer-info.svg?style=flat-square)](https://david-dm.org/diasdavid/js-peer-info)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

Expand Down
3 changes: 3 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
machine:
node:
version: stable
38 changes: 38 additions & 0 deletions test/peer-info.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ describe('peer-info', function () {
done()
})

it('create without "new"', (done) => {
const pi = PeerInfo()
expect(pi).to.exist
expect(pi.id).to.exist
done()
})

it('add multiaddr', (done) => {
const pi = new PeerInfo()
expect(pi).to.exist
Expand Down Expand Up @@ -60,10 +67,15 @@ describe('peer-info', function () {
const pi = new PeerInfo()
expect(pi).to.exist
const mh = Multiaddr('/ip4/127.0.0.1/tcp/5001')
const mh2 = Multiaddr('/ip4/127.0.0.1/tcp/9002')
const mh3 = Multiaddr('/ip4/127.0.0.1/tcp/9009')
pi.multiaddr.addSafe(mh)
expect(pi.multiaddrs.length).to.equal(0)
pi.multiaddr.addSafe(mh)
expect(pi.multiaddrs.length).to.equal(1)
pi.multiaddr.addSafe(mh2)
pi.multiaddr.addSafe(mh3)
expect(pi.multiaddrs.length).to.equal(1)
done()
})

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

done()
})

it('replace multiaddr (no arrays)', (done) => {
const pi = new PeerInfo()
expect(pi).to.exist
const mh1 = Multiaddr('/ip4/127.0.0.1/tcp/5001')
const mh2 = Multiaddr('/ip4/127.0.0.1/tcp/5002')
const mh3 = Multiaddr('/ip4/127.0.0.1/tcp/5003')
const mh4 = Multiaddr('/ip4/127.0.0.1/tcp/5004')
const mh5 = Multiaddr('/ip4/127.0.0.1/tcp/5005')

pi.multiaddr.add(mh1)
pi.multiaddr.add(mh2)
pi.multiaddr.add(mh3)
pi.multiaddr.add(mh4)

expect(pi.multiaddrs.length).to.equal(4)

const old = mh2
const fresh = mh5

pi.multiaddr.replace(old, fresh)

expect(pi.multiaddrs.length).to.equal(4)

done()
})
})

0 comments on commit 0b0bcaf

Please sign in to comment.