Skip to content

Commit

Permalink
Merge pull request #8 from NYPL/feature/DR-2465/individual-json-swim-…
Browse files Browse the repository at this point in the history
…lanes

DR-2465 Json Swim Lanes
  • Loading branch information
7emansell authored Oct 25, 2023
2 parents 0faa9d1 + 5206b66 commit 2deb3d1
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 158 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Returns respective JSON for that lane.

---

Returns JSON containing all lanes' metadata.
Returns JSON containing all lanes.

#### Note for future

Expand Down
57 changes: 0 additions & 57 deletions __tests__/[slug].test.tsx

This file was deleted.

43 changes: 43 additions & 0 deletions __tests__/api/lanes/[slug].test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import slugHandler from "@/pages/api/lanes/[slug]";
import { NextApiRequest } from "next";

it("should respond with 200 status and lanes data for a GET request", () => {
const request: NextApiRequest = {
method: "GET",
query: {
slug: "maps",
},
} as unknown as NextApiRequest;

const mockResponse: any = {
status: jest.fn(function () {
return this;
}),
json: jest.fn(),
};

slugHandler(request, mockResponse);

expect(mockResponse.status).toHaveBeenCalledWith(200);
});

it("should respond with an error for nonexistent slugs", () => {
const request: NextApiRequest = {
method: "GET",
query: {
slug: "not-a-slug",
},
} as unknown as NextApiRequest;

const mockResponse: any = {
status: jest.fn(function () {
return this;
}),
json: jest.fn(),
};

slugHandler(request, mockResponse);

expect(mockResponse.status).toHaveBeenCalledWith(404);
expect(mockResponse.json).toHaveBeenCalledWith({ error: "Lane not found" });
});
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 2deb3d1

Please sign in to comment.