diff --git a/server/controllers/kindergartens/kindergartenSearch.js b/server/controllers/kindergartens/kindergartenSearch.js index d782f8e..a57a27c 100644 --- a/server/controllers/kindergartens/kindergartenSearch.js +++ b/server/controllers/kindergartens/kindergartenSearch.js @@ -13,15 +13,7 @@ const kindergartenSearch = async (req, res, next) => { abortEarly: false, }); - if (!q && (!minPrice || !maxPrice) && !locationId) { - next( - boomify( - 400, - 'Validation Error', - 'At least one of these (q, minPrice & maxPrice,locationId) values is required' - ) - ); - } else { + if (q || (minPrice && maxPrice) || locationId) { const { rows: data } = await getKindergartenSearch({ q, minPrice, @@ -33,6 +25,14 @@ const kindergartenSearch = async (req, res, next) => { StatusCode: 200, data, }); + } else { + next( + boomify( + 400, + 'Validation Error', + 'At least one of these (q, minPrice & maxPrice,locationId) values is required' + ) + ); } } catch (error) { next( diff --git a/test/search.test.js b/test/search.test.js index 4ed2bc9..280496a 100644 --- a/test/search.test.js +++ b/test/search.test.js @@ -90,7 +90,6 @@ describe('search endPoint', () => { })); test('Route /search?minPrice=500&maxPrice=1000, status 200, json header, data = testData', (done) => { - // still something TODO const testData = { id: 6, kindergarten_name: 'روضة الزهراء النموذجية الخاصة',