Skip to content

Commit 574e35f

Browse files
committed
CodeRabbit's suggestions.
1 parent 04b0657 commit 574e35f

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

test/graphql/types/Organization/creator.test.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ type UserFromDB = {
105105
role: UserRole;
106106
homePhoneNumber: string | null;
107107
workPhoneNumber: string | null;
108-
avatarMimeType: "image/avif" | "image/jpeg" | "image/png" | "image/webp" | null
109-
avatarBase64: string | null;
108+
avatarMimeType:
109+
| "image/avif"
110+
| "image/jpeg"
111+
| "image/png"
112+
| "image/webp"
113+
| null;
114+
avatarBase64: string | null;
110115
educationGrade: string | null;
111116
employmentStatus: string | null;
112117
maritalStatus: string | null;
@@ -223,11 +228,6 @@ const resolveCreator = async (
223228
});
224229
}
225230

226-
// Early return if organization has no creator
227-
if (parent.creatorId === null) {
228-
return null;
229-
}
230-
231231
const currentUserOrganizationMembership =
232232
currentUser.organizationMembershipsWhereMember[0];
233233

@@ -295,7 +295,7 @@ describe("Organization Resolver - Creator Field", () => {
295295
await resolveCreator(
296296
mockOrganization,
297297
{},
298-
testCtx as unknown as ResolverContext,
298+
testCtx, // Ensure createMockContext returns the correct type
299299
);
300300
}).rejects.toThrow(
301301
new TalawaGraphQLError({
@@ -376,24 +376,24 @@ describe("Organization Resolver - Creator Field", () => {
376376
}),
377377
);
378378
});
379-
});
380379

381-
it("should throw unauthorized error if user has no organization membership", async () => {
382-
const mockUser = createCompleteMockUser("regular", []);
383-
ctx.drizzleClient.query.usersTable.findFirst.mockResolvedValueOnce(mockUser);
384-
385-
await expect(async () => {
386-
await resolveCreator(
387-
mockOrganization,
388-
{},
389-
ctx as unknown as ResolverContext,
390-
);
391-
}).rejects.toThrow(
392-
new TalawaGraphQLError({
393-
extensions: { code: "unauthorized_action" },
394-
}),
395-
);
396-
});
380+
it("should throw unauthorized error if user has no organization membership", async () => {
381+
const mockUser = createCompleteMockUser("regular", []);
382+
ctx.drizzleClient.query.usersTable.findFirst.mockResolvedValueOnce(mockUser);
383+
384+
await expect(async () => {
385+
await resolveCreator(
386+
mockOrganization,
387+
{},
388+
ctx as unknown as ResolverContext,
389+
);
390+
}).rejects.toThrow(
391+
new TalawaGraphQLError({
392+
extensions: { code: "unauthorized_action" },
393+
}),
394+
);
395+
});
396+
});
397397

398398
describe("Error Handling", () => {
399399
it("should throw unexpected error if creator user is not found", async () => {

0 commit comments

Comments
 (0)