resque-slack
Version:
Trigger Slack notifications on job events.
41 lines (33 loc) • 1.05 kB
JavaScript
var should = require('should');
var sinon = require('sinon');
var ResqueSlack = require('..');
describe('ResqueSlack', function() {
var hooks = ['before_enqueue', 'after_enqueue', 'before_perform', 'after_perform'];
var sandbox, runHook, notify, rs;
beforeEach(function() {
sandbox = sinon.sandbox.create();
runHook = sandbox.stub(ResqueSlack.prototype, 'runHook');
runHook.yieldsAsync(null, true);
notify = sandbox.stub(ResqueSlack.prototype, 'notify');
notify.yieldsAsync(null, true);
rs = new ResqueSlack(1,2,3,4,5,{before_perform: true});
});
afterEach(function() {
sandbox.restore();
});
hooks.forEach(function(hook) {
it('#'+hook, function(done) {
rs[hook](function() {
runHook.getCall(0).args[0].should.eql(hook);
return done();
});
});
});
it('#runHook', function(done) {
runHook.restore();
rs.runHook('before_perform', function() {
notify.getCall(0).args[0].should.eql('About to perform job:');
return done();
});
});
});