mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
34 lines
962 B
JavaScript
34 lines
962 B
JavaScript
|
|
'use strict';
|
||
|
|
|
||
|
|
var assert = require('assert');
|
||
|
|
var nconf = require('nconf');
|
||
|
|
|
||
|
|
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);
|
||
|
|
pubsub.on('testEvent', function (message) {
|
||
|
|
assert.equal(message.foo, 1);
|
||
|
|
nconf.set('singleHostCluster', oldValue);
|
||
|
|
pubsub.removeAllListeners('testEvent');
|
||
|
|
done();
|
||
|
|
});
|
||
|
|
pubsub.publish('testEvent', { foo: 1 });
|
||
|
|
});
|
||
|
|
|
||
|
|
it('should use the current database\'s pubsub', function (done) {
|
||
|
|
var oldValue = nconf.get('singleHostCluster');
|
||
|
|
nconf.set('singleHostCluster', false);
|
||
|
|
pubsub.on('testEvent', function (message) {
|
||
|
|
assert.equal(message.foo, 1);
|
||
|
|
nconf.set('singleHostCluster', oldValue);
|
||
|
|
pubsub.removeAllListeners('testEvent');
|
||
|
|
done();
|
||
|
|
});
|
||
|
|
pubsub.publish('testEvent', { foo: 1 });
|
||
|
|
});
|
||
|
|
});
|