Skip to content

Commit

Permalink
fix error in addProject query
Browse files Browse the repository at this point in the history
realtes #33
  • Loading branch information
MohammedAlghazali committed Apr 2, 2020
1 parent fcb7e2d commit c8a7e65
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 30 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
"parserOptions": {
"ecmaVersion": 2018
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx"]
}
}
},
"plugins": [
"prettier",
"jest"
Expand Down
2 changes: 1 addition & 1 deletion server/database/queries/project/addProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const addProjectQuery = (data) => {
projectType,
cohortId,
} = data;
connection.query(
return connection.query(
'INSERT INTO project (name, description, img_url, github_link, website_link, project_type, cohort_id) VALUES ($1, $2, $3, $4, $5, $6, $7)',
[name, description, imgUrl, githubLink, websiteLink, projectType, cohortId],
);
Expand Down
59 changes: 30 additions & 29 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,35 +283,36 @@ describe('Admin, (/projects/:projectId)', () => {
});
});

// describe('Admin, Post Project', () => {
// test('Route /projects status 200, json header, data.message = Project Added successfully ', (done) => {
// const reqData = {
// name: 'Mohmmedzw851@',
// description: 'description',
// imgUrl: 'https://avatars3.githubusercontent.com/u/52123464?s=200&v=4',
// githubLink: 'https://avatars3.githubusercontent.com/u/52123464?s=200&v=4',
// websiteLink:
// 'https://avatars3.githubusercontent.com/u/52123464?s=200&v=4',
// projectType: 'internal',
// cohortId: '1',
// };
// return request(app)
// .post('/api/v1/projects')
// .send(reqData)
// .expect(201)
// .expect('Content-Type', /json/)
// .end(async (err, res) => {
// const { message } = res.body.data;
// if (err) return done(err);
// const { rows } = await connection.query(
// 'SELECT * from project WHERE id = 8',
// );
// expect(rows[0].name).toBe('Mohmmedzw851@');
// expect(message).toBe('Project Added successfully');
// done();
// });
// });
// });
describe('Admin, Post Project', () => {
test('Route /projects status 200, json header, data.message = Project Added successfully ', (done) => {
const reqData = {
name: 'Mohmmedzw851@',
description: 'description',
imgUrl: 'https://avatars3.githubusercontent.com/u/52123464?s=200&v=4',
githubLink: 'https://avatars3.githubusercontent.com/u/52123464?s=200&v=4',
websiteLink:
'https://avatars3.githubusercontent.com/u/52123464?s=200&v=4',
projectType: 'internal',
cohortId: '1',
};
return request(app)
.post('/api/v1/projects')
.send(reqData)
.expect(201)
.expect('Content-Type', /json/)
.end(async (err, res) => {
const { message } = res.body.data;
if (err) return done(err);
const { rows } = await connection.query(
'SELECT * from project WHERE id = 8',
);
console.log(rows);
expect(rows[0].name).toBe('Mohmmedzw851@');
expect(message).toBe('Project Added successfully');
done();
});
});
});

describe('Delete specific student by ID', () => {
test('Route /alumni/1 status 200, data.message = Student deleted successfully ', (done) => {
Expand Down

0 comments on commit c8a7e65

Please sign in to comment.