fix test typings

This commit is contained in:
dswbx
2025-03-11 09:38:14 +01:00
parent eb451a8e1a
commit 0dd29c3b07
4 changed files with 19 additions and 13 deletions

View File

@@ -32,7 +32,7 @@ describe("MediaApi", () => {
host, host,
basepath, basepath,
}); });
expect(api.getFileUploadUrl({ path: "path" })).toBe(`${host}${basepath}/upload/path`); expect(api.getFileUploadUrl({ path: "path" } as any)).toBe(`${host}${basepath}/upload/path`);
}); });
it("should have correct upload headers", () => { it("should have correct upload headers", () => {

View File

@@ -7,8 +7,8 @@ describe("OAuthStrategy", async () => {
const strategy = new OAuthStrategy({ const strategy = new OAuthStrategy({
type: "oidc", type: "oidc",
client: { client: {
client_id: process.env.OAUTH_CLIENT_ID, client_id: process.env.OAUTH_CLIENT_ID!,
client_secret: process.env.OAUTH_CLIENT_SECRET, client_secret: process.env.OAUTH_CLIENT_SECRET!,
}, },
name: "google", name: "google",
}); });
@@ -19,11 +19,6 @@ describe("OAuthStrategy", async () => {
const config = await strategy.getConfig(); const config = await strategy.getConfig();
console.log("config", JSON.stringify(config, null, 2)); console.log("config", JSON.stringify(config, null, 2));
const request = await strategy.request({
redirect_uri,
state,
});
const server = Bun.serve({ const server = Bun.serve({
fetch: async (req) => { fetch: async (req) => {
const url = new URL(req.url); const url = new URL(req.url);
@@ -39,6 +34,11 @@ describe("OAuthStrategy", async () => {
return new Response("Bun!"); return new Response("Bun!");
}, },
}); });
const request = await strategy.request({
redirect_uri,
state,
});
console.log("request", request); console.log("request", request);
await new Promise((resolve) => setTimeout(resolve, 100000)); await new Promise((resolve) => setTimeout(resolve, 100000));

View File

@@ -39,8 +39,8 @@ function makeName(ext: string) {
return randomString(10) + "." + ext; return randomString(10) + "." + ext;
} }
/*beforeAll(disableConsoleLog); beforeAll(disableConsoleLog);
afterAll(enableConsoleLog);*/ afterAll(enableConsoleLog);
describe("MediaController", () => { describe("MediaController", () => {
test.only("accepts direct", async () => { test.only("accepts direct", async () => {
@@ -56,9 +56,9 @@ describe("MediaController", () => {
console.log(result); console.log(result);
expect(result.name).toBe(name); expect(result.name).toBe(name);
/*const destFile = Bun.file(assetsTmpPath + "/" + name); const destFile = Bun.file(assetsTmpPath + "/" + name);
expect(destFile.exists()).resolves.toBe(true); expect(destFile.exists()).resolves.toBe(true);
await destFile.delete();*/ await destFile.delete();
}); });
test("accepts form data", async () => { test("accepts form data", async () => {

View File

@@ -1,4 +1,4 @@
import { Exception } from "core"; import { Exception, isDebug } from "core";
import { type Static, StringEnum, Type } from "core/utils"; import { type Static, StringEnum, Type } from "core/utils";
import { cors } from "hono/cors"; import { cors } from "hono/cors";
import { Module } from "modules/Module"; import { Module } from "modules/Module";
@@ -102,6 +102,12 @@ export class AppServer extends Module<typeof serverConfigSchema> {
return c.json(err.toJSON(), err.code as any); return c.json(err.toJSON(), err.code as any);
} }
if (err instanceof Error) {
if (isDebug()) {
return c.json({ error: err.message, stack: err.stack }, 500);
}
}
return c.json({ error: err.message }, 500); return c.json({ error: err.message }, 500);
}); });
this.setBuilt(); this.setBuilt();