Skip to content

Commit

Permalink
Merge pull request #81 from atlp-rwanda/bg-fix-search-functionality
Browse files Browse the repository at this point in the history
bg-fix fixing search
  • Loading branch information
UmuhireJessie authored Jul 25, 2024
2 parents b76bb1c + 00b9dee commit f6f3a4f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/controllers/productSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SearchController {
const searchConditions: any = {
[Op.or]: [
{ name: { [Op.iLike]: `%${searchKeyword}%` } },
{ category: { [Op.iLike]: `%${searchKeyword}%` } },
{ description: { [Op.iLike]: `%${searchKeyword}%` } },
],
};

Expand Down
8 changes: 4 additions & 4 deletions src/tests/product/productSearch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('SearchController', () => {

it('should return products matching the search keyword', async () => {
db.Product.findAll.mockResolvedValue([
{ name: 'Test Product', category: 'TestCategory', price: 100 },
{ name: 'Test Product', description: 'TestCategory', price: 100 },
]);

const response = await request(app)
Expand All @@ -46,13 +46,13 @@ describe('SearchController', () => {

expect(response.status).toBe(200);
expect(response.body.data).toEqual([
{ name: 'Test Product', category: 'TestCategory', price: 100 },
{ name: 'Test Product', description: 'TestCategory', price: 100 },
]);
});

it('should return products within the price range', async () => {
db.Product.findAll.mockResolvedValue([
{ name: 'Test Product', category: 'TestCategory', price: 100 },
{ name: 'Test Product', description: 'TestCategory', price: 100 },
]);

const response = await request(app).get('/search').query({
Expand All @@ -63,7 +63,7 @@ describe('SearchController', () => {

expect(response.status).toBe(200);
expect(response.body.data).toEqual([
{ name: 'Test Product', category: 'TestCategory', price: 100 },
{ name: 'Test Product', description: 'TestCategory', price: 100 },
]);
});

Expand Down

0 comments on commit f6f3a4f

Please sign in to comment.