-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from NYPL/feature/DR-2465/individual-json-swim-…
…lanes DR-2465 Json Swim Lanes
- Loading branch information
Showing
14 changed files
with
281 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.