import { describe, expect, it } from "vitest"; import { LISTED_PUBLISHED_RULE_WHERE, isListedPublishedRule, } from "../../lib/publishedRuleAccess"; describe("isListedPublishedRule", () => { it("lists owned rules", () => { expect( isListedPublishedRule({ userId: "user-1", claimTokenHash: null }), ).toBe(true); }); it("lists ownerless rows that are not waiting on a guest claim", () => { expect(isListedPublishedRule({ userId: null, claimTokenHash: null })).toBe( true, ); }); it("keeps guest-claim rows unlisted", () => { expect( isListedPublishedRule({ userId: null, claimTokenHash: "claim-hash", }), ).toBe(false); }); }); describe("LISTED_PUBLISHED_RULE_WHERE", () => { it("matches owned rows or rows with no claim token", () => { expect(LISTED_PUBLISHED_RULE_WHERE).toEqual({ OR: [{ userId: { not: null } }, { claimTokenHash: null }], }); }); });