hardlounge/test/client/js/helpers/ircmessageparser/findEmoji.js

67 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-08-23 14:34:20 +00:00
"use strict";
const expect = require("chai").expect;
2019-11-21 09:11:06 +00:00
const findEmoji = require("../../../../../client/js/helpers/ircmessageparser/findEmoji").default;
2017-08-23 14:34:20 +00:00
describe("findEmoji", () => {
it("should find default emoji presentation character", () => {
const input = "test \u{231A} test";
2019-07-17 09:33:59 +00:00
const expected = [
{
start: 5,
end: 6,
emoji: "\u{231A}",
},
];
2017-08-23 14:34:20 +00:00
const actual = findEmoji(input);
expect(actual).to.deep.equal(expected);
});
it("should find default text presentation character rendered as emoji", () => {
const input = "test \u{2194}\u{FE0F} test";
2019-07-17 09:33:59 +00:00
const expected = [
{
start: 5,
end: 7,
emoji: "\u{2194}\u{FE0F}",
},
];
2017-08-23 14:34:20 +00:00
const actual = findEmoji(input);
expect(actual).to.deep.equal(expected);
});
it("should find emoji modifier base", () => {
const input = "test\u{1F469}test";
2019-07-17 09:33:59 +00:00
const expected = [
{
start: 4,
end: 6,
emoji: "\u{1F469}",
},
];
2017-08-23 14:34:20 +00:00
const actual = findEmoji(input);
expect(actual).to.deep.equal(expected);
});
it("should find emoji modifier base followed by a modifier", () => {
const input = "test\u{1F469}\u{1F3FF}test";
2019-07-17 09:33:59 +00:00
const expected = [
{
start: 4,
end: 8,
emoji: "\u{1F469}\u{1F3FF}",
},
];
2017-08-23 14:34:20 +00:00
const actual = findEmoji(input);
expect(actual).to.deep.equal(expected);
});
});