Create effects concept #402

Merged
Vylpes merged 9 commits from feature/378-effects-concept into develop 2024-11-09 21:31:11 +00:00
4 changed files with 42 additions and 67 deletions
Showing only changes of commit 2becf6b95a - Show all commits

View file

@ -7,7 +7,7 @@
"clean": "rm -rf node_modules/ dist/",
"build": "tsc",
"start": "node ./dist/bot.js",
"test": "echo true",
"test": "jest",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"db:up": "typeorm migration:run -d dist/database/dataSources/appDataSource.js",

View file

@ -0,0 +1,41 @@
describe("AddUnused", () => {
test.todo("EXPECT unused to be the amount more");
});
describe("UseEffect", () => {
describe("GIVEN Unused is 0", () => {
test.todo("EXPECT false returned");
});
describe("GIVEN Unused is greater than 0", () => {
test.todo("EXPECT true returned");
test.todo("EXPECT Unused to be subtracted by 1");
test.todo("EXPECT WhenExpires to be set");
});
});
describe("IsEffectActive", () => {
describe("GIVEN WhenExpires is null", () => {
test.todo("EXPECT false returned");
});
describe("GIVEN WhenExpires is defined", () => {
describe("AND WhenExpires is in the past", () => {
test.todo("EXPECT false returned");
});
describe("AND WhenExpires is in the future", () => {
test.todo("EXPECT true returned");
});
});
});
describe("FetchOneByUserIdAndName", () => {
test.todo("EXPECT entity to be returned");
test.todo("EXPECT AppDataSource.getRepository to have been called");
test.todo("EXPECT repository.findOne to have been called");
});

View file

View file

@ -1,66 +0,0 @@
import {CoreClient} from "../src/client/client";
import Registry from "../src/registry";
import fs from "fs";
import path from "path";
describe("RegisterCommands", () => {
test("EXPECT every command in the commands folder to be registered", () => {
const registeredCommands: string[] = [];
CoreClient.RegisterCommand = jest.fn().mockImplementation((name: string) => {
registeredCommands.push(name);
});
Registry.RegisterCommands();
const commandFiles = getFilesInDirectory(path.join(process.cwd(), "src", "commands"))
.filter(x => x.endsWith(".ts"));
for (const file of commandFiles) {
expect(registeredCommands).toContain(file.split("/").pop()!.split(".")[0]);
}
expect(commandFiles.length).toBe(registeredCommands.length);
});
});
describe("RegisterButtonEvents", () => {
test("EXEPCT every button event in the button events folder to be registered", () => {
const registeredButtonEvents: string[] = [];
CoreClient.RegisterButtonEvent = jest.fn().mockImplementation((name: string) => {
registeredButtonEvents.push(name);
});
Registry.RegisterButtonEvents();
const eventFiles = getFilesInDirectory(path.join(process.cwd(), "src", "buttonEvents"))
.filter(x => x.endsWith(".ts"));
for (const file of eventFiles) {
expect(registeredButtonEvents).toContain(file.split("/").pop()!.split(".")[0].toLowerCase());
}
expect(eventFiles.length).toBe(registeredButtonEvents.length);
});
});
function getFilesInDirectory(dir: string): string[] {
let results: string[] = [];
const list = fs.readdirSync(dir);
list.forEach(file => {
file = path.join(dir, file);
const stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
/* recurse into a subdirectory */
results = results.concat(getFilesInDirectory(file));
} else {
/* is a file */
results.push(file);
}
});
return results;
}