Skip to content

Commit

Permalink
Test with taking an argument and not
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Jun 30, 2017
1 parent fe876d8 commit 61be74e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/robot.js
Expand Up @@ -9,7 +9,7 @@ const Context = require('./context');
* @property {logger} log - A logger
*/
class Robot {
constructor({app, cache, logger}) {
constructor({app, cache, logger} = {}) {
this.events = new EventEmitter();
this.app = app;
this.cache = cache;
Expand Down
19 changes: 18 additions & 1 deletion test/robot.js
Expand Up @@ -8,7 +8,7 @@ describe('Robot', function () {
let spy;

beforeEach(function () {
robot = createRobot({});
robot = createRobot();
robot.auth = () => {};

event = {
Expand All @@ -22,6 +22,23 @@ describe('Robot', function () {
spy = expect.createSpy();
});

describe('constructor', () => {
it('takes a logger', () => {
const logger = {
trace: expect.createSpy(),
debug: expect.createSpy(),
info: expect.createSpy(),
warn: expect.createSpy(),
error: expect.createSpy(),
fatal: expect.createSpy()
};
robot = createRobot({logger});

robot.log('hello world');
expect(logger.debug).toHaveBeenCalledWith('hello world');
});
});

describe('on', function () {
it('calls callback when no action is specified', async function () {
robot.on('test', spy);
Expand Down

0 comments on commit 61be74e

Please sign in to comment.