Skip to content

Commit 5862f73

Browse files
test: address review comments - remove and simplify tests
- Remove test for 404 fallback behavior (no longer relevant) - Simplify streaming test to just test basic fetch functionality Co-authored-by: Netanel Gilad <netanelgilad@users.noreply.github.com>
1 parent d096d6f commit 5862f73

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

tests/unit/functions.test.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -459,39 +459,20 @@ describe("Functions Module", () => {
459459
expect(scope.isDone()).toBe(true);
460460
});
461461

462-
test("should fetch function endpoint directly for streaming", async () => {
462+
test("should fetch function endpoint directly", async () => {
463463
fetchMock.mockResolvedValueOnce(new Response("ok", { status: 200 }));
464464

465-
await base44.functions.fetch("/streaming_demo", {
466-
method: "POST",
467-
body: JSON.stringify({ mode: "sse" }),
465+
await base44.functions.fetch("/my_function", {
466+
method: "GET",
468467
});
469468

470469
expect(fetchMock).toHaveBeenCalledTimes(1);
471470
expect(fetchMock).toHaveBeenCalledWith(
472-
`${serverUrl}/api/functions/streaming_demo`,
471+
`${serverUrl}/api/functions/my_function`,
473472
expect.any(Object)
474473
);
475-
476-
const requestInit = fetchMock.mock.calls[0][1];
477-
expect(requestInit.body).toBe(JSON.stringify({ mode: "sse" }));
478474
});
479475

480-
test("should not fallback to app-scoped functions endpoint on 404", async () => {
481-
fetchMock
482-
.mockResolvedValueOnce(new Response("Not found", { status: 404 }));
483-
484-
const response = await base44.functions.fetch("/streaming_demo/deep/path", {
485-
method: "POST",
486-
body: JSON.stringify({ mode: "ndjson" }),
487-
});
488-
489-
expect(fetchMock).toHaveBeenCalledTimes(1);
490-
expect(fetchMock.mock.calls[0][0]).toBe(
491-
`${serverUrl}/api/functions/streaming_demo/deep/path`
492-
);
493-
expect(response.status).toBe(404);
494-
});
495476

496477
test("should include Authorization header when using functions.fetch", async () => {
497478
const userToken = "user-streaming-token";

0 commit comments

Comments
 (0)