Skip to content

Commit 2a178c6

Browse files
committed
add test for group invite
1 parent faea616 commit 2a178c6

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

tests/fixtures/groups.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { GroupResponseType } from "../../src/typeDefinitions/group.types";
2+
3+
export const groups: GroupResponseType = {
4+
message: "Roles fetched successfully!",
5+
groups: [
6+
{
7+
id: "27EdauP9UmxCTgAMDPpl",
8+
date: {
9+
_seconds: 1719334613,
10+
_nanoseconds: 934000000,
11+
},
12+
createdBy: "zXQpimWaGWOFF2sLyrFt",
13+
rolename: "group-testing 3",
14+
roleid: "1255205109340573782",
15+
description: "for testing",
16+
memberCount: 0,
17+
isMember: false,
18+
},
19+
{
20+
id: "ELjCeNZxhHupn8qU5pWI",
21+
date: {
22+
_seconds: 1718771669,
23+
_nanoseconds: 27000000,
24+
},
25+
createdBy: "zXQpimWaGWOFF2sLyrFt",
26+
rolename: "group-testing",
27+
roleid: "1252843931306164298",
28+
description: "for testing",
29+
memberCount: 0,
30+
isMember: false,
31+
},
32+
{
33+
id: "tO4vZe5CC690yOb9Txlh",
34+
date: {
35+
_seconds: 1718771969,
36+
_nanoseconds: 680000000,
37+
},
38+
createdBy: "zXQpimWaGWOFF2sLyrFt",
39+
rolename: "group-testinge",
40+
roleid: "1252845191472087050",
41+
description: "",
42+
memberCount: 0,
43+
isMember: false,
44+
},
45+
],
46+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { groupInvite } from "../../../src/controllers/groupInvite";
2+
import { groups } from "../../fixtures/groups";
3+
import { environment } from "../../fixtures/config";
4+
import * as fetchDiscordGroup from "../../../src/utils/fetchDiscordGroups";
5+
import JSONResponse from "../../../src/utils/JsonResponse";
6+
7+
describe("Test /group-invite command", () => {
8+
beforeEach(() => {
9+
jest
10+
.spyOn(fetchDiscordGroup, "fetchDiscordGroups")
11+
.mockImplementation(() => Promise.resolve(new JSONResponse(groups)));
12+
});
13+
14+
it("Should be an instance of JSONResponse", async () => {
15+
const response = await groupInvite(
16+
"1",
17+
groups.groups[0].roleid,
18+
environment[0]
19+
);
20+
21+
expect(response).toBe(JSONResponse);
22+
});
23+
});

0 commit comments

Comments
 (0)