Add test for Robot#log

This commit is contained in:
Andrew Stewart 2015-01-20 19:38:46 -08:00
parent 8272efe060
commit 754af3b4db
1 changed files with 23 additions and 1 deletions

View File

@ -3,7 +3,8 @@
var Driver = source("driver"),
Adaptor = source("adaptor"),
Robot = source("robot");
Robot = source("robot"),
Logger = source("logger");
describe("Robot", function() {
var work, extraFunction, robot;
@ -574,4 +575,25 @@ describe("Robot", function() {
expect(robot.toString()).to.be.eql("[Robot name='Robby']");
});
});
describe("#log", function() {
beforeEach(function() {
stub(Logger, "info");
stub(Logger, "fatal");
robot.log("info", "an informative message");
robot.log("fatal", "a fatal error");
});
afterEach(function() {
Logger.info.restore();
Logger.fatal.restore();
});
it("it passes messages onto Logger, with the Robot's name", function() {
var nameStr = "[" + robot.name + "] -";
expect(Logger.info).to.be.calledWith(nameStr, "an informative message");
expect(Logger.fatal).to.be.calledWith(nameStr, "a fatal error");
});
});
});