MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / sourceOf

Function sourceOf

apps/cloud/src/auth/v2-import.test.ts:28–50  ·  view source on GitHub ↗
(facts: Facts)

Source from the content-addressed store, hash-verified

26
27/** A source answering from fixed facts, recording which reads were made. */
28const sourceOf = (facts: Facts) => {
29 const reads: string[] = [];
30 const answer = <A>(read: string, value: A) =>
31 Effect.suspend(() => {
32 reads.push(read);
33 return facts.failing === read ? Effect.fail("unavailable") : Effect.succeed(value);
34 });
35 const source: V2ImportSource = {
36 emailVerified: (userId) => {
37 expect(userId).toBe(USER);
38 return answer("user", facts.emailVerified ?? true);
39 },
40 activeMemberIds: (organizationId) => {
41 expect(organizationId).toBe(ORG);
42 return answer("members", facts.members ?? [USER]);
43 },
44 subscriptions: (organizationId) => {
45 expect(organizationId).toBe(ORG);
46 return answer("billing", facts.subscriptions ?? [{ planId: "free", status: "active" }]);
47 },
48 };
49 return { source, reads };
50};
51
52describe("v2 import eligibility", () => {
53 it.effect("admits a verified user who is the free org's only active member", () =>

Callers 1

v2-import.test.tsFile · 0.70

Calls 1

answerFunction · 0.70

Tested by

no test coverage detected