starting Address idiom changes
This commit is contained in:
parent
73ceb2e04e
commit
ad34fd191d
|
@ -10,10 +10,12 @@ Address.parent = parent;
|
|||
parent.applyEncodingsTo(Address);
|
||||
|
||||
Address.prototype.validate = function() {
|
||||
var answer;
|
||||
this.doAsBinary(function() {
|
||||
Address.super(this, 'validate', arguments);
|
||||
if(this.data.length !== 21) throw new Error('invalid data length');
|
||||
answer = (this.data.length === 21);
|
||||
});
|
||||
return answer;
|
||||
};
|
||||
|
||||
module.exports = require('soop')(Address);
|
||||
|
|
|
@ -26,7 +26,11 @@ describe('Address', function() {
|
|||
var b = new Address('11111111111111111111111111122222234');
|
||||
a.validate.bind(a).should.not.throw(Error);
|
||||
m.validate.bind(m).should.not.throw(Error);
|
||||
b.validate.bind(b).should.throw(Error);
|
||||
b.validate.bind(b).should.not.throw(Error);
|
||||
|
||||
a.validate().should.equal(true);
|
||||
m.validate().should.equal(true);
|
||||
b.validate().should.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue