import { describe, expect, it } from "vitest"; import { publishedRuleAnalyticsFromDocument, publishedRuleAnalyticsFromState, } from "../../lib/create/publishedRuleAnalytics"; describe("publishedRuleAnalyticsFromDocument", () => { it("reads place and a canonical group type", () => { expect( publishedRuleAnalyticsFromDocument({ communityLocation: " Boulder ", orgType: "mutualAid", }), ).toEqual({ communityLocation: "Boulder", orgType: "mutualAid" }); }); it("drops unknown types and empty place", () => { expect( publishedRuleAnalyticsFromDocument({ communityLocation: " ", orgType: "not-a-kind", }), ).toEqual({ communityLocation: null, orgType: null }); }); }); describe("publishedRuleAnalyticsFromState", () => { it("takes place from the description field and the main group type", () => { expect( publishedRuleAnalyticsFromState({ communityLocation: "Denver", selectedOrganizationTypeIds: ["mutualAid", "nonprofit"], }), ).toEqual({ communityLocation: "Denver", orgType: "mutualAid" }); }); });