Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { describe, expect, it } from "vitest";
import { normalizeReaction, reactionAnswer, REACTIONS } from "./reactions.ts";
describe("reactions", () => {
it("reads π as yes and π as no, and nothing else as an answer", () => {
expect(reactionAnswer("π")).toBe("yes");
expect(reactionAnswer("π")).toBe("no");
for (const feeling of REACTIONS.filter((emoji) => emoji !== "π" && emoji !== "π")) expect(reactionAnswer(feeling)).toBeNull();
expect(reactionAnswer(undefined)).toBeNull();
expect(reactionAnswer(null)).toBeNull();
});
it("takes each offered emoji as itself", () => {
for (const emoji of REACTIONS) expect(normalizeReaction(emoji)).toBe(emoji);
});
it("takes the same emoji however a platform spells it", () => {
expect(normalizeReaction("ππ½")).toBe("π");
expect(normalizeReaction("ππΏ")).toBe("π");
expect(normalizeReaction("β€")).toBe("β€οΈ");
expect(normalizeReaction(" π ")).toBe("π");
});
it("takes Slack's names, with or without colons and skin tones", () => {
expect(normalizeReaction("+1")).toBe("π");
expect(normalizeReaction(":thumbsup:")).toBe("π");
expect(normalizeReaction("+1::skin-tone-4")).toBe("π");
expect(normalizeReaction("-1")).toBe("π");
expect(normalizeReaction("thumbsdown")).toBe("π");
expect(normalizeReaction("heart")).toBe("β€οΈ");
expect(normalizeReaction("joy")).toBe("π");
expect(normalizeReaction("tada")).toBe("π");
expect(normalizeReaction("eyes")).toBe("π");
});
it("refuses anything outside the set", () => {
for (const raw of ["π₯", "ππ", "yes", "white_check_mark", "", "__proto__", "constructor", "toString", 1, null, undefined, {}, "π".repeat(40)]) {
expect(normalizeReaction(raw), String(raw)).toBeNull();
}
});
});