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

Function stubWorkOS

apps/cloud/src/admin/admin-users-email.node.test.ts:43–69  ·  view source on GitHub ↗
(calls: string[])

Source from the content-addressed store, hash-verified

41};
42
43const stubWorkOS = (calls: string[]) =>
44 Layer.succeed(
45 WorkOSClient,
46 new Proxy({} as WorkOSClientService, {
47 get: (_target, prop) => {
48 if (prop === "listOrgMembers") {
49 return (organizationId: string) => {
50 calls.push(`listOrgMembers:${organizationId}`);
51 return Effect.succeed({
52 data: Object.keys(DIRECTORY).map((userId) => ({ userId, organizationId })),
53 });
54 };
55 }
56 if (prop === "getUser") {
57 return (userId: string) => {
58 calls.push(`getUser:${userId}`);
59 const user = DIRECTORY[userId];
60 if (!user) return Effect.die(`unexpected user ${userId}`);
61 return Effect.succeed(user);
62 };
63 }
64 // A resolver that reaches for any other WorkOS call — notably a
65 // `listUsers` the emulator cannot serve — is the failure this catches.
66 return () => Effect.die(`unexpected WorkOSClient.${String(prop)} call`);
67 },
68 }),
69 );
70
71const resolve = (email: string, calls: string[]) =>
72 Effect.gen(function* () {

Callers 1

resolveFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected