From 9d04c08729a36b7eff9d6d74daae882d3c9447a6 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Thu, 30 Nov 2017 23:40:34 -0500 Subject: [PATCH] more tests for delete --- server/tests/server.test.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/tests/server.test.js b/server/tests/server.test.js index 24322ff..6a917af 100644 --- a/server/tests/server.test.js +++ b/server/tests/server.test.js @@ -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) });