diff options
Diffstat (limited to 'apps/web/src/lib/stickers/__tests__')
| -rw-r--r-- | apps/web/src/lib/stickers/__tests__/sticker-id.test.ts | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/web/src/lib/stickers/__tests__/sticker-id.test.ts b/apps/web/src/lib/stickers/__tests__/sticker-id.test.ts new file mode 100644 index 00000000..573dc251 --- /dev/null +++ b/apps/web/src/lib/stickers/__tests__/sticker-id.test.ts @@ -0,0 +1,34 @@ +import { describe, expect, test } from "bun:test"; +import { buildStickerId, parseStickerId } from "../sticker-id"; + +describe("sticker-id strict mode", () => { + test("parses provider-prefixed IDs", () => { + expect(parseStickerId({ stickerId: "icons:mdi:home" })).toEqual({ + providerId: "icons", + providerValue: "mdi:home", + }); + expect(parseStickerId({ stickerId: "emoji:noto:grinning-face" })).toEqual({ + providerId: "emoji", + providerValue: "noto:grinning-face", + }); + }); + + test("throws for IDs without provider prefix", () => { + expect(() => parseStickerId({ stickerId: "home" })).toThrow(); + }); + + test("throws for malformed IDs", () => { + expect(() => parseStickerId({ stickerId: "" })).toThrow(); + expect(() => parseStickerId({ stickerId: "icons:" })).toThrow(); + expect(() => parseStickerId({ stickerId: ":mdi:home" })).toThrow(); + }); + + test("builds sticker IDs unchanged", () => { + expect( + buildStickerId({ + providerId: "flags", + providerValue: "US", + }), + ).toBe("flags:US"); + }); +}); |
