Menu
Public repository / 0216cf0f6008aae88a648a82e9b3a462a6688302
AkurAI-Mail / src/lib/webmail/filters.test.ts
Latest change 22202d1bde69be4ace8a299dffd91f8ff24378df - Recover deployed webmail frontend (frontend parity with EC2 a6afffc) by Ólafur Búi Ólafsson
import { describe, expect, test } from "bun:test";
import { filterParams, isPlainView, mailboxCacheKey } from "./filters";
describe("filters", () => {
test("smart mailboxes and chips both set query flags", () => {
expect(filterParams("today", new Set(["unread", "contacts"]))).toEqual({
unread: "true", flagged: "false", attachment: "false", today: "true", vip: "false", contacts: "true", priority: "false",
});
expect(filterParams("flagged", new Set()).flagged).toBe("true");
});
test("only unfiltered first pages are cached", () => {
expect(isPlainView("", "", "", new Set())).toBe(true);
expect(isPlainView("q", "", "", new Set())).toBe(false);
expect(isPlainView("", "c", "", new Set())).toBe(false);
expect(isPlainView("", "", "vip", new Set())).toBe(false);
expect(isPlainView("", "", "", new Set(["unread"]))).toBe(false);
});
test("cache key is per mailbox and folder", () => {
expect(mailboxCacheKey("a@x.is", "Inbox")).toBe("akurai-webmail-cache:a@x.is:Inbox");
expect(mailboxCacheKey("", "Sent")).toBe("akurai-webmail-cache:default:Sent");
});
});