diff --git a/server/database/queries/getMealsByCat.js b/server/database/queries/getMealsByCat.js index 6246682..ffd2169 100644 --- a/server/database/queries/getMealsByCat.js +++ b/server/database/queries/getMealsByCat.js @@ -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], ); diff --git a/test/getMeals.test.js b/test/getMeals.test.js index fa9256d..dbb525c 100644 --- a/test/getMeals.test.js +++ b/test/getMeals.test.js @@ -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(); }); });