|
1 | 1 | 'use strict';
|
2 |
| -var assert = require('assert'); |
| 2 | +var chai = require('chai'), |
| 3 | + expect = chai.expect, |
| 4 | + sinon = require('sinon'); |
| 5 | + |
3 | 6 | var PeerSync = require('../../lib/PeerSync.js').class();
|
4 |
| -describe('Unit testing PeerSync', function() { |
5 |
| - var ps; |
| 7 | +describe('PeerSync', function() { |
| 8 | + var ps, inv_info; |
6 | 9 | beforeEach(function() {
|
7 | 10 | ps = new PeerSync();
|
| 11 | + ps.init(); |
| 12 | + }); |
| 13 | + afterEach(function(){ |
| 14 | + ps.close(); |
8 | 15 | });
|
9 | 16 | describe('#init()', function() {
|
10 | 17 | it('should return with no errors', function() {
|
11 |
| - assert.doesNotThrow(function() { |
12 |
| - ps.init(); |
13 |
| - }); |
| 18 | + var other_ps = new PeerSync(); |
| 19 | + expect(other_ps.init.bind(other_ps)).not.to.throw(Error); |
| 20 | + other_ps.close(); |
14 | 21 | });
|
15 | 22 | });
|
16 | 23 | describe('#handle_inv()', function() {
|
17 |
| - it('should return with no errors'); |
18 |
| - it('should call sendGetData'); |
| 24 | + inv_info = { |
| 25 | + message: {invs: []}, |
| 26 | + conn: {sendGetData: sinon.spy()} |
| 27 | + }; |
| 28 | + it('should return with no errors', function(){ |
| 29 | + expect(function() { |
| 30 | + ps.handle_inv(inv_info); |
| 31 | + }).not.to.throw(Error); |
| 32 | + }); |
| 33 | + it('should call sendGetData', function() { |
| 34 | + ps.handle_inv(inv_info); |
| 35 | + expect(inv_info.conn.calledOnce); |
| 36 | + }); |
19 | 37 | });
|
20 | 38 | describe('#handle_tx()', function() {
|
21 | 39 | it('should call storeTxs');
|
|
0 commit comments