| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | import { Cookies, HttpClientRequest, HttpClientResponse } from "effect/http"; |
| 3 | |
| 4 | describe("React Native HTTP responses", () => { |
| 5 | it("can inspect a rejected response when native Headers has no getSetCookie", () => { |
| 6 | const response = new Response("Registration rejected", { status: 400 }); |
| 7 | Object.defineProperty(response.headers, "getSetCookie", { value: undefined }); |
| 8 | const result = HttpClientResponse.fromWeb( |
| 9 | HttpClientRequest.post("https://relay.example.test/v1/mobile/devices"), |
| 10 | response, |
| 11 | ); |
| 12 | expect(result.cookies).toEqual(Cookies.empty); |
| 13 | expect(result.status).toBe(400); |
| 14 | }); |
| 15 | |
| 16 | it("preserves cookies on platforms that expose Set-Cookie headers", () => { |
| 17 | const result = HttpClientResponse.fromWeb( |
| 18 | HttpClientRequest.get("https://relay.example.test"), |
| 19 | new Response(null, { headers: { "Set-Cookie": "session=abc; HttpOnly" } }), |
| 20 | ); |
| 21 | expect(result.cookies).toEqual(Cookies.fromSetCookie(["session=abc; HttpOnly"])); |
| 22 | }); |
| 23 | }); |