mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
test(fetch): fix mock typing openclaw#19194 thanks @sebslight
This commit is contained in:
@@ -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 });
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user