delete tests

This commit is contained in:
Tyrel Souza 2017-11-30 23:33:22 -05:00
parent f239700c3c
commit 4dc0674c3a

View File

@ -98,3 +98,27 @@ describe("GET /todos/:id", () => {
.end(done) .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)
});
});