From f50669dfa3c0a1ae093d3d4b1869f95ea401cc69 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 28 Apr 2026 12:15:11 +0100 Subject: [PATCH] Iterate --- apps/web/src/emojipicker/recent.ts | 2 +- .../views/emojipicker/EmojiPicker-test.tsx | 23 +++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/apps/web/src/emojipicker/recent.ts b/apps/web/src/emojipicker/recent.ts index 09d88b0aa3..a7a4242137 100644 --- a/apps/web/src/emojipicker/recent.ts +++ b/apps/web/src/emojipicker/recent.ts @@ -73,6 +73,6 @@ export function get(limit = 24): string[] { const recents = getRecentEmoji(); // perform a stable sort on `count` to keep the recent (date) order as a secondary sort factor - const sorted = orderBy(recents, "1", "desc"); + const sorted = orderBy(recents, "total", "desc"); return sorted.slice(0, limit).map(({ emoji }) => emoji); } diff --git a/apps/web/test/unit-tests/components/views/emojipicker/EmojiPicker-test.tsx b/apps/web/test/unit-tests/components/views/emojipicker/EmojiPicker-test.tsx index 951e17ce66..98be5bf503 100644 --- a/apps/web/test/unit-tests/components/views/emojipicker/EmojiPicker-test.tsx +++ b/apps/web/test/unit-tests/components/views/emojipicker/EmojiPicker-test.tsx @@ -13,6 +13,7 @@ import userEvent from "@testing-library/user-event"; import EmojiPicker from "../../../../../src/components/views/emojipicker/EmojiPicker"; import { stubClient } from "../../../../test-utils"; import SettingsStore from "../../../../../src/settings/SettingsStore"; +import { SettingLevel } from "../../../../../src/settings/SettingLevel.ts"; describe("EmojiPicker", function () { stubClient(); @@ -23,10 +24,7 @@ describe("EmojiPicker", function () { beforeEach(() => { // Clear recent emojis to prevent test pollution - jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName) => { - if (settingName === "recent_emoji") return [] as any; - return jest.requireActual("../../../../../src/settings/SettingsStore").default.getValue(settingName); - }); + SettingsStore.reset(); }); afterEach(() => { @@ -98,10 +96,11 @@ describe("EmojiPicker", function () { it("should initialize categories with recent as firstVisible when recent emojis exist", () => { // Mock recent emojis - jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName) => { - if (settingName === "recent_emoji") return ["😀", "🎉", "❤️"] as any; - return jest.requireActual("../../../../../src/settings/SettingsStore").default.getValue(settingName); - }); + SettingsStore.setValue("recent_emoji", null, SettingLevel.ACCOUNT, [ + { emoji: "😀", total: 3 }, + { emoji: "🎉", total: 2 }, + { emoji: "❤️", total: 2 }, + ]); const ref = createRef(); render( false} onFinished={jest.fn()} />); @@ -394,10 +393,10 @@ describe("EmojiPicker", function () { it("check tabindex for recent category when recent emojis exist", async () => { // Mock recent emojis - jest.spyOn(SettingsStore, "getValue").mockImplementation((settingName) => { - if (settingName === "recent_emoji") return ["😀", "🎉"] as any; - return jest.requireActual("../../../../../src/settings/SettingsStore").default.getValue(settingName); - }); + SettingsStore.setValue("recent_emoji", null, SettingLevel.ACCOUNT, [ + { emoji: "😀", total: 3 }, + { emoji: "🎉", total: 2 }, + ]); const { container } = render();