1import { describe, expect, it } from "vite-plus/test";
2
3import { searchComposerEmoji } from "./composerEmojiSearch";
4
5describe("composer emoji search", () => {
6 it("puts the exact shortcode ahead of longer matching names", () => {
7 const matches = searchComposerEmoji("dizzy");
8 expect(matches[0]).toMatchObject({ type: "emoji", emoji: "💫", label: ":dizzy:" });
9 expect(matches.some((entry) => entry.label === ":dizzy_face:")).toBe(true);
10 });
11
12 it("finds canonical aliases, tags, descriptions, and multi-codepoint emoji", () => {
13 expect(searchComposerEmoji("+1")[0]).toMatchObject({ emoji: "👍", label: ":+1:" });
14 expect(searchComposerEmoji("happy").length).toBeGreaterThan(0);
15 expect(searchComposerEmoji("rainbow_flag")[0]).toMatchObject({ emoji: "🏳️‍🌈" });
16 expect(
17 searchComposerEmoji("scientist").some((entry) => entry.label === ":woman_scientist:"),
18 ).toBe(true);
19 });
20
21 it("normalizes uppercase, caps broad searches, and keeps emoji results unique", () => {
22 const matches = searchComposerEmoji("a");
23 expect(matches).toHaveLength(30);
24 expect(new Set(matches.map((entry) => entry.id)).size).toBe(matches.length);
25 expect(searchComposerEmoji("DIZZY")).toEqual(searchComposerEmoji("dizzy"));
26 expect(searchComposerEmoji("")).toEqual([]);
27 expect(searchComposerEmoji("no_such_emoji_999")).toEqual([]);
28 });
29});