import { describe, expect, it } from "vitest" import { GET } from "@/app/api/search/route" describe("GET /api/search", () => { it("returns 200 with items and meta", async () => { const request = new Request("http://x/api/search") const response = await GET(request) expect(response.status).toBe(200) const json = await response.json() expect(Array.isArray(json.items)).toBe(true) expect(json.meta).toHaveProperty("total") expect(json.meta).toHaveProperty("offset") expect(json.meta).toHaveProperty("limit") }) it("sets Cache-Control to no-store", async () => { const request = new Request("http://x/api/search") const response = await GET(request) expect(response.headers.get("Cache-Control")).toBe("no-store") }) it("filters by q param", async () => { const request = new Request("http://x/api/search?q=winter") const response = await GET(request) const json = await response.json() expect(response.status).toBe(200) expect(json.items.length).toBeGreaterThan(0) }) it("respects limit and offset", async () => { const request = new Request("http://x/api/search?limit=2&offset=1") const response = await GET(request) const json = await response.json() expect(json.items.length).toBeLessThanOrEqual(2) expect(json.meta.limit).toBe(2) expect(json.meta.offset).toBe(1) }) it("handles game filter", async () => { const request = new Request("http://x/api/search?game=CS2") const response = await GET(request) const json = await response.json() expect(response.status).toBe(200) expect(json.items.length).toBeGreaterThan(0) }) })