mirror of https://github.com/BTCPrivate/copay.git
Adding Identity close test
This commit is contained in:
parent
f7c1e3d4ab
commit
afb6574217
|
@ -461,6 +461,7 @@ Identity.prototype._cleanUp = function() {
|
||||||
* @desc Closes the wallet and disconnects all services
|
* @desc Closes the wallet and disconnects all services
|
||||||
*/
|
*/
|
||||||
Identity.prototype.close = function(cb) {
|
Identity.prototype.close = function(cb) {
|
||||||
|
console.log('close!!!!!');
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
function doClose() {
|
function doClose() {
|
||||||
|
@ -507,7 +508,7 @@ Identity.prototype.importWalletFromObj = function(obj, opts, cb) {
|
||||||
log.debug('Updating Indexes for wallet:' + w.getName());
|
log.debug('Updating Indexes for wallet:' + w.getName());
|
||||||
w.updateIndexes(function(err) {
|
w.updateIndexes(function(err) {
|
||||||
log.debug('Adding wallet to profile:' + w.getName());
|
log.debug('Adding wallet to profile:' + w.getName());
|
||||||
self.storeWallet(w, function (err) {
|
self.storeWallet(w, function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
self.addWallet(w);
|
self.addWallet(w);
|
||||||
|
|
|
@ -179,6 +179,36 @@ describe('Identity model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#close', function(done) {
|
||||||
|
it('should store profile', function(done) {
|
||||||
|
var iden = new Identity(getDefaultParams());
|
||||||
|
sinon.spy(iden, 'emitAndKeepAlive');
|
||||||
|
sinon.spy(iden, '_cleanUp');
|
||||||
|
iden.verifyChecksum = sinon.stub().yields(null, true);
|
||||||
|
iden.close(function() {
|
||||||
|
iden._cleanUp.calledOnce.should.be.true;
|
||||||
|
iden.emitAndKeepAlive.calledOnce.should.be.true;
|
||||||
|
iden.emitAndKeepAlive.getCall(0).args[0].should.equal('closed');
|
||||||
|
iden.store.calledOnce.should.be.true;
|
||||||
|
iden.store.getCall(0).args[0].noWallets.should.equal(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
it('should not store profile', function(done) {
|
||||||
|
var iden = new Identity(getDefaultParams());
|
||||||
|
sinon.spy(iden, 'emitAndKeepAlive');
|
||||||
|
sinon.spy(iden, '_cleanUp');
|
||||||
|
iden.verifyChecksum = sinon.stub().yields(null, false);
|
||||||
|
iden.close(function() {
|
||||||
|
iden._cleanUp.calledOnce.should.be.true;
|
||||||
|
iden.emitAndKeepAlive.calledOnce.should.be.true;
|
||||||
|
iden.emitAndKeepAlive.getCall(0).args[0].should.equal('closed');
|
||||||
|
iden.store.calledOnce.should.be.false;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#remove', function(done) {
|
describe('#remove', function(done) {
|
||||||
it('should remove empty profile', function(done) {
|
it('should remove empty profile', function(done) {
|
||||||
var storage = sinon.stub();
|
var storage = sinon.stub();
|
||||||
|
|
Loading…
Reference in New Issue