2015-09-30 22:39:57 +00:00
|
|
|
var EventEmitter = require("events").EventEmitter;
|
|
|
|
var util = require("util");
|
|
|
|
var _ = require("lodash");
|
|
|
|
var express = require("express");
|
2016-03-20 14:39:59 +00:00
|
|
|
var Network = require("../src/models/network");
|
2014-11-17 20:14:28 +00:00
|
|
|
|
|
|
|
function MockClient(opts) {
|
2016-03-08 16:01:56 +00:00
|
|
|
this.user = {nick: "test-user"};
|
2014-11-17 20:14:28 +00:00
|
|
|
|
2015-09-30 22:39:57 +00:00
|
|
|
for (var k in opts) {
|
|
|
|
this[k] = opts[k];
|
|
|
|
}
|
2014-11-17 20:14:28 +00:00
|
|
|
}
|
|
|
|
util.inherits(MockClient, EventEmitter);
|
|
|
|
|
|
|
|
MockClient.prototype.createMessage = function(opts) {
|
2015-09-30 22:39:57 +00:00
|
|
|
var message = _.extend({
|
2016-03-15 09:59:36 +00:00
|
|
|
message: "dummy message",
|
2016-03-08 16:01:56 +00:00
|
|
|
nick: "test-user",
|
|
|
|
target: "#test-channel"
|
2015-09-30 22:39:57 +00:00
|
|
|
}, opts);
|
2014-11-17 20:14:28 +00:00
|
|
|
|
2016-03-08 16:01:56 +00:00
|
|
|
this.emit("privmsg", message);
|
2015-09-30 22:39:57 +00:00
|
|
|
};
|
2014-11-17 20:14:28 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2015-09-30 22:39:57 +00:00
|
|
|
createClient: function() {
|
|
|
|
return new MockClient();
|
|
|
|
},
|
|
|
|
createNetwork: function() {
|
2016-03-20 14:39:59 +00:00
|
|
|
return new Network({
|
|
|
|
host: "example.com",
|
2015-09-30 22:39:57 +00:00
|
|
|
channels: [{
|
2016-03-08 16:01:56 +00:00
|
|
|
name: "#test-channel",
|
2015-09-30 22:39:57 +00:00
|
|
|
messages: []
|
|
|
|
}]
|
2016-03-20 14:39:59 +00:00
|
|
|
});
|
2015-09-30 22:39:57 +00:00
|
|
|
},
|
|
|
|
createWebserver: function() {
|
|
|
|
return express();
|
|
|
|
}
|
|
|
|
};
|