Skip to content

Commit

Permalink
Add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Zia Ul Rehman committed Sep 11, 2019
1 parent e87da21 commit 24b770d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions source/Search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ describe('Search', function() {
writers: [
{ name: 'ABC' },
{ name: 'xyz' }
],
deeplyNested: [
{
writers: [
{ name: 'deeply nested name'}
]
}
]
};
});
Expand Down Expand Up @@ -131,6 +138,20 @@ describe('Search', function() {
validateSearchResults(search.search('ABC'), [nestedArrayDocumentFoo]);
});

it('should index deeply nested arrays document properties', function() {
search.addIndex(['deeplyNested', '[]', 'writers', '[]', 'name']);
search.addDocument(nestedArrayDocumentFoo);

validateSearchResults(search.search('deeply nested'), [nestedArrayDocumentFoo]);
});

it('should not give false results for deeply nested arrays document properties', function() {
search.addIndex(['deeplyNested', '[]', 'writers', '[]', 'name']);
search.addDocument(nestedArrayDocumentFoo);

validateSearchResults(search.search('something not findable'), []);
});

it('should gracefully handle broken property path', function() {
search.addIndex(['nested', 'title', 'not', 'existing']);
search.addDocument(nestedDocumentFoo);
Expand Down

0 comments on commit 24b770d

Please sign in to comment.