|
|
|
@ -7,27 +7,29 @@ var db = require('./mocks/databasemock');
|
|
|
|
|
var pubsub = require('../src/pubsub');
|
|
|
|
|
|
|
|
|
|
describe('pubsub', function () {
|
|
|
|
|
it('should use singleHostCluster', function (done) {
|
|
|
|
|
var oldValue = nconf.get('singleHostCluster');
|
|
|
|
|
nconf.set('singleHostCluster', true);
|
|
|
|
|
it('should use the plain event emitter', function (done) {
|
|
|
|
|
nconf.set('isCluster', 'false');
|
|
|
|
|
pubsub.reset();
|
|
|
|
|
pubsub.on('testEvent', function (message) {
|
|
|
|
|
assert.equal(message.foo, 1);
|
|
|
|
|
nconf.set('singleHostCluster', oldValue);
|
|
|
|
|
nconf.set('isCluster', 'true');
|
|
|
|
|
pubsub.removeAllListeners('testEvent');
|
|
|
|
|
pubsub.reset();
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
pubsub.publish('testEvent', { foo: 1 });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should use the current database\'s pubsub', function (done) {
|
|
|
|
|
it('should use singleHostCluster', function (done) {
|
|
|
|
|
var oldValue = nconf.get('singleHostCluster');
|
|
|
|
|
nconf.set('singleHostCluster', false);
|
|
|
|
|
nconf.set('singleHostCluster', true);
|
|
|
|
|
pubsub.on('testEvent', function (message) {
|
|
|
|
|
assert.equal(message.foo, 1);
|
|
|
|
|
assert.equal(message.foo, 2);
|
|
|
|
|
nconf.set('singleHostCluster', oldValue);
|
|
|
|
|
pubsub.removeAllListeners('testEvent');
|
|
|
|
|
pubsub.reset();
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
pubsub.publish('testEvent', { foo: 1 });
|
|
|
|
|
pubsub.publish('testEvent', { foo: 2 });
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|