Discord Actions: Update tests for optional config parameter
This commit is contained in:
@@ -78,7 +78,7 @@ describe("handleDiscordMessagingAction", () => {
|
|||||||
},
|
},
|
||||||
enableAllActions,
|
enableAllActions,
|
||||||
);
|
);
|
||||||
expect(reactMessageDiscord).toHaveBeenCalledWith("C1", "M1", "✅");
|
expect(reactMessageDiscord).toHaveBeenCalledWith("C1", "M1", "✅", {});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes reactions on empty emoji", async () => {
|
it("removes reactions on empty emoji", async () => {
|
||||||
@@ -91,7 +91,7 @@ describe("handleDiscordMessagingAction", () => {
|
|||||||
},
|
},
|
||||||
enableAllActions,
|
enableAllActions,
|
||||||
);
|
);
|
||||||
expect(removeOwnReactionsDiscord).toHaveBeenCalledWith("C1", "M1");
|
expect(removeOwnReactionsDiscord).toHaveBeenCalledWith("C1", "M1", {});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes reactions when remove flag set", async () => {
|
it("removes reactions when remove flag set", async () => {
|
||||||
@@ -105,7 +105,7 @@ describe("handleDiscordMessagingAction", () => {
|
|||||||
},
|
},
|
||||||
enableAllActions,
|
enableAllActions,
|
||||||
);
|
);
|
||||||
expect(removeReactionDiscord).toHaveBeenCalledWith("C1", "M1", "✅");
|
expect(removeReactionDiscord).toHaveBeenCalledWith("C1", "M1", "✅", {});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("rejects removes without emoji", async () => {
|
it("rejects removes without emoji", async () => {
|
||||||
@@ -227,15 +227,18 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(createChannelDiscord).toHaveBeenCalledWith({
|
expect(createChannelDiscord).toHaveBeenCalledWith(
|
||||||
guildId: "G1",
|
{
|
||||||
name: "test-channel",
|
guildId: "G1",
|
||||||
type: 0,
|
name: "test-channel",
|
||||||
parentId: undefined,
|
type: 0,
|
||||||
topic: "Test topic",
|
parentId: undefined,
|
||||||
position: undefined,
|
topic: "Test topic",
|
||||||
nsfw: undefined,
|
position: undefined,
|
||||||
});
|
nsfw: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
expect(result.details).toMatchObject({ ok: true });
|
expect(result.details).toMatchObject({ ok: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -255,15 +258,18 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(editChannelDiscord).toHaveBeenCalledWith({
|
expect(editChannelDiscord).toHaveBeenCalledWith(
|
||||||
channelId: "C1",
|
{
|
||||||
name: "new-name",
|
channelId: "C1",
|
||||||
topic: "new topic",
|
name: "new-name",
|
||||||
position: undefined,
|
topic: "new topic",
|
||||||
parentId: undefined,
|
position: undefined,
|
||||||
nsfw: undefined,
|
parentId: undefined,
|
||||||
rateLimitPerUser: undefined,
|
nsfw: undefined,
|
||||||
});
|
rateLimitPerUser: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears the channel parent when parentId is null", async () => {
|
it("clears the channel parent when parentId is null", async () => {
|
||||||
@@ -275,15 +281,18 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(editChannelDiscord).toHaveBeenCalledWith({
|
expect(editChannelDiscord).toHaveBeenCalledWith(
|
||||||
channelId: "C1",
|
{
|
||||||
name: undefined,
|
channelId: "C1",
|
||||||
topic: undefined,
|
name: undefined,
|
||||||
position: undefined,
|
topic: undefined,
|
||||||
parentId: null,
|
position: undefined,
|
||||||
nsfw: undefined,
|
parentId: null,
|
||||||
rateLimitPerUser: undefined,
|
nsfw: undefined,
|
||||||
});
|
rateLimitPerUser: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears the channel parent when clearParent is true", async () => {
|
it("clears the channel parent when clearParent is true", async () => {
|
||||||
@@ -295,20 +304,23 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(editChannelDiscord).toHaveBeenCalledWith({
|
expect(editChannelDiscord).toHaveBeenCalledWith(
|
||||||
channelId: "C1",
|
{
|
||||||
name: undefined,
|
channelId: "C1",
|
||||||
topic: undefined,
|
name: undefined,
|
||||||
position: undefined,
|
topic: undefined,
|
||||||
parentId: null,
|
position: undefined,
|
||||||
nsfw: undefined,
|
parentId: null,
|
||||||
rateLimitPerUser: undefined,
|
nsfw: undefined,
|
||||||
});
|
rateLimitPerUser: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("deletes a channel", async () => {
|
it("deletes a channel", async () => {
|
||||||
await handleDiscordGuildAction("channelDelete", { channelId: "C1" }, channelsEnabled);
|
await handleDiscordGuildAction("channelDelete", { channelId: "C1" }, channelsEnabled);
|
||||||
expect(deleteChannelDiscord).toHaveBeenCalledWith("C1");
|
expect(deleteChannelDiscord).toHaveBeenCalledWith("C1", {});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("moves a channel", async () => {
|
it("moves a channel", async () => {
|
||||||
@@ -322,12 +334,15 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(moveChannelDiscord).toHaveBeenCalledWith({
|
expect(moveChannelDiscord).toHaveBeenCalledWith(
|
||||||
guildId: "G1",
|
{
|
||||||
channelId: "C1",
|
guildId: "G1",
|
||||||
parentId: "P1",
|
channelId: "C1",
|
||||||
position: 5,
|
parentId: "P1",
|
||||||
});
|
position: 5,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears the channel parent on move when parentId is null", async () => {
|
it("clears the channel parent on move when parentId is null", async () => {
|
||||||
@@ -340,12 +355,15 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(moveChannelDiscord).toHaveBeenCalledWith({
|
expect(moveChannelDiscord).toHaveBeenCalledWith(
|
||||||
guildId: "G1",
|
{
|
||||||
channelId: "C1",
|
guildId: "G1",
|
||||||
parentId: null,
|
channelId: "C1",
|
||||||
position: undefined,
|
parentId: null,
|
||||||
});
|
position: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("clears the channel parent on move when clearParent is true", async () => {
|
it("clears the channel parent on move when clearParent is true", async () => {
|
||||||
@@ -358,12 +376,15 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(moveChannelDiscord).toHaveBeenCalledWith({
|
expect(moveChannelDiscord).toHaveBeenCalledWith(
|
||||||
guildId: "G1",
|
{
|
||||||
channelId: "C1",
|
guildId: "G1",
|
||||||
parentId: null,
|
channelId: "C1",
|
||||||
position: undefined,
|
parentId: null,
|
||||||
});
|
position: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("creates a category with type=4", async () => {
|
it("creates a category with type=4", async () => {
|
||||||
@@ -372,12 +393,15 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
{ guildId: "G1", name: "My Category" },
|
{ guildId: "G1", name: "My Category" },
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(createChannelDiscord).toHaveBeenCalledWith({
|
expect(createChannelDiscord).toHaveBeenCalledWith(
|
||||||
guildId: "G1",
|
{
|
||||||
name: "My Category",
|
guildId: "G1",
|
||||||
type: 4,
|
name: "My Category",
|
||||||
position: undefined,
|
type: 4,
|
||||||
});
|
position: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("edits a category", async () => {
|
it("edits a category", async () => {
|
||||||
@@ -386,16 +410,19 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
{ categoryId: "CAT1", name: "Renamed Category" },
|
{ categoryId: "CAT1", name: "Renamed Category" },
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(editChannelDiscord).toHaveBeenCalledWith({
|
expect(editChannelDiscord).toHaveBeenCalledWith(
|
||||||
channelId: "CAT1",
|
{
|
||||||
name: "Renamed Category",
|
channelId: "CAT1",
|
||||||
position: undefined,
|
name: "Renamed Category",
|
||||||
});
|
position: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("deletes a category", async () => {
|
it("deletes a category", async () => {
|
||||||
await handleDiscordGuildAction("categoryDelete", { categoryId: "CAT1" }, channelsEnabled);
|
await handleDiscordGuildAction("categoryDelete", { categoryId: "CAT1" }, channelsEnabled);
|
||||||
expect(deleteChannelDiscord).toHaveBeenCalledWith("CAT1");
|
expect(deleteChannelDiscord).toHaveBeenCalledWith("CAT1", {});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets channel permissions for role", async () => {
|
it("sets channel permissions for role", async () => {
|
||||||
@@ -410,13 +437,16 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(setChannelPermissionDiscord).toHaveBeenCalledWith({
|
expect(setChannelPermissionDiscord).toHaveBeenCalledWith(
|
||||||
channelId: "C1",
|
{
|
||||||
targetId: "R1",
|
channelId: "C1",
|
||||||
targetType: 0,
|
targetId: "R1",
|
||||||
allow: "1024",
|
targetType: 0,
|
||||||
deny: "2048",
|
allow: "1024",
|
||||||
});
|
deny: "2048",
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("sets channel permissions for member", async () => {
|
it("sets channel permissions for member", async () => {
|
||||||
@@ -430,13 +460,16 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
},
|
},
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(setChannelPermissionDiscord).toHaveBeenCalledWith({
|
expect(setChannelPermissionDiscord).toHaveBeenCalledWith(
|
||||||
channelId: "C1",
|
{
|
||||||
targetId: "U1",
|
channelId: "C1",
|
||||||
targetType: 1,
|
targetId: "U1",
|
||||||
allow: "1024",
|
targetType: 1,
|
||||||
deny: undefined,
|
allow: "1024",
|
||||||
});
|
deny: undefined,
|
||||||
|
},
|
||||||
|
{},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes channel permissions", async () => {
|
it("removes channel permissions", async () => {
|
||||||
@@ -445,6 +478,6 @@ describe("handleDiscordGuildAction - channel management", () => {
|
|||||||
{ channelId: "C1", targetId: "R1" },
|
{ channelId: "C1", targetId: "R1" },
|
||||||
channelsEnabled,
|
channelsEnabled,
|
||||||
);
|
);
|
||||||
expect(removeChannelPermissionDiscord).toHaveBeenCalledWith("C1", "R1");
|
expect(removeChannelPermissionDiscord).toHaveBeenCalledWith("C1", "R1", {});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user