2017-07-24 06:01:25 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
|
|
|
|
|
|
|
const Msg = require("../../src/models/msg");
|
|
|
|
|
|
|
|
describe("Msg", function() {
|
|
|
|
describe("#findPreview(link)", function() {
|
|
|
|
const msg = new Msg({
|
|
|
|
previews: [{
|
|
|
|
body: "",
|
|
|
|
head: "Example Domain",
|
|
|
|
link: "https://example.org/",
|
|
|
|
thumb: "",
|
|
|
|
type: "link",
|
|
|
|
shown: true,
|
|
|
|
}, {
|
|
|
|
body: "",
|
|
|
|
head: "The Lounge",
|
|
|
|
link: "https://thelounge.github.io/",
|
|
|
|
thumb: "",
|
|
|
|
type: "link",
|
|
|
|
shown: true,
|
2017-11-15 06:35:15 +00:00
|
|
|
}],
|
2017-07-24 06:01:25 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("should find a preview given an existing link", function() {
|
|
|
|
expect(msg.findPreview("https://thelounge.github.io/").head)
|
|
|
|
.to.equal("The Lounge");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not find a preview that does not exist", function() {
|
|
|
|
expect(msg.findPreview("https://github.com/thelounge/lounge"))
|
|
|
|
.to.be.undefined;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|