Cotton code
29 lines · 1.5 KB · TypeScriptRaw
/** * RULE (COMMS WITHOUT MAIL, mail CONTRACT row 21): Comms' kit stops listing the mail tables, because Cotton Post * reads them. Nothing of his mail is put at risk by that: every mail table is still in the personal kit every object * holds whole, and the owner's erase act (src/erase.ts `keptTables`) still refuses each of them, now as Post's kit's. */import { describe, expect, it } from "vitest";import { keptTables } from "../src/erase.ts";import { KITS, PERSONAL } from "../src/kits.ts";const MAIL = ["email_thread", "email", "email_sender", "email_participant", "email_draft", "mail_history", "email_account", "email_cut", "email_bin_cut", "email_read_cut"];describe("Comms without mail", () => {  it("lists no mail table in Comms' kit, and every one stays in the personal kit and in Post's", () => {    const ids = (kit: string) => (KITS[kit]?.tables ?? []).map((t) => String(t.id));    for (const table of MAIL) {      expect(ids("messages"), table).not.toContain(table);      expect(ids("mail"), table).toContain(table);      expect(PERSONAL.tables.map((t) => String(t.id)), table).toContain(table);    }    // What Comms still draws stays: the outbox (WhatsApp sends through it) and a sender's merge.    expect(ids("messages")).toEqual(expect.arrayContaining(["thread", "message", "outbox", "sender_merge"]));  });  it("still refuses to erase any mail table: each is kept as a kept app's", () => {    const kept = keptTables();    for (const table of MAIL) expect(kept.get(table), table).toBeTruthy();  });});