Files
ThreadNet-Web/apps/web/test/unit-tests/components/views/emojipicker/recent-test.tsx
T
Michael TelatynskiandGitHub f0342ddbd2 Add support for m.recent_emoji account data event (#33172)
* Improve types in AccountSettingsHandler

* Add support for `m.recent_emoji` account data event

Maintains read-compatibility with `io.element.recent_emoji`

* Iterate

* Make ts happier

* Improve coverage

* Improve coverage

* Improve coverage
2026-05-26 08:30:02 +00:00

46 lines
1.4 KiB
TypeScript

/*
Copyright 2026 Element Creations Ltd.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import { translateLegacyEmojiData, mergeEmojiData } from "../../../../../src/emojipicker/recent.ts";
describe("recent", () => {
describe("translateLegacyEmojiData", () => {
it("should correctly translate to the new format", () => {
expect(
translateLegacyEmojiData([
["🤩", 1],
["😀", 2],
]),
).toEqual([
{ emoji: "🤩", total: 1 },
{ emoji: "😀", total: 2 },
]);
});
});
describe("mergeEmojiData", () => {
it("should merge given data correctly", () => {
expect(
mergeEmojiData(
[{ emoji: "🤩", total: 1 }],
[
{ emoji: "🤩", total: 2 },
{ emoji: "😀", total: 1 },
],
),
).toEqual([
{ emoji: "🤩", total: 2 },
{ emoji: "😀", total: 1 },
]);
});
it("should handle data2 being undefined", () => {
expect(mergeEmojiData([{ emoji: "🤩", total: 1 }])).toEqual([{ emoji: "🤩", total: 1 }]);
});
});
});