thelounge/test/util.js
Jérémie Astori a13c08a45b
Enforce correct order for previews on server-side prefectch rather than at client parsing
This has the benefit of not adding `.preview` divs everywhere, anytime we use `parse()`, and also to un-tie the position of the preview blocks from the result of the helper. This means that templates that call `parse` and have some extra markup after that are not constrained anymore.

This is effectively an alternative, better way to fix https://github.com/thelounge/lounge/issues/1343, but the initial fix that was put in place (https://github.com/thelounge/lounge/pull/1347) is still relevant, for example to make sure a preview stays hidden (and does not add extra margin/padding/etc.) if the link does not prefetch.
2017-07-21 01:06:42 -04:00

47 lines
894 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({
text: "dummy message",
nick: "test-user",
target: "#test-channel",
links: [],
previews: [],
}, opts);
return 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();
}
};