|
1 | 1 | import { kickEachUser } from "../../../src/controllers/kickEachUser";
|
2 |
| -import { transformedArgument, ctx } from "../../fixtures/fixture"; |
| 2 | +import { |
| 3 | + transformedArgument, |
| 4 | + ctx, |
| 5 | + messageRequestMemberMockSuperUser, |
| 6 | + messageRequestMemberMockNonSuperUser, |
| 7 | +} from "../../fixtures/fixture"; |
3 | 8 |
|
4 | 9 | describe("kickEachUser", () => {
|
5 |
| - it("should run when found no users with Matched Role", async () => { |
| 10 | + it("should fail when a non super_user runs ", async () => { |
6 | 11 | const env = {
|
7 | 12 | BOT_PUBLIC_KEY: "xyz",
|
8 | 13 | DISCORD_GUILD_ID: "123",
|
9 | 14 | DISCORD_TOKEN: "abc",
|
10 | 15 | };
|
11 | 16 |
|
12 | 17 | const { roleToBeTaggedObj } = transformedArgument; // Extracting roleToBeTaggedObj
|
13 |
| - const response = kickEachUser( |
14 |
| - { roleToBeRemovedObj: roleToBeTaggedObj, channelId: 12345 }, |
15 |
| - env, |
16 |
| - ctx |
| 18 | + const messageRequestMember = { |
| 19 | + roleToBeRemovedObj: roleToBeTaggedObj, |
| 20 | + channelId: 12345, |
| 21 | + ...messageRequestMemberMockNonSuperUser, |
| 22 | + }; |
| 23 | + const response = kickEachUser(messageRequestMember, env, ctx); |
| 24 | + |
| 25 | + const roleID = roleToBeTaggedObj.value; |
| 26 | + |
| 27 | + expect(response).toBeInstanceOf(Promise); |
| 28 | + |
| 29 | + const textMessage: { data: { content: string } } = await response.then( |
| 30 | + (res) => res.json() |
| 31 | + ); |
| 32 | + expect(textMessage.data.content).toBe( |
| 33 | + `You're not authorized to make this request.` |
17 | 34 | );
|
| 35 | + }); |
| 36 | + |
| 37 | + it("should run when found no users with Matched Role", async () => { |
| 38 | + const env = { |
| 39 | + BOT_PUBLIC_KEY: "xyz", |
| 40 | + DISCORD_GUILD_ID: "123", |
| 41 | + DISCORD_TOKEN: "abc", |
| 42 | + }; |
| 43 | + |
| 44 | + const { roleToBeTaggedObj } = transformedArgument; // Extracting roleToBeTaggedObj |
| 45 | + const messageRequestMember = { |
| 46 | + roleToBeRemovedObj: roleToBeTaggedObj, |
| 47 | + channelId: 12345, |
| 48 | + ...messageRequestMemberMockSuperUser, |
| 49 | + }; |
| 50 | + const response = kickEachUser(messageRequestMember, env, ctx); |
18 | 51 |
|
19 | 52 | const roleID = roleToBeTaggedObj.value;
|
20 | 53 |
|
|
0 commit comments