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 f5a4077
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/fixtures/groups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
export const groups = {
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,
},
],
};
28 changes: 28 additions & 0 deletions tests/unit/handlers/groupInvite.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import JSONResponse from "../../../src/utils/JsonResponse";
import { groupInvite } from "../../../src/controllers/groupInvite";
import { groups } from "../../fixtures/groups";
import { environment } from "../../fixtures/config";

describe("Test /group-invite command", () => {
beforeEach(() => {
jest.mock("../../src/utils/fetchDiscordGroups", () => ({
fetchDiscordGroups: jest.fn().mockImplementation(() => {
return Promise.resolve({
json: () => Promise.resolve(groups),
status: 200,
ok: true,
});
}),
}));
});

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

0 comments on commit f5a4077

Please sign in to comment.