Skip to content

Commit

Permalink
The category name is returned in the response
Browse files Browse the repository at this point in the history
Relates #27
  • Loading branch information
SajedaIsmail committed Sep 24, 2019
1 parent 016e25b commit ab11199
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/database/queries/getMealsByCat.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const connection = require('../../database/config/connection');

const getMealsByCat = (categoryName) => connection.query(
'Select * from menu_category c inner join meal m on (c.id = m.category_id) where c.name=$1',
'Select c.name as category, m.* from menu_category c inner join meal m on (c.id = m.category_id) where c.name=$1',
[categoryName],
);

Expand Down
1 change: 1 addition & 0 deletions test/getMeals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = test('Testing for getMeals route', (t) => {
'The code value must be 200 in the response body',
);
res.body.data.forEach((ele) => t.equal(ele.category_id, 1, 'All category ids must be 1'),);
res.body.data.forEach((ele) => t.equal(ele.category, 'main', 'All category names must be main'),);
t.end();
});
});
Expand Down

0 comments on commit ab11199

Please sign in to comment.