Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions routes/date.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ describe("/date", () => {
});

describe("GET /month", () => {
it("should return 5", async () => {
it("should return 6", async () => {
const res = await request(server).get("/date/month");
expect(res.statusCode).toEqual(200);
expect(res.body).toEqual({ month: 5 });
expect(res.body).toEqual({ month: 6 });
});
});

Expand Down
7 changes: 4 additions & 3 deletions routes/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ router.post("/sum", (req, res, next) => {

router.post("/product", (req, res, next) => {
if (req.body.length == 0) {
res.sendStatus(400).send("Product requires at least two values");
res.sendStatus(400).send();
} else if (req.body.length == 1) {
res.json({ product: req.body[0] });
} else {
const product = req.body.reduce(
(runningProduct, num) => num * runningProduct,
0
(runningProduct, num) => num * runningProduct
);
res.json({ product });
}
Expand Down
8 changes: 4 additions & 4 deletions routes/parrot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const server = require("../server");
describe("/parrot", () => {
describe("GET /parrot", () => {
it("should return GET and query parameters", async () => {
const res = await request(server).get("/parrot?key1=true&key2=other");
const res = await request(server).get("/parrot/parrot?key1=true&key2=other");
expect(res.statusCode).toEqual(200);
expect(res.body).toEqual({
body: {},
Expand All @@ -20,10 +20,10 @@ describe("/parrot", () => {
describe("POST /parrot", () => {
it("should return POST and body", async () => {
const requestBody = {
key: true,
key: "true",
key2: "other",
};
const res = await request(server).post("/parrot").send(requestBody);
const res = await request(server).post("/parrot/parrot").send(requestBody);
expect(res.statusCode).toEqual(200);
expect(res.body).toEqual({
body: requestBody,
Expand All @@ -39,7 +39,7 @@ describe("/parrot", () => {
key2: "other",
};
const res = await request(server)
.put("/parrot?field=value")
.put("/parrot/parrot?field=value")
.send(requestBody);
expect(res.statusCode).toEqual(200);
expect(res.body).toEqual({
Expand Down
4 changes: 2 additions & 2 deletions routes/string.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe("/string", () => {
});
describe("GET /uppercase", () => {
it("should not change an already uppercase version of a string", async () => {
const res = await request(server).get("/string/TEST/lowercase");
const res = await request(server).get("/string/TEST/uppercase");
expect(res.statusCode).toEqual(200);
expect(res.body).toEqual({ uppercase: "TEST" });
});
it("should return an uppercase version of a string", async () => {
const res = await request(server).get("/string/otHEr/lowercase");
const res = await request(server).get("/string/otHEr/uppercase");
expect(res.statusCode).toEqual(200);
expect(res.body).toEqual({ uppercase: "OTHER" });
});
Expand Down