mirror of
https://github.com/thelounge/thelounge
synced 2024-12-24 11:23:07 +00:00
03e3444a35
- Add comments and descriptions to: - `findChannels.js` - `parseStyle` - `findLinks` - `fill` - `anyIntersection` - `merge` - `parse` - Minor optimizations to `parseStyle` - Add tests for `fill`
50 lines
1 KiB
JavaScript
50 lines
1 KiB
JavaScript
"use strict";
|
|
|
|
const expect = require("chai").expect;
|
|
const fill = require("../../../../../../client/js/libs/handlebars/ircmessageparser/fill");
|
|
|
|
describe("fill", () => {
|
|
const text = "01234567890123456789";
|
|
|
|
it("should return an entry for the unmatched end of string", () => {
|
|
const existingEntries = [
|
|
{start: 0, end: 10},
|
|
{start: 5, end: 15},
|
|
];
|
|
|
|
const expected = [
|
|
{start: 15, end: 20},
|
|
];
|
|
|
|
const actual = fill(existingEntries, text);
|
|
|
|
expect(actual).to.deep.equal(expected);
|
|
});
|
|
|
|
it("should return an entry per unmatched areas of the text", () => {
|
|
const existingEntries = [
|
|
{start: 0, end: 5},
|
|
{start: 10, end: 15},
|
|
];
|
|
|
|
const expected = [
|
|
{start: 5, end: 10},
|
|
{start: 15, end: 20},
|
|
];
|
|
|
|
const actual = fill(existingEntries, text);
|
|
|
|
expect(actual).to.deep.equal(expected);
|
|
});
|
|
|
|
it("should not return anything when entries match all text", () => {
|
|
const existingEntries = [
|
|
{start: 0, end: 10},
|
|
{start: 10, end: 20},
|
|
];
|
|
|
|
const actual = fill(existingEntries, text);
|
|
|
|
expect(actual).to.be.empty;
|
|
});
|
|
});
|