thelounge/test/util.js

42 lines
733 B
JavaScript
Raw Normal View History

2015-09-30 22:39:57 +00:00
var EventEmitter = require("events").EventEmitter;
var util = require("util");
var _ = require("lodash");
var express = require("express");
function MockClient(opts) {
2015-09-30 22:39:57 +00:00
this.me = "test-user";
2015-09-30 22:39:57 +00:00
for (var k in opts) {
this[k] = opts[k];
}
}
util.inherits(MockClient, EventEmitter);
MockClient.prototype.createMessage = function(opts) {
2015-09-30 22:39:57 +00:00
var message = _.extend({
message: "dummy message",
from: "test-user",
to: "test-channel"
}, opts);
2015-09-30 22:39:57 +00:00
this.emit("message", message);
};
module.exports = {
2015-09-30 22:39:57 +00:00
createClient: function() {
return new MockClient();
},
createNetwork: function() {
return {
channels: [{
name: "test-channel",
messages: []
}]
};
},
createWebserver: function() {
return express();
}
};