Skip to content

Commit

Permalink
tests: Added test for updateAgendaSection.ts
Browse files Browse the repository at this point in the history
- Added tests for `updateAgendaSection.ts` file to ensure 100% code coverage.

Signed-off-by: Akhilender <akhilenderb9@gmail.com>
  • Loading branch information
akhilender-bongirwar committed Apr 9, 2024
1 parent b6f93cd commit 07851a1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/resolvers/Mutation/updateAgendaSection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
USER_NOT_AUTHORIZED_ERROR,
USER_NOT_FOUND_ERROR,
} from "../../../src/constants";
import { AgendaSectionModel, User } from "../../../src/models";
import { AgendaSectionModel, AppUserProfile, User } from "../../../src/models";
import { connect, disconnect } from "../../helpers/db";
import { beforeAll, afterAll, describe, it, expect, vi } from "vitest";
import { updateAgendaSection } from "../../../src/resolvers/Mutation/updateAgendaSection";
Expand Down Expand Up @@ -137,4 +137,24 @@ describe("resolvers -> Mutation -> updateAgendaSection", () => {

expect(updateAgendaSectionPayload).toBeDefined();
});

it("throws UnauthorizedError if the user does not have an app profile", async () => {
await AppUserProfile.deleteOne({ userId: testAdminUser?._id });

try {
const args: MutationUpdateAgendaSectionArgs = {
id: testAgendaSection._id.toString(),
input: {},
};

const context = {
userId: testAdminUser?._id,
};
await updateAgendaSection?.({}, args, context);
} catch (error: unknown) {
expect((error as Error).message).toEqual(
USER_NOT_AUTHORIZED_ERROR.MESSAGE,
);
}
});
});

0 comments on commit 07851a1

Please sign in to comment.