more tests for delete

This commit is contained in:
Tyrel Souza 2017-11-30 23:40:34 -05:00
parent 4dc0674c3a
commit 9d04c08729
1 changed files with 10 additions and 2 deletions

View File

@ -107,7 +107,15 @@ describe("DELETE /todos/:id", () => {
.expect((res) => {
expect(res.body.todo.text).toBe(dummy[0].text)
})
.end(done)
.end((err, res) => {
if(err){
return done(err);
}
Todo.findById(dummy[0]._id.toHexString()).then((todo) => {
expect(todo).toNotExist();
done();
}).catch((e) => done(e));
});
});
it("should return a 404 if todo not found", (done) => {
request(app)
@ -117,7 +125,7 @@ describe("DELETE /todos/:id", () => {
});
it("should return a 404 if id is bad", (done) => {
request(app)
.delete(`/todos/${dummy[0]._id.toHexString()}11111`)
.delete(`/todos/123`)
.expect(404)
.end(done)
});