Skip to content

Commit

Permalink
add test for group invite
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabez committed Sep 29, 2024
1 parent faea616 commit 2a178c6
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/fixtures/groups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { GroupResponseType } from "../../src/typeDefinitions/group.types";

export const groups: GroupResponseType = {
message: "Roles fetched successfully!",
groups: [
{
id: "27EdauP9UmxCTgAMDPpl",
date: {
_seconds: 1719334613,
_nanoseconds: 934000000,
},
createdBy: "zXQpimWaGWOFF2sLyrFt",
rolename: "group-testing 3",
roleid: "1255205109340573782",
description: "for testing",
memberCount: 0,
isMember: false,
},
{
id: "ELjCeNZxhHupn8qU5pWI",
date: {
_seconds: 1718771669,
_nanoseconds: 27000000,
},
createdBy: "zXQpimWaGWOFF2sLyrFt",
rolename: "group-testing",
roleid: "1252843931306164298",
description: "for testing",
memberCount: 0,
isMember: false,
},
{
id: "tO4vZe5CC690yOb9Txlh",
date: {
_seconds: 1718771969,
_nanoseconds: 680000000,
},
createdBy: "zXQpimWaGWOFF2sLyrFt",
rolename: "group-testinge",
roleid: "1252845191472087050",
description: "",
memberCount: 0,
isMember: false,
},
],
};
23 changes: 23 additions & 0 deletions tests/unit/handlers/groupInvite.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { groupInvite } from "../../../src/controllers/groupInvite";
import { groups } from "../../fixtures/groups";
import { environment } from "../../fixtures/config";
import * as fetchDiscordGroup from "../../../src/utils/fetchDiscordGroups";
import JSONResponse from "../../../src/utils/JsonResponse";

describe("Test /group-invite command", () => {
beforeEach(() => {
jest
.spyOn(fetchDiscordGroup, "fetchDiscordGroups")
.mockImplementation(() => Promise.resolve(new JSONResponse(groups)));
});

it("Should be an instance of JSONResponse", async () => {
const response = await groupInvite(
"1",
groups.groups[0].roleid,
environment[0]
);

expect(response).toBe(JSONResponse);
});
});

0 comments on commit 2a178c6

Please sign in to comment.