-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproxy.test.ts
More file actions
23 lines (20 loc) · 774 Bytes
/
proxy.test.ts
File metadata and controls
23 lines (20 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { describe, expect, it } from "bun:test";
import { NextRequest } from "next/server";
import { proxy } from "./coello-one/proxy";
function buildRequest(pathname: string, acceptLanguage: string) {
const url = new URL(`https://coello.test${pathname}`);
return new NextRequest(url, {
headers: {
"accept-language": acceptLanguage,
},
});
}
describe("proxy Accept-Language negotiation", () => {
it("redirects to the Spanish locale when curl sends Accept-Language: es", () => {
const request = buildRequest("/", "es");
const response = proxy(request);
expect(response.status).toBe(307);
expect(response.headers.get("location")).toBe("https://coello.test/es-ES");
expect(response.headers.get("x-locale")).toBe("es-ES");
});
});