Buckets:
| /** | |
| * Unit tests for moderation.ts | |
| * Run with: bun test lib/moderation.test.ts | |
| */ | |
| import { describe, expect, test } from "bun:test"; | |
| import { isLikelyUserId, parseListFlags } from "./moderation"; | |
| describe("moderation list flag parsing", () => { | |
| test("uses defaults when no flags are present", () => { | |
| const parsed = parseListFlags([]); | |
| expect(parsed.json).toBe(false); | |
| expect(parsed.limit).toBe(50); | |
| }); | |
| test("parses --json and --limit", () => { | |
| const parsed = parseListFlags(["--json", "--limit", "25"]); | |
| expect(parsed.json).toBe(true); | |
| expect(parsed.limit).toBe(25); | |
| }); | |
| test("clamps invalid limit to minimum 1", () => { | |
| const parsed = parseListFlags(["--limit", "0"]); | |
| expect(parsed.limit).toBe(1); | |
| }); | |
| }); | |
| describe("moderation user id detection", () => { | |
| test("detects numeric IDs", () => { | |
| expect(isLikelyUserId("2244994945")).toBe(true); | |
| }); | |
| test("does not treat usernames as IDs", () => { | |
| expect(isLikelyUserId("jack")).toBe(false); | |
| expect(isLikelyUserId("@jack")).toBe(false); | |
| }); | |
| }); | |
Xet Storage Details
- Size:
- 1.07 kB
- Xet hash:
- 29d383f7a4b1ffc4fe99ebd0122a4e555b69fd3745c07d07458dc4f2e3a40b81
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.