-
Notifications
You must be signed in to change notification settings - Fork 454
Unit tests for Multisignatures module - Closes #1723 #2326
Conversation
cab716c
to
ed14605
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@4miners the initial skeleton for unit tests was huge, so idea was to separate them into several PRs. But it's not needed anymore. I updated the PR. |
test/unit/modules/multisignatures.js
Outdated
|
||
const rewiredMultisignatures = rewire('../../../modules/multisignatures.js'); | ||
|
||
const validAccount = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use fixtures for that, you already importing those (accountsFixtures
).
test/unit/modules/multisignatures.js
Outdated
@@ -99,6 +138,7 @@ describe('multisignatures', () => { | |||
// Create instance of multisignatures module | |||
multisignaturesInstance = new rewiredMultisignatures( | |||
(err, __multisignatures) => { | |||
error = err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really needed to use global variable here, you can call done(err)
instead.
test/unit/modules/multisignatures.js
Outdated
.calledOnce; | ||
}); | ||
|
||
it('assign __private.assetTypes[transactionTypes.MULTI]', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should assign
test/unit/modules/multisignatures.js
Outdated
done(); | ||
}); | ||
|
||
it('should accept address as parameter', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description doesn't match what is tested, please clarify
test/unit/modules/multisignatures.js
Outdated
}); | ||
}); | ||
|
||
it('should fail if getMultiSignature function returns an error', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not failing, it's calling callback with error
test/unit/modules/multisignatures.js
Outdated
}); | ||
}); | ||
|
||
it('should fail if given address does not return an account', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrong description, you're not testing the behavior of getMultiSignature
, so you cannot be sure of the reason why this function returning empty account
test/unit/modules/multisignatures.js
Outdated
expect(get('modules').accounts.getAccounts).to.be.calledWith({ | ||
address: ['address1'], | ||
}); | ||
expect(scopeGroup.members) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please also test with more than 1 member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this test to have multiple members instead of adding another one.
test/unit/modules/multisignatures.js
Outdated
done(); | ||
}); | ||
|
||
it('should fail library.logic.account.get function returns an error', done => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should call a callback with ApiError instance when...
Review checklist