fix: noop if no slack flagging url is passed in

This commit is contained in:
Blade Barringer
2016-08-26 23:09:54 -05:00
parent 2180cb3d98
commit 41851afe5f
2 changed files with 30 additions and 1 deletions

View File

@@ -1,7 +1,10 @@
/* eslint-disable camelcase */
import { IncomingWebhook } from '@slack/client';
import requireAgain from 'require-again';
import slack from '../../../../../website/server/libs/slack';
import logger from '../../../../../website/server/libs/logger';
import { TAVERN_ID } from '../../../../../website/server/models/group';
import nconf from 'nconf';
describe('slack', () => {
describe('sendFlagNotification', () => {
@@ -93,5 +96,21 @@ describe('slack', () => {
})],
});
});
it('noops if no flagging url is provided', () => {
sandbox.stub(nconf, 'get').withArgs('SLACK:FLAGGING_URL').returns('');
sandbox.stub(logger, 'error');
let reRequiredSlack = requireAgain('../../../../../website/server/libs/slack');
expect(logger.error).to.be.calledOnce;
reRequiredSlack.sendFlagNotification({
flagger,
group,
message,
});
expect(IncomingWebhook.prototype.send).to.not.be.called;
});
});
});