Skip to content

Commit

Permalink
fix(tests): cover start and signal error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Oct 19, 2019
1 parent 317b8b0 commit ac08431
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion test/TestApp.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from 'chai';
import { ineeda } from 'ineeda';
import { defaultTo } from 'lodash';
import { LogLevel } from 'noicejs';
import { BaseError, LogLevel } from 'noicejs';
import { stub } from 'sinon';

import { createBot, CreateOptions, ExitStatus, main, runBot } from '../src/app';
import { Bot, BotDefinition } from '../src/Bot';
Expand Down Expand Up @@ -189,7 +191,17 @@ describeLeaks('app bot stuff', async () => {
.and.been.calledWith(ServiceEvent.Start)
.and.been.calledWith(ServiceEvent.Reload)
.and.been.calledWith(ServiceEvent.Stop);
});

itLeaks('should handle errors starting the bot', async () => {
const start = stub().throws(BaseError);
const bot = ineeda<Bot>({
start,
});
return expect(runBot({
config: TEST_CONFIG,
logger: getTestLogger(),
}, bot)).to.eventually.equal(ExitStatus.Error);
});
});

Expand Down

0 comments on commit ac08431

Please sign in to comment.