CartoDB-SQL-API/test/unit/batch/job_publisher.js

28 lines
884 B
JavaScript
Raw Normal View History

2016-01-23 02:31:25 +08:00
var JobPublisher = require('../../../batch/job_publisher');
var assert = require('assert');
describe('batch API job publisher', function () {
beforeEach(function () {
var self = this;
this.host = 'irrelevantHost';
this.redis = {
createClient: function () {
return this;
},
publish: function () {
var isValidFirstArg = arguments[0] === 'batch:hosts';
var isValidSecondArg = arguments[1] === self.host;
self.redis.publishIsCalledWithValidArgs = isValidFirstArg && isValidSecondArg;
}
};
this.jobPublisher = new JobPublisher(this.redis);
});
it('.publish() should publish new messages', function () {
this.jobPublisher.publish(this.host);
assert.ok(this.redis.publishIsCalledWithValidArgs);
});
});