From d2afa98a9a6a604943f9ad12c2cb07bd0e29494b Mon Sep 17 00:00:00 2001 From: MohammedAlghazali Date: Mon, 30 Mar 2020 21:29:54 +0300 Subject: [PATCH] add query test fot /cohorts/:cohortId route to be sure the delete done relates #29 --- test/index.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/index.test.js b/test/index.test.js index 1bf35312..89f1040b 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -13,14 +13,18 @@ afterAll(() => { }); describe('Admin, (/cohorts/:cohortId)', () => { - test('Route /cohorts/1 status 200, json header, data.message = Cohort deleted successfully ', (done) => { + test('Route /cohorts/1 status 200, data.message = Cohort deleted successfully ', (done) => { return request(app) .delete('/api/v1/cohorts/1') .expect(200) .expect('Content-Type', /json/) - .end((err, res) => { + .end(async (err, res) => { const { data } = res.body; if (err) return done(err); + const result = await connection.query( + 'SELECT * from cohort WHERE id = 1', + ); + expect(result.rows).toHaveLength(0); expect(data.message).toBe('Cohort deleted successfully'); done(); });