diff --git a/server/tests/server.test.js b/server/tests/server.test.js index ec137d3..24322ff 100644 --- a/server/tests/server.test.js +++ b/server/tests/server.test.js @@ -98,3 +98,27 @@ describe("GET /todos/:id", () => { .end(done) }) }); + +describe("DELETE /todos/:id", () => { + it("should delete a single todo", (done) => { + request(app) + .delete(`/todos/${dummy[0]._id.toHexString()}`) + .expect(200) + .expect((res) => { + expect(res.body.todo.text).toBe(dummy[0].text) + }) + .end(done) + }); + it("should return a 404 if todo not found", (done) => { + request(app) + .delete(`/todos/${new ObjectID()}`) + .expect(404) + .end(done) + }); + it("should return a 404 if id is bad", (done) => { + request(app) + .delete(`/todos/${dummy[0]._id.toHexString()}11111`) + .expect(404) + .end(done) + }); +});