Unit Tests for SuggestionsTableView#19018
Merged
twstokes merged 6 commits intowordpress-mobile:trunkfrom Jul 8, 2022
Merged
Conversation
salimbraksa
commented
Jul 8, 2022
| expectedResult3.insert(element, at: 0) | ||
| element = expectedResult3.remove(at: 14) | ||
| expectedResult3.insert(element, at: 1) | ||
| let result3 = self.suggestionsTableView.moveProminentSuggestionsToTop(searchResults: input, prominentSuggestionsIds: [10, 15]) |
Contributor
Author
There was a problem hiding this comment.
@twstokes Is it okey to construct these expectedResults like this?
Another alternative is to have those expectations as JSON files, then load them the same way we are loading user-suggestions.json.
Contributor
There was a problem hiding this comment.
It's OK, but it may be even clearer to split up those cases into their own tests. I think tests are a place where we can be more verbose and not as focused on being DRY.
I've personally been a fan of the "given / when / then" format.
ee95dc5 to
f73c719
Compare
122827a to
6a62524
Compare
twstokes
reviewed
Jul 8, 2022
| self.suggestionsTableView.suggestions = suggestions | ||
| } | ||
|
|
||
| override func tearDownWithError() throws { |
Contributor
There was a problem hiding this comment.
It'll be fine to wipe this if we don't need it. 👍
WordPress/WordPressTest/Mention/SuggestionsTableViewTests.swift
Outdated
Show resolved
Hide resolved
WordPress/WordPressTest/Mention/SuggestionsTableViewMockDelegate.swift
Outdated
Show resolved
Hide resolved
Generated by 🚫 dangerJS |
twstokes
approved these changes
Jul 8, 2022
Contributor
twstokes
left a comment
There was a problem hiding this comment.
Looks good @salimbraksa! Thanks for adding these. 🎉
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue
Part of #18979
Description
This adds Unit Tests to
SuggestionsTableViewmost critical methods, which are:Test Instructions
WordPresstarget is selectedSuggestionsTableViewTestsRegression Notes
Potential unintended areas of impact
n/a
What I did to test those areas of impact (or what existing automated tests I relied on)
n/a
What automated tests I added (or what prevented me from doing so)
n/a
PR submission checklist:
RELEASE-NOTES.txtif necessary.