add fetcher option to api to allow local calls

This commit is contained in:
dswbx
2025-01-25 19:29:36 +01:00
parent ba1eb5fe08
commit 2d6d83ccb2
3 changed files with 18 additions and 18 deletions

View File

@@ -27,10 +27,7 @@ describe("ModuleApi", () => {
it("fetches endpoint", async () => {
const app = new Hono().get("/endpoint", (c) => c.json({ foo: "bar" }));
const api = new Api({ host });
// @ts-expect-error it's protected
api.fetcher = app.request as typeof fetch;
const api = new Api({ host }, app.request as typeof fetch);
const res = await api.get("/endpoint");
expect(res.res.ok).toEqual(true);
@@ -41,10 +38,7 @@ describe("ModuleApi", () => {
it("has accessible request", async () => {
const app = new Hono().get("/endpoint", (c) => c.json({ foo: "bar" }));
const api = new Api({ host });
// @ts-expect-error it's protected
api.fetcher = app.request as typeof fetch;
const api = new Api({ host }, app.request as typeof fetch);
const promise = api.get("/endpoint");
expect(promise.request).toBeDefined();