From ecc7683c02430cee57eac59bf2c9c64fe87b7091 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Mon, 20 Sep 2021 23:35:37 +0200 Subject: :bug: fix unittests --- api/jest/globalSetup.js | 7 ++++++- api/jest/setup.js | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'api/jest') diff --git a/api/jest/globalSetup.js b/api/jest/globalSetup.js index 98e70fb9..520aa0e2 100644 --- a/api/jest/globalSetup.js +++ b/api/jest/globalSetup.js @@ -1,3 +1,4 @@ +const { Config, initDatabase } = require("@fosscord/util"); const fs = require("fs"); const path = require("path"); const { FosscordServer } = require("../dist/Server"); @@ -5,8 +6,12 @@ const Server = new FosscordServer({ port: 3001 }); global.server = Server; module.exports = async () => { try { - fs.unlinkSync(path.join(__dirname, "..", "database.db")); + fs.unlinkSync(path.join(process.cwd(), "database.db")); } catch {} + + await initDatabase(); + await Config.init(); + Config.get().limits.rate.disabled = true; return await Server.start(); }; diff --git a/api/jest/setup.js b/api/jest/setup.js index bd535866..abc485ae 100644 --- a/api/jest/setup.js +++ b/api/jest/setup.js @@ -1,2 +1,2 @@ -// jest.spyOn(global.console, "log").mockImplementation(() => jest.fn()); -// jest.spyOn(global.console, "info").mockImplementation(() => jest.fn()); +jest.spyOn(global.console, "log").mockImplementation(() => jest.fn()); +jest.spyOn(global.console, "info").mockImplementation(() => jest.fn()); -- cgit 1.5.1