2017-03-18 08:18:47 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const expect = require("chai").expect;
|
|
|
|
const merge = require("../../../../../../client/js/libs/handlebars/ircmessageparser/merge");
|
|
|
|
|
|
|
|
describe("merge", () => {
|
|
|
|
it("should split style information", () => {
|
|
|
|
const textParts = [{
|
|
|
|
start: 0,
|
|
|
|
end: 10,
|
2017-11-15 06:35:15 +00:00
|
|
|
flag1: true,
|
2017-03-18 08:18:47 +00:00
|
|
|
}, {
|
|
|
|
start: 10,
|
|
|
|
end: 20,
|
2017-11-15 06:35:15 +00:00
|
|
|
flag2: true,
|
2017-03-18 08:18:47 +00:00
|
|
|
}];
|
|
|
|
const styleFragments = [{
|
|
|
|
start: 0,
|
|
|
|
end: 5,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "01234",
|
2017-03-18 08:18:47 +00:00
|
|
|
}, {
|
|
|
|
start: 5,
|
|
|
|
end: 15,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "5678901234",
|
2017-03-18 08:18:47 +00:00
|
|
|
}, {
|
|
|
|
start: 15,
|
|
|
|
end: 20,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "56789",
|
2017-03-18 08:18:47 +00:00
|
|
|
}];
|
|
|
|
|
|
|
|
const expected = [{
|
|
|
|
start: 0,
|
|
|
|
end: 10,
|
|
|
|
flag1: true,
|
|
|
|
fragments: [{
|
|
|
|
start: 0,
|
|
|
|
end: 5,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "01234",
|
2017-03-18 08:18:47 +00:00
|
|
|
}, {
|
|
|
|
start: 5,
|
|
|
|
end: 10,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "56789",
|
|
|
|
}],
|
2017-03-18 08:18:47 +00:00
|
|
|
}, {
|
|
|
|
start: 10,
|
|
|
|
end: 20,
|
|
|
|
flag2: true,
|
|
|
|
fragments: [{
|
|
|
|
start: 10,
|
|
|
|
end: 15,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "01234",
|
2017-03-18 08:18:47 +00:00
|
|
|
}, {
|
|
|
|
start: 15,
|
|
|
|
end: 20,
|
2017-11-15 06:35:15 +00:00
|
|
|
text: "56789",
|
|
|
|
}],
|
2017-03-18 08:18:47 +00:00
|
|
|
}];
|
|
|
|
|
|
|
|
const actual = merge(textParts, styleFragments);
|
|
|
|
|
|
|
|
expect(actual).to.deep.equal(expected);
|
|
|
|
});
|
|
|
|
});
|