Skip to content

Commit

Permalink
make test for /project/:projectId route
Browse files Browse the repository at this point in the history
relates #32
  • Loading branch information
MohammedAlghazali committed Mar 31, 2020
1 parent a9817cd commit dc511f8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/controllers/routes/admin/project/editProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const projectEdit = async (req, res, next) => {
);
res.json({
StatusCode: 200,
data: { message: 'Cohort updated successfully' },
data: { message: 'project updated successfully' },
});
} catch (err) {
next(err);
Expand Down
16 changes: 16 additions & 0 deletions server/database/config/fakeData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ INSERT INTO project (name , description , img_url , github_link , website_link ,
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA',
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3',
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal project',1),
('ca-wiki',
'Ca-wiki is a web application which allows clients to view all cohorts that have been enrolled in Code Academy. Clients can view all students who graduated from the academy so that they can view every student and his/her projects he/she participated in, his/her github page',
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA',
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3',
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal project',2),
('ca-wiki',
'Ca-wiki is a web application which allows clients to view all cohorts that have been enrolled in Code Academy. Clients can view all students who graduated from the academy so that they can view every student and his/her projects he/she participated in, his/her github page',
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA',
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3',
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal project',1),
('ca-wiki',
'Ca-wiki is a web application which allows clients to view all cohorts that have been enrolled in Code Academy. Clients can view all students who graduated from the academy so that they can view every student and his/her projects he/she participated in, his/her github page',
'https://lh3.googleusercontent.com/proxy/fp_bF_rbMIKyCfgdgWodyuM9LGt3HwGgM8AMnQ4qxjftKcvEdmhngdaeA8F6xFgRDHVzezPLT6YZarpBcqnMD5WtAvUhKJXcWS7qvS6Bn3CllitLttt_uA',
'https://github.com/GSG-G8/ca-wiki/tree/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3',
'https://github.com/GSG-G8/ca-wiki/blob/ed9f4cd9b5dc428f5420fe9a880a27e63f5f04d3/%5Blink%5D','Internal project',2),

('events-booker',
'This app to help GSG organization in organizing the registration for the events that they do. So When they announced for an event, it will be known who would like to attend and they can ensure if this person attended or not. By this way, the GSG can have information about the people who attended and they can use it in the future as they want.',
'https://d2slcw3kip6qmk.cloudfront.net/marketing/blog/2017Q2/[email protected]',
Expand Down
31 changes: 30 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('Admin, Project', () => {
const { data } = res.body;
if (err) return done(err);
const result = await connection.query(
'SELECT * from project WHERE id = 3',
'SELECT * from project WHERE id = 6',
);
expect(result.rows[0].name).toBe('Mohmmedzw851@');
expect(data.message).toBe('Cohort Added successfully');
Expand All @@ -60,3 +60,32 @@ describe('Admin, (/cohorts/:cohortId)', () => {
});
});
});

describe('Admin, (/projects/:projectId)', () => {
test('PUT Route /projects/1 status 200, json header, message:Cohort updated successfully', (done) => {
const testData = {
name: 'Mooooot',
description: 'project test',
imgUrl: 'https://github.com/GSG-G1',
githubLink: 'https://github.com/GSG-G1',
websiteLink: 'https://github.com/GSG-G1',
projectType: 'https://github.com/GSG-G1',
cohortId: '2',
};
return request(app)
.put('/api/v1/projects/5')
.send(testData)
.expect(200)
.expect('Content-Type', /json/)
.end(async (err, res) => {
if (err) return done(err);
const { message } = res.body.data;
const { rows } = await connection.query(
'SELECT * from project WHERE id = 5',
);
expect(message).toBe('project updated successfully');
expect(rows[0].name).toBe('Mooooot');
done();
});
});
});

0 comments on commit dc511f8

Please sign in to comment.