Skip to content

Commit

Permalink
edit agint #10
Browse files Browse the repository at this point in the history
  • Loading branch information
ElhamFadel committed Oct 31, 2021
1 parent d8cc7ec commit 3c4ec92
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/database/config/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ switch (NODE_ENV) {

const options = {
connectionString: dbUrl,
ssl: false,
ssl: { rejectUnauthorized: false },
};
module.exports = new Pool(options);
6 changes: 2 additions & 4 deletions server/routes/estate.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const router = require('express').Router();

// router.delete('/:estateId', isAuth, isAdmin, deleteEstate);
// const { isAuth, isAdmin } = require('../middleware');
const { isAuth, isAdmin } = require('../middleware');
const { editEstate, deleteEstate } = require('../controllers');

router.put('/:estateId', editEstate);

router.delete('/:estateId', isAuth, isAdmin, deleteEstate);
router.delete('/:estateId', deleteEstate);
module.exports = router;
47 changes: 47 additions & 0 deletions server/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ describe('Delete Specific Estate By Using Id', () => {
});
});
});

describe('test signup endpoint with all cases ', () => {
test('test sign up endpoint when success', async () => {
const res = await supertest(app)
Expand Down Expand Up @@ -250,3 +251,49 @@ describe('test signup endpoint with all cases ', () => {
});
});
});

describe('test Edit Agent data /users/:iduser ', () => {
test('test 200', async () => {
const res = await supertest(app)
.put('/api/v1/users/1')
.send({
username: 'test',
email: '[email protected]',
phone: '059985555555',
})
.expect(200)
.expect('Content-Type', /json/);
return expect(res.body).toEqual({
message: 'Agent\'s data updated successfully',
});
});

test('test 400', async () => {
const res = await supertest(app)
.put('/api/v1/users/1')
.send({
username: 'test',
email: '[email protected]',
phone: '0599',
})
.expect(400)
.expect('Content-Type', /json/);
return expect(res.body).toEqual({
message: '"phone" length must be at least 9 characters long',
});
});
test('test 404', async () => {
const res = await supertest(app)
.put('/api/v1/users/400')
.send({
username: 'test',
email: '[email protected]',
phone: '059915587555',
})
.expect(404)
.expect('Content-Type', /json/);
return expect(res.body).toEqual({
message: 'There\'s no Agent, put correct id',
});
});
});

0 comments on commit 3c4ec92

Please sign in to comment.