You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Use grapheme-splitter instead of lodash for saving emoji from being ripped apart (#10976)
* Use grapheme-splitter instead of lodash for saving emoji from being ripped apart * Move to a more appropriate place * Add tests and improve types
This commit is contained in:
committed by
GitHub
parent
277a3c0146
commit
f4a265b2c7
@ -19,7 +19,7 @@ import { mocked } from "jest-mock";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { IContent } from "matrix-js-sdk/src/models/event";
|
||||
|
||||
import { bodyToHtml, topicToHtml } from "../src/HtmlUtils";
|
||||
import { bodyToHtml, formatEmojis, topicToHtml } from "../src/HtmlUtils";
|
||||
import SettingsStore from "../src/settings/SettingsStore";
|
||||
|
||||
jest.mock("../src/settings/SettingsStore");
|
||||
@ -168,3 +168,19 @@ describe("bodyToHtml", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("formatEmojis", () => {
|
||||
it.each([
|
||||
["🏴", [["🏴", "flag-england"]]],
|
||||
["🏴", [["🏴", "flag-scotland"]]],
|
||||
["🏴", [["🏴", "flag-wales"]]],
|
||||
])("%s emoji", (emoji, expectations) => {
|
||||
const res = formatEmojis(emoji, false);
|
||||
expect(res).toHaveLength(expectations.length);
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const [emoji, title] = expectations[i];
|
||||
expect(res[i].props.children).toEqual(emoji);
|
||||
expect(res[i].props.title).toEqual(`:${title}:`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user