test(fetch): fix mock typing openclaw#19194 thanks @sebslight

This commit is contained in:
Sebastian
2026-02-17 09:41:38 -05:00
parent 3ce0e297fd
commit 7e3b2ff7af
3 changed files with 3 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ const urlToString = (url: Request | URL | string): string => {
describe("chutes-oauth", () => {
it("exchanges code for tokens and stores username as email", async () => {
const fetchFn = withFetchPreconnect(async (input, init) => {
const fetchFn = withFetchPreconnect(async (input: RequestInfo | URL, init?: RequestInit) => {
const url = urlToString(input);
if (url === CHUTES_TOKEN_ENDPOINT) {
expect(init?.method).toBe("POST");
@@ -66,7 +66,7 @@ describe("chutes-oauth", () => {
});
it("refreshes tokens using stored client id and falls back to old refresh token", async () => {
const fetchFn = withFetchPreconnect(async (input, init) => {
const fetchFn = withFetchPreconnect(async (input: RequestInfo | URL, init?: RequestInit) => {
const url = urlToString(input);
if (url !== CHUTES_TOKEN_ENDPOINT) {
return new Response("not found", { status: 404 });

View File

@@ -33,7 +33,7 @@ function createOAuthFetchFn(params: {
username: string;
passthrough?: boolean;
}) {
return withFetchPreconnect(async (input, init) => {
return withFetchPreconnect(async (input: RequestInfo | URL, init?: RequestInit) => {
const url = urlToString(input);
if (url === CHUTES_TOKEN_ENDPOINT) {
return new Response(

View File

@@ -96,19 +96,6 @@ describe("voyage embedding provider", () => {
it("passes input_type=document for embedBatch", async () => {
const fetchMock = withFetchPreconnect(
<<<<<<< HEAD
vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) => {
return new Response(
JSON.stringify({
data: [{ embedding: [0.1, 0.2] }, { embedding: [0.3, 0.4] }],
}),
{
status: 200,
headers: { "Content-Type": "application/json" },
},
);
}),
=======
vi.fn<FetchMock>(
async (_input: RequestInfo | URL, _init?: RequestInit) =>
new Response(
@@ -118,7 +105,6 @@ describe("voyage embedding provider", () => {
{ status: 200, headers: { "Content-Type": "application/json" } },
),
),
>>>>>>> 03a725142 (test(fetch): align mocks openclaw#19194 thanks @sebslight)
);
vi.stubGlobal("fetch", fetchMock);