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

Function stubWorkOS

apps/cloud/src/admin/admin-users-email.node.test.ts:29–70  ·  view source on GitHub ↗
(calls: string[], unreadableUserIds: ReadonlySet<string>)

Source from the content-addressed store, hash-verified

27] as const;
28
29const stubWorkOS = (calls: string[], unreadableUserIds: ReadonlySet<string>) =>
30 Layer.succeed(
31 WorkOSClient,
32 new Proxy({} as WorkOSClientService, {
33 get: (_target, prop) => {
34 if (prop === "listUsers") {
35 return (params: { email: string; organizationId: string }) => {
36 calls.push(`listUsers:${params.organizationId}:${params.email}`);
37 return Effect.succeed({
38 data: DIRECTORY.filter(
39 (user) =>
40 user.organizationId === params.organizationId &&
41 user.email?.toLowerCase() === params.email,
42 ),
43 });
44 };
45 }
46 if (prop === "listOrgMembers") {
47 return (organizationId: string) => {
48 calls.push(`listOrgMembers:${organizationId}`);
49 return Effect.succeed({
50 data: DIRECTORY.filter((user) => user.organizationId === organizationId).map(
51 (user) => ({ userId: user.id, organizationId }),
52 ),
53 });
54 };
55 }
56 if (prop === "getUser") {
57 return (userId: string) => {
58 calls.push(`getUser:${userId}`);
59 if (unreadableUserIds.has(userId)) {
60 return Effect.fail(new WorkOSUnavailable({ userId }));
61 }
62 const user = DIRECTORY.find((candidate) => candidate.id === userId);
63 if (!user) return Effect.die(`unexpected user ${userId}`);
64 return Effect.succeed(user);
65 };
66 }
67 return () => Effect.die(`unexpected WorkOSClient.${String(prop)} call`);
68 },
69 }),
70 );
71
72const resolve = (
73 email: string,

Callers 1

resolveFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected