Added a test to PublicKeyRing to increase coverage

This commit is contained in:
Matias Pando 2014-08-26 17:01:41 -03:00
parent f8c665ce2e
commit d4ce4e3c01
2 changed files with 18 additions and 3 deletions

View File

@ -43,9 +43,9 @@ PublicKeyRing.trim = function(data) {
};
PublicKeyRing.fromObj = function(data) {
if (data instanceof PublicKeyRing) {
throw new Error('bad data format: Did you use .toObj()?');
}
preconditions.checkArgument(typeof data !== 'PublicKeyRing');
var opts = PublicKeyRing.trim(data);
// Support old indexes schema

View File

@ -434,6 +434,21 @@ describe('PublicKeyRing model', function() {
w.nicknameForIndex(4).should.equal('juan1');
});
it('#fromObj with error', function() {
var config = {
networkName: 'livenet',
};
var pkr = new PublicKeyRing(config);
(function ()
{
PublicKeyRing.fromObj(pkr);
}
).should.throw('bad data format: Did you use .toObj()?');
});
it('#toObj #fromObj with nickname', function() {
var config = {