Skip to content

Commit

Permalink
add query test fot /cohorts/:cohortId route to be sure the delete done
Browse files Browse the repository at this point in the history
relates #29
  • Loading branch information
MohammedAlghazali committed Mar 30, 2020
1 parent df31b0a commit d2afa98
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit d2afa98

Please sign in to comment.