Merge pull request #1197 from matiaspando/tmp

Added a test to PublicKeyRing to increase coverage
This commit is contained in:
Manuel Aráoz 2014-08-27 17:29:35 -03:00
commit dfa383b351
2 changed files with 17 additions and 3 deletions

View file

@ -42,9 +42,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(!(data instanceof PublicKeyRing), 'bad data format: Did you use .toObj()?');
var opts = PublicKeyRing.trim(data);
// Support old indexes schema

View file

@ -434,6 +434,20 @@ 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 = {