WIP: Change noop to use anonymous function and added tests.

This commit is contained in:
Edgar Silva 2014-07-03 13:42:43 -05:00
parent ed8d6faeee
commit 1eabab6ec9
2 changed files with 19 additions and 5 deletions

View File

@ -66,9 +66,7 @@ Adaptor.prototype.disconnect = function(callback) {
//
// Returns nothing
Adaptor.prototype._noop = function() {
var fnVoid = (function(command) {
this[command] = function() {return null };
}).bind(this);
this.commands.forEach(fnVoid);
this.commands.forEach((function(command) {
this[command] = function() { return null; };
}).bind(this));
};

View File

@ -72,4 +72,20 @@ describe("Adaptor", function() {
expect(callback).to.be.called;
})
});
describe("#_noop", function() {
before(function() {
adaptor.commands = ['write', 'read'];
adaptor._noop();
adaptor.write = spy();
adaptor.read = spy();
});
it("adaptor commands return null", function() {
var string = "Disconnecting from adaptor 'adaptor'.";
expect(adaptor.write).to.have.returned(null);
expect(adaptor.read).to.have.returned(null);
});
});
});