Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
import { describe, expect, it, vi } from "vitest";
import {
handleEmojiReaction,
REACTIONS,
} from "@/app/s/[videoId]/_components/toolbar-reactions";
describe("toolbar reactions", () => {
it("exposes the standard reaction set in display order", () => {
expect(REACTIONS).toEqual([
{ emoji: "๐", label: "joy" },
{ emoji: "๐", label: "love" },
{ emoji: "๐ฎ", label: "wow" },
{ emoji: "๐", label: "yay" },
{ emoji: "๐", label: "up" },
{ emoji: "๐", label: "down" },
]);
});
it("prompts sign-in overlay when unauthenticated viewer reacts", () => {
const onRequireAuth = vi.fn();
const onReact = vi.fn();
handleEmojiReaction({
emoji: "๐",
canReact: true,
user: null,
onRequireAuth,
onReact,
});
expect(onRequireAuth).toHaveBeenCalledOnce();
expect(onReact).not.toHaveBeenCalled();
});
it("prompts sign-in overlay when user is undefined", () => {
const onRequireAuth = vi.fn();
const onReact = vi.fn();
handleEmojiReaction({
emoji: "๐",
canReact: true,
user: undefined,
onRequireAuth,
onReact,
});
expect(onRequireAuth).toHaveBeenCalledOnce();
expect(onReact).not.toHaveBeenCalled();
});
it("suppresses interaction when reactions are disabled", () => {
const onRequireAuth = vi.fn();
const onReact = vi.fn();
handleEmojiReaction({
emoji: "๐",
canReact: false,
user: null,
onRequireAuth,
onReact,
});
expect(onRequireAuth).not.toHaveBeenCalled();
expect(onReact).not.toHaveBeenCalled();
});
it("submits reaction when viewer is signed in", () => {
const onRequireAuth = vi.fn();
const onReact = vi.fn();
handleEmojiReaction({
emoji: "๐",
canReact: true,
user: { id: "user-123" },
onRequireAuth,
onReact,
});
expect(onRequireAuth).not.toHaveBeenCalled();
expect(onReact).toHaveBeenCalledOnce();
expect(onReact).toHaveBeenCalledWith("๐", { id: "user-123" });
});
});