Compare commits

..

No commits in common. "581c275adf04196b20805ba8c4c353d350e51752" and "39231ddc16e0c1062d4ba743f1286d7c6a63f595" have entirely different histories.

3 changed files with 7 additions and 156 deletions

View file

@ -1,32 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Constructor EXPECT properties to be set 1`] = `
{
"default_member_permissions": "8",
"default_permission": undefined,
"description": "Rules-related commands",
"description_localizations": undefined,
"dm_permission": undefined,
"name": "rules",
"name_localizations": undefined,
"nsfw": undefined,
"options": [
{
"description": "Send the rules embeds for this server",
"description_localizations": undefined,
"name": "embeds",
"name_localizations": undefined,
"options": [],
"type": 1,
},
{
"description": "Send the server verification embed button",
"description_localizations": undefined,
"name": "access",
"name_localizations": undefined,
"options": [],
"type": 1,
},
],
}
`;

View file

@ -117,126 +117,15 @@ describe('Execute', () => {
expect(message.react).toHaveBeenCalledWith("5⃣"); expect(message.react).toHaveBeenCalledWith("5⃣");
}); });
test("GIVEN option3 is not supplied, EXPECT a 2 option poll to be created", async () => { test.todo("GIVEN title is not supplied, EXPECT nothing to happen");
let sentEmbed: EmbedBuilder | undefined;
// Arrange test.todo("GIVEN option1 is not supplied, EXPECT nothing to happen");
const message = {
react: jest.fn(),
} as unknown as Message<boolean>;
const response = { test.todo("GIVEN option2 is not supplied, EXPECT nothing to happen");
fetch: jest.fn().mockResolvedValue(message),
} as unknown as InteractionResponse<boolean>;
const interaction = { test.todo("GIVEN option3 is not supplied, EXPECT a 2 option poll to be created");
options: {
get: jest.fn().mockReturnValueOnce({ value: "Title" })
.mockReturnValueOnce({ value: "Option 1" })
.mockReturnValueOnce({ value: "Option 2" }),
},
reply: jest.fn().mockImplementation((options: any) => {
sentEmbed = options.embeds[0];
return response; test.todo("GIVEN option4 is not supplied, EXPECT a 3 option poll to be created");
}),
user: {
username: "username",
avatarURL: jest.fn().mockReturnValue("https://avatarurl.com/user.png"),
},
} as unknown as CommandInteraction;
// Act test.todo("GIVEN option5 is not supplied, EXPECT a 4 option poll to be created");
const command = new Command();
await command.execute(interaction);
// Assert
expect(sentEmbed).toBeDefined();
expect(sentEmbed!.data.description).toBe("1⃣ Option 1\n2⃣ Option 2");
expect(message.react).toHaveBeenCalledTimes(2);
});
test("GIVEN option4 is not supplied, EXPECT a 3 option poll to be created", async () => {
let sentEmbed: EmbedBuilder | undefined;
// Arrange
const message = {
react: jest.fn(),
} as unknown as Message<boolean>;
const response = {
fetch: jest.fn().mockResolvedValue(message),
} as unknown as InteractionResponse<boolean>;
const interaction = {
options: {
get: jest.fn().mockReturnValueOnce({ value: "Title" })
.mockReturnValueOnce({ value: "Option 1" })
.mockReturnValueOnce({ value: "Option 2" })
.mockReturnValueOnce({ value: "Option 3" }),
},
reply: jest.fn().mockImplementation((options: any) => {
sentEmbed = options.embeds[0];
return response;
}),
user: {
username: "username",
avatarURL: jest.fn().mockReturnValue("https://avatarurl.com/user.png"),
},
} as unknown as CommandInteraction;
// Act
const command = new Command();
await command.execute(interaction);
// Assert
expect(sentEmbed).toBeDefined();
expect(sentEmbed!.data.description).toBe("1⃣ Option 1\n2⃣ Option 2\n3⃣ Option 3");
expect(message.react).toHaveBeenCalledTimes(3);
});
test("GIVEN option5 is not supplied, EXPECT a 4 option poll to be created", async () => {
let sentEmbed: EmbedBuilder | undefined;
// Arrange
const message = {
react: jest.fn(),
} as unknown as Message<boolean>;
const response = {
fetch: jest.fn().mockResolvedValue(message),
} as unknown as InteractionResponse<boolean>;
const interaction = {
options: {
get: jest.fn().mockReturnValueOnce({ value: "Title" })
.mockReturnValueOnce({ value: "Option 1" })
.mockReturnValueOnce({ value: "Option 2" })
.mockReturnValueOnce({ value: "Option 3" })
.mockReturnValueOnce({ value: "Option 4" }),
},
reply: jest.fn().mockImplementation((options: any) => {
sentEmbed = options.embeds[0];
return response;
}),
user: {
username: "username",
avatarURL: jest.fn().mockReturnValue("https://avatarurl.com/user.png"),
},
} as unknown as CommandInteraction;
// Act
const command = new Command();
await command.execute(interaction);
// Assert
expect(sentEmbed).toBeDefined();
expect(sentEmbed!.data.description).toBe("1⃣ Option 1\n2⃣ Option 2\n3⃣ Option 3\n4⃣ Option 4");
expect(message.react).toHaveBeenCalledTimes(4);
});
}); });

View file

@ -1,15 +1,9 @@
import Command from "../../src/commands/rules";
beforeEach(() => { beforeEach(() => {
process.env = {}; process.env = {};
}); });
describe('Constructor', () => { describe('Constructor', () => {
test('EXPECT properties to be set', () => { test.todo('EXPECT properties to be set');
const command = new Command();
expect(command.CommandBuilder).toMatchSnapshot();
});
}); });
describe('Execute', () => { describe('Execute', () => {