Files
musicshare/packages/shared/src/reactions.test.ts
T
chrisandClaude Opus 5.5 d2edad4b0d
CI / check (push) Canceled after 0s
Emoji reactions on songs
React to a friend's current song or any of their recent plays: tap an
emoji to add yours (or take it back), "☺+" for the quick six, and a full
picker with search and categories (Unicode emoji up to 13.1, generated
into the shared package so web and mobile match). One reaction per person
per play; a new one replaces the old. Chips show counts and, on hover/
long label, who reacted; yours is highlighted. Listeners and followers get
the update live. Not on your own plays, not across a block (blocking also
clears reactions between the two people).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzFywujuH9TiuXbr9vjoX8
2026-10-06 13:39:26 -04:00

20 lines
1015 B
TypeScript

import { describe, expect, it } from 'vitest';
import { EMOJI_PICKER_GROUPS, QUICK_REACTIONS, isSingleEmoji, searchEmoji } from './reactions';
describe('emoji', () => {
it('has every group and the quick reactions in it', () => {
expect(EMOJI_PICKER_GROUPS.map((g) => g.name)).toContain('Smileys and Emotion');
const all = new Set(EMOJI_PICKER_GROUPS.flatMap((g) => g.emojis.map((e) => e.emoji)));
for (const q of QUICK_REACTIONS) expect(all.has(q)).toBe(true);
});
it('searches by word starts', () => {
expect(searchEmoji('fire').map((e) => e.emoji)).toContain('🔥');
expect(searchEmoji('red hea').map((e) => e.emoji)).toContain('❤️');
expect(searchEmoji(' ')).toEqual([]);
});
it('accepts exactly one emoji', () => {
for (const ok of ['🔥', '❤️', '👍🏽', '👩‍💻', '🇯🇵', '🏳️‍🌈']) expect(isSingleEmoji(ok)).toBe(true);
for (const bad of ['', 'a', '🔥🔥', 'hi 🔥', '<b>', '1']) expect(isSingleEmoji(bad)).toBe(false);
});
});