import { describe, expect, it } from "vitest"; import { checkCommentContent, normalizeCommentText } from "./moderation"; describe("comment content moderation", () => { it.each(["fuck you", "F U C K", "f.u.c.k", "f\u200buck", "fuck", "sh1t", "b!tch", "ไอ้เหี้ย", "เย็ดแม่", "ควย"])("rejects abusive language: %s", (text) => { expect(() => checkCommentContent(text)).toThrow("comment-abusive-language"); }); it.each(["", "This weapon has classic passive stats", "Scunthorpe", "The boss has an assassin phase", "ทีมนี้ใช้กล้วยได้ไหม", "ขอบคุณสำหรับไกด์ครับ", "https://example.com/guide", "https://a.test https://b.test https://c.test", "ha ha ha", "Crit rate 100%!"])("allows ordinary discussion: %s", (text) => { expect(() => checkCommentContent(text)).not.toThrow(); }); it.each(["https://a.test https://b.test https://c.test https://d.test", "www.a.test www.b.test www.c.test www.d.test", "a".repeat(20), "🔥".repeat(20), "buy now ".repeat(8), "spam ".repeat(8)])("rejects spam: %s", (text) => { expect(() => checkCommentContent(text)).toThrow("comment-spam"); }); it("normalizes casing, whitespace, invisible characters and compatibility forms for duplicates", () => { expect(normalizeCommentText(" Hello\u200b\n WORLD ")).toBe("hello world"); }); it("rejects text containing only invisible characters", () => { expect(() => checkCommentContent("\u200b\u200d")).toThrow("empty-comment"); }); });