Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I worked majorly on 2 files, namely:
In order to fix the code breaking
TestSearchCaseSensitive
test case, what I did was to have 2 copies of the data read fromcompleteworks.txt
.I made one of the copy letters all small case and then ran the sort Array index algorithm on this data.
I also made sure that the data passed as a query was converted in to small case, hence making the search for indices case insensitive.
When I was to return a portion of the text back to the user, I made use of the first copy of data i.e the unaltered version of
completworks.txt
data.In order to fix the code breaking
TestSearchDrunk
test case, what I did was to make use of a function called FindAllIndex found in the suffix array package.The function makes it possible for you to find indices of substrings that match a given regular expression.
So I went ahead to convert the query been passed into a ‘exact match’ regular expression, the regular expression generated is then passed to the FindAllIndex to get indices of all substrings with the exact match.
The two indices returned represents the start index and end index of the substring. I use these values to return a section of the article for the user.
Since the testCase was expecting only 20 items and there was the possibility of the substrings occurring more than 20 times, I limited the amount of indices returned to 20 by passing 20 as the second argument to FindAllIndex function.
In order to fix the code breaking
should load more results for “horse” when clicking “Load More”
test case, what I did was to give the load more button an id ofload-more
.Since puppetter function
page.click(‘#load-more’)
was looking for a clickable item with an id ofload-more
.