Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the code to pass test cases #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Big-Silver
Copy link

@Big-Silver Big-Silver commented Aug 4, 2023

I worked majorly on 2 files, namely:

  1. main.go
  2. index.html
    In order to fix the code breaking TestSearchCaseSensitive test case, what I did was to have 2 copies of the data read from completeworks.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 of load-more.
    Since puppetter function page.click(‘#load-more’) was looking for a clickable item with an id of load-more.

@Big-Silver Big-Silver changed the title Christian home task Update the code to pass test cases Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant