From 61be74e3d45f6df0d960bf0f829985279f674aab Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 30 Jun 2017 12:18:31 -0500 Subject: [PATCH] Test with taking an argument and not --- lib/robot.js | 2 +- test/robot.js | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/robot.js b/lib/robot.js index fafac741bb..ec72688786 100644 --- a/lib/robot.js +++ b/lib/robot.js @@ -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; diff --git a/test/robot.js b/test/robot.js index 37ed3614d7..2f2225c2c2 100644 --- a/test/robot.js +++ b/test/robot.js @@ -8,7 +8,7 @@ describe('Robot', function () { let spy; beforeEach(function () { - robot = createRobot({}); + robot = createRobot(); robot.auth = () => {}; event = { @@ -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);