caa46042bf
Several ES6 additions are only available in strict mode. Example: > SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode Strict mode was also enabled in a few of our files already, and it is a good thing to have anyway.
45 lines
882 B
JavaScript
45 lines
882 B
JavaScript
"use strict";
|
|
|
|
var EventEmitter = require("events").EventEmitter;
|
|
var util = require("util");
|
|
var _ = require("lodash");
|
|
var express = require("express");
|
|
var Network = require("../src/models/network");
|
|
var Chan = require("../src/models/chan");
|
|
|
|
function MockClient(opts) {
|
|
this.user = {nick: "test-user"};
|
|
|
|
for (var k in opts) {
|
|
this[k] = opts[k];
|
|
}
|
|
}
|
|
util.inherits(MockClient, EventEmitter);
|
|
|
|
MockClient.prototype.createMessage = function(opts) {
|
|
var message = _.extend({
|
|
message: "dummy message",
|
|
nick: "test-user",
|
|
target: "#test-channel"
|
|
}, opts);
|
|
|
|
this.emit("privmsg", message);
|
|
};
|
|
|
|
module.exports = {
|
|
createClient: function() {
|
|
return new MockClient();
|
|
},
|
|
createNetwork: function() {
|
|
return new Network({
|
|
host: "example.com",
|
|
channels: [new Chan({
|
|
name: "#test-channel"
|
|
})]
|
|
});
|
|
},
|
|
createWebserver: function() {
|
|
return express();
|
|
}
|
|
};
|