more tests for delete
This commit is contained in:
parent
4dc0674c3a
commit
9d04c08729
@ -107,7 +107,15 @@ describe("DELETE /todos/:id", () => {
|
|||||||
.expect((res) => {
|
.expect((res) => {
|
||||||
expect(res.body.todo.text).toBe(dummy[0].text)
|
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) => {
|
it("should return a 404 if todo not found", (done) => {
|
||||||
request(app)
|
request(app)
|
||||||
@ -117,7 +125,7 @@ describe("DELETE /todos/:id", () => {
|
|||||||
});
|
});
|
||||||
it("should return a 404 if id is bad", (done) => {
|
it("should return a 404 if id is bad", (done) => {
|
||||||
request(app)
|
request(app)
|
||||||
.delete(`/todos/${dummy[0]._id.toHexString()}11111`)
|
.delete(`/todos/123`)
|
||||||
.expect(404)
|
.expect(404)
|
||||||
.end(done)
|
.end(done)
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user