From 0d9317e2d46929ebd2504b34054d4a54eacaa725 Mon Sep 17 00:00:00 2001 From: Manan Patel Date: Thu, 19 Jun 2014 01:07:45 -0700 Subject: [PATCH] adding few tests for Peer.js --- test/test.Peer.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/test.Peer.js b/test/test.Peer.js index 0a0f0fd..d020f39 100644 --- a/test/test.Peer.js +++ b/test/test.Peer.js @@ -20,6 +20,28 @@ describe('Peer', function() { var p = new Peer('localhost', 8333); should.exist(p); }); + it('should be able to create instance', function() { + var p = new Peer('localhost:8333'); + should.exist(p); + }); + it('should be able to create instance', function() { + var p = new Peer('localhost:8333'); + var p2 = new Peer(p); + should.exist(p2); + }); + it('should not be able to create instance', function() { + should.throw(function() { + new Peer(8333); + }); + }); + it('should be able to create instance', function() { + var p = new Peer('localhost', 8333); + p.toString().should.equal('localhost:8333'); + }); + it('check host as buffer', function() { + var p = new Peer('127.0.0.1', 8333); + p.getHostAsBuffer().toString('hex').should.equal('7f000001'); + }); });