Merge pull request #1418 from matiaspando/test/addingCoverage
Test added on Wallet.js
This commit is contained in:
commit
e2af5ac782
2 changed files with 31 additions and 2 deletions
|
|
@ -517,7 +517,6 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
preconditions.checkArgument(data.type);
|
preconditions.checkArgument(data.type);
|
||||||
preconditions.checkArgument(ts);
|
preconditions.checkArgument(ts);
|
||||||
preconditions.checkArgument(_.isNumber(ts));
|
preconditions.checkArgument(_.isNumber(ts));
|
||||||
|
|
||||||
log.debug('RECV', senderId, data);
|
log.debug('RECV', senderId, data);
|
||||||
|
|
||||||
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
||||||
|
|
@ -526,7 +525,6 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
// This handler is repeaded on WalletFactory (#join). TODO
|
// This handler is repeaded on WalletFactory (#join). TODO
|
||||||
case 'walletId':
|
case 'walletId':
|
||||||
|
|
|
||||||
|
|
@ -402,6 +402,37 @@ describe('Wallet model', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('#_onData', function() {
|
||||||
|
var w = cachedCreateW();
|
||||||
|
var sender = '025c046aaf505a6d23203edd343132e9d4d21818b962d1e9a9c98573cc2031bfc9';
|
||||||
|
var ts = 1410810974778246;
|
||||||
|
it('should fail on message unknown', function() {
|
||||||
|
var data = {
|
||||||
|
type: "xxx",
|
||||||
|
walletId: w.id
|
||||||
|
};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
w._onData(sender, data, ts);
|
||||||
|
}).should.
|
||||||
|
throw('unknown message type received: xxx from: 025c046aaf505a6d23203edd343132e9d4d21818b962d1e9a9c98573cc2031bfc9');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call sendWalletReady', function() {
|
||||||
|
var data = {
|
||||||
|
type: "walletId",
|
||||||
|
walletId: w.id
|
||||||
|
};
|
||||||
|
|
||||||
|
var spy = sinon.spy(w, 'sendWalletReady');
|
||||||
|
w._onData(sender, data, ts);
|
||||||
|
sinon.assert.callCount(spy, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('#purgeTxProposals', function() {
|
describe('#purgeTxProposals', function() {
|
||||||
it('should delete all', function() {
|
it('should delete all', function() {
|
||||||
var w = cachedCreateW();
|
var w = cachedCreateW();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue