File size: 594 Bytes
7f88bdf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { POST as initUpload } from "../../app/api/uploads/init/route";

describe("Uploads API", () => {
  it("returns 400 for invalid payload", async () => {
    // Construct a standard Fetch Request as expected by App Router
    const req = new Request("http://localhost/api/uploads/init", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({}),
    });

    const res = await initUpload(req);
    expect(res.status).toBe(400);
    
    const data = await res.json();
    expect(data.error).toBe("Invalid upload init payload");
  });
});