From 43751e5b021a3eff3bb8fcd501572191c9114ab0 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 31 Oct 2024 16:56:36 +0000 Subject: [PATCH] WIP: Planning more tests --- src/commands/304276391837302787/moons/add.ts | 6 +- tests/buttonEvents/moons/list.test.ts | 68 +++++++++---------- .../304276391837302787/moons/add.test.ts | 19 ++++++ .../304276391837302787/moons/list.test.ts | 29 ++++++++ tests/database/entites/UserSetting.test.ts | 11 +++ 5 files changed, 91 insertions(+), 42 deletions(-) create mode 100644 tests/commands/304276391837302787/moons/add.test.ts create mode 100644 tests/commands/304276391837302787/moons/list.test.ts create mode 100644 tests/database/entites/UserSetting.test.ts diff --git a/src/commands/304276391837302787/moons/add.ts b/src/commands/304276391837302787/moons/add.ts index 10a2d17..ffc79c0 100644 --- a/src/commands/304276391837302787/moons/add.ts +++ b/src/commands/304276391837302787/moons/add.ts @@ -24,11 +24,7 @@ export default async function AddMoon(interaction: CommandInteraction) { const allMoons = await Moon.FetchMoonCountByUserId(interaction.user.id); - let moonNumber = allMoons + 1; - - if (allMoons < moonCount) { - moonNumber = moonCount + 1; - } + const moonNumber = allMoons + 1; const moon = new Moon(moonNumber, description, interaction.user.id); diff --git a/tests/buttonEvents/moons/list.test.ts b/tests/buttonEvents/moons/list.test.ts index 21c740d..73b66b6 100644 --- a/tests/buttonEvents/moons/list.test.ts +++ b/tests/buttonEvents/moons/list.test.ts @@ -1,49 +1,43 @@ -describe("GIVEN interation.guild is null", () => { - test.todo("EXPECT nothing to happen"); +describe("GIVEN interaction.guild is null", () => { + test.todo("EXPECT function to return"); }); -describe("GIVEN userId is not supplied", () => { - test.todo("EXPECT nothing to happen"); +describe("GIVEN userId parameter is undefined", () => { + test.todo("EXPECT function to return"); }); -describe("GIVEN page is not supplied", () => { - test.todo("EXPECT nothing to happen"); +describe("GIVEN page parameter is undefined", () => { + test.todo("EXPECT function to return"); }); -describe("GIVEN moons entity is undefined", () => { - test.todo("EXPECT interaction replied"); +describe("GIVEN no moons for the user is returned", () => { + test.todo("EXPECT error replied"); }); -describe("GIVEN moons array is empty", () => { - test.todo("EXPECT embed description to say none"); -}); - -describe("GIVEN moons array is not empty", () => { - test.todo("EXPECT embed description to specify moon details"); -}); - -describe("GIVEN moon difference is greater than 0", () => { - describe("GIVEN it is not the last page", () => { - test.todo("EXPECT untracked moons message to not be displayed"); - }); - - describe("GIVEN it is the last page", () => { - test.todo("EXPECT untracked moons to be displayed"); - }); - - describe("GIVEN moons array is empty", () => { - test.todo("EXPECT untracked moons to be displayed"); - }); -}); - -describe("GIVEN it is the first page", () => { - test.todo("EXPECT previous button to be disabled"); -}); - -describe("GIVEN it is the last page", () => { - test.todo("EXPECT next button to be disabled"); +describe("GIVEN no moons on current page", () => { + test.todo("EXPECT description to say so"); }); describe("GIVEN happy flow", () => { - test.todo("EXPECT interaction to be updated"); + test.todo("EXPECT moons to be fetched"); + + test.todo("EXPECT embed to be updated"); + + test.todo("EXPECT row to be updated"); + + describe("GIVEN it is the first page", () => { + test.todo("EXPECT Previous button to be disabled"); + }); + + describe("GIVEN it is the last page", () => { + test.todo("EXPECT Next button to be disabled"); + + describe("GIVEN there are more moons in the counter than in the database", () => { + test.todo("EXPECT untracked counter to be present"); + }); + }); + + describe("GIVEN no moons on the current page", () => { + test.todo("EXPECT Next button to be disabled"); + }); }); \ No newline at end of file diff --git a/tests/commands/304276391837302787/moons/add.test.ts b/tests/commands/304276391837302787/moons/add.test.ts new file mode 100644 index 0000000..a07e070 --- /dev/null +++ b/tests/commands/304276391837302787/moons/add.test.ts @@ -0,0 +1,19 @@ +describe("GIVEN description is null", () => { + test.todo("EXPECT error replied"); +}); + +describe("GIVEN description is greater than 255 characters", () => { + test.todo("EXPECT error replied"); +}); + +describe("GIVEN moon count setting exists", () => { + test.todo("EXPECT existing entity to be updated"); +}); + +describe("GIVEN moon count setting does not exist", () => { + test.todo("EXPECT new entity to be created"); +}); + +test.todo("EXPECT setting to be saved"); + +test.todo("EXPECT embed to be replied"); diff --git a/tests/commands/304276391837302787/moons/list.test.ts b/tests/commands/304276391837302787/moons/list.test.ts new file mode 100644 index 0000000..cea7bd5 --- /dev/null +++ b/tests/commands/304276391837302787/moons/list.test.ts @@ -0,0 +1,29 @@ +describe("GIVEN moons returned is empty", () => { + test.todo("EXPECT none description"); +}); + +describe("GIVEN it is the first page", () => { + test.todo("EXPECT Previous button to be disabled"); +}); + +describe("GIVEN it is the last page", () => { + test.todo("EXPECT Next button to be disabled"); + + describe("GIVEN moon count is greater than the amount of moons in the database", () => { + test.todo("EXPECT untracked counter to be shown"); + }); +}); + +describe("GIVEN moon count is empty", () => { + test.todo("EXPECT Next button to be disabled"); + + describe("GIVEN moon count is greater than the amount of moons in the database", () => { + test.todo("EXPECT untracked counter to be shown"); + }); +}); + +test.todo("EXPECT interaction to be replied"); + +test.todo("EXPECT embed to be replied"); + +test.todo("EXPECT row to be replied"); diff --git a/tests/database/entites/UserSetting.test.ts b/tests/database/entites/UserSetting.test.ts new file mode 100644 index 0000000..238e23d --- /dev/null +++ b/tests/database/entites/UserSetting.test.ts @@ -0,0 +1,11 @@ +describe("constructor", () => { + test.todo("EXPECT settings to be configured"); +}); + +describe("UpdateValue", () => { + test.todo("EXPECT value to be updated"); +}); + +describe("FetchOneByKey", () => { + test.todo("EXPECT single entity returned"); +});