2022-06-19 00:25:21 +00:00
|
|
|
import {expect} from "chai";
|
|
|
|
import fill from "../../../../../client/js/helpers/ircmessageparser/fill";
|
2017-04-04 04:36:03 +00:00
|
|
|
|
|
|
|
describe("fill", () => {
|
|
|
|
const text = "01234567890123456789";
|
|
|
|
|
|
|
|
it("should return an entry for the unmatched end of string", () => {
|
2019-11-09 08:55:50 +00:00
|
|
|
const existingEntries = [
|
|
|
|
{start: 0, end: 10},
|
|
|
|
{start: 5, end: 15},
|
|
|
|
];
|
2017-04-04 04:36:03 +00:00
|
|
|
|
2019-07-17 09:33:59 +00:00
|
|
|
const expected = [{start: 15, end: 20}];
|
2017-04-04 04:36:03 +00:00
|
|
|
|
|
|
|
const actual = fill(existingEntries, text);
|
|
|
|
|
|
|
|
expect(actual).to.deep.equal(expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return an entry per unmatched areas of the text", () => {
|
2019-11-09 08:55:50 +00:00
|
|
|
const existingEntries = [
|
|
|
|
{start: 0, end: 5},
|
|
|
|
{start: 10, end: 15},
|
|
|
|
];
|
2017-04-04 04:36:03 +00:00
|
|
|
|
2019-11-09 08:55:50 +00:00
|
|
|
const expected = [
|
|
|
|
{start: 5, end: 10},
|
|
|
|
{start: 15, end: 20},
|
|
|
|
];
|
2017-04-04 04:36:03 +00:00
|
|
|
|
|
|
|
const actual = fill(existingEntries, text);
|
|
|
|
|
|
|
|
expect(actual).to.deep.equal(expected);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should not return anything when entries match all text", () => {
|
2019-11-09 08:55:50 +00:00
|
|
|
const existingEntries = [
|
|
|
|
{start: 0, end: 10},
|
|
|
|
{start: 10, end: 20},
|
|
|
|
];
|
2017-04-04 04:36:03 +00:00
|
|
|
|
|
|
|
const actual = fill(existingEntries, text);
|
|
|
|
|
|
|
|
expect(actual).to.be.empty;
|
|
|
|
});
|
|
|
|
});
|