Skip to content

Commit

Permalink
164796901-feature(searchFunctionality): user will be able to search f…
Browse files Browse the repository at this point in the history
…or articles

- user can search for articles
[Delivers #164796901]
  • Loading branch information
toluola committed Apr 24, 2019
1 parent 8f96fa2 commit c51daf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/controllers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const searchArticle = async (req, res) => {
body: { [Op.iLike]: `%${search}%` },
description: { [Op.iLike]: `%${search}%` } } },
raw: true,
attributes: ['id', 'title']
attributes: ['id', 'title', 'body', 'description']
});

if (articleSearch.length > 0) {
Expand All @@ -21,10 +21,12 @@ export const searchArticle = async (req, res) => {
}));
}

return res.status(404).json(errorResponseFormat({
return res.status(404).json({
status: 'fail',
message: 'No Search Record Found'
}));
data: {
message: 'No Search Record Found'
}
});
} catch (error) {
return res.status(500).json(errorResponseFormat({
status: 'error',
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('Search Test', () => {
.to.have.property('status')
.eql('fail');
expect(body).should.be.an('object');
expect(body).to.have.property('message').to.eql('No Search Record Found');
expect(body.data).to.have.property('message').to.eql('No Search Record Found');
done();
});
});
Expand Down

0 comments on commit c51daf4

Please sign in to comment.