From b442e110e4c51b39e804c35f547c5fd3cc3d0b54 Mon Sep 17 00:00:00 2001 From: "Ryan X. Charles" Date: Wed, 16 Apr 2014 16:52:42 -0300 Subject: [PATCH] make tests work by faking storage --- API.js | 3 +++ test/test.API.js | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/API.js b/API.js index cf6e68bfe..5cf8d0841 100644 --- a/API.js +++ b/API.js @@ -20,6 +20,9 @@ API.prototype._init = function(opts) { wallet: { requiredCopayers: opts.requiredCopayers || 3, totalCopayers: opts.totalCopayers || 5, + }, + storage: { + filename: 'copaywallet.json' } }; diff --git a/test/test.API.js b/test/test.API.js index 75161997e..a3046d20e 100644 --- a/test/test.API.js +++ b/test/test.API.js @@ -4,11 +4,13 @@ var chai = chai || require('chai'); var should = chai.should(); var copay = copay || require('../copay'); var API = API || copay.API; +var Storage = Storage || require('../test/mocks/FakeStorage'); describe('API', function() { it('should have a command called "echo"', function() { - var api = new API(); + + var api = new API({Storage: Storage}); should.exist(api.echo); }); @@ -22,7 +24,7 @@ describe('API', function() { }) it('should throw an error for all commands when called with wrong number of arguments', function() { - var api = new API(); + var api = new API({Storage: Storage}); for (var i in API.prototype) { var f = API.prototype[i]; if (i[0] != '_' && typeof f == 'function') { @@ -49,7 +51,7 @@ describe('API', function() { describe('#echo', function() { it('should echo a string', function(done) { - var api = new API(); + var api = new API({Storage: Storage}); var str = 'mystr'; api.echo(str, function(err, result) { result.should.equal(str); @@ -60,7 +62,7 @@ describe('API', function() { describe('#echoNumber', function() { it('should echo a number', function(done) { - var api = new API(); + var api = new API({Storage: Storage}); var num = 500; api.echoNumber(num, function(err, result) { result.should.equal(num); @@ -72,7 +74,7 @@ describe('API', function() { describe('#echoObject', function() { it('should echo an object', function(done) { - var api = new API(); + var api = new API({Storage: Storage}); var obj = {test:'test'}; api.echoObject(obj, function(err, result) { result.test.should.equal(obj.test); @@ -84,7 +86,7 @@ describe('API', function() { describe('#getArgTypes', function() { it('should get the argTypes of echo', function(done) { - var api = new API(); + var api = new API({Storage: Storage}); api.getArgTypes('echo', function(err, result) { result[0][1].should.equal('string'); done(); @@ -94,7 +96,7 @@ describe('API', function() { describe('#getCommands', function() { it('should get all the commands', function(done) { - var api = new API(); + var api = new API({Storage: Storage}); var n = 0; for (var i in api) @@ -110,7 +112,7 @@ describe('API', function() { describe('#getPublicKeyRingId', function() { it('should get a public key ring ID', function(done) { - var api = new API(); + var api = new API({Storage: Storage}); api.getPublicKeyRingId(function(err, result) { result.length.should.be.greaterThan(5); done(); @@ -120,7 +122,7 @@ describe('API', function() { describe('#help', function() { it('should call _cmd_getCommands', function(done) { - var api = new API(); + var api = new API({Storage: Storage}); api._cmd_getCommands = function(callback) { (typeof arguments[0]).should.equal('function'); callback(null, ['item']);