-
Notifications
You must be signed in to change notification settings - Fork 22
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
Added tester for RouterLink. #1810
Conversation
var targetlessRouterLink = $routerLinkView.find(RouterLink.class) | ||
.withText("No Target") | ||
.single(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest making all RouterLink components as package protected class fields so that the test can directly wrap the instance, without relying on find
.
This allows to prevent false positives in tests because of potential bugs in the component locator.
IMO it also simplifies the test code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would revert changes to this file that are not related to RouterLink
*/ | ||
public Component click() { | ||
if (getRoute().isEmpty()) { | ||
throw new IllegalStateException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exception requires an explanatory message
* | ||
* @return navigated view | ||
*/ | ||
public Component click() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about returning HasElement
to be consistent with AnchorTester
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method should ensure that the component is usable by calling ensureComponentIsUsable()
.
I mean, the check is done indirectly done by getPath()
, but I think it would be good to make it more explicit.
Assertions.assertDoesNotThrow(() -> $targetView.find(Span.class) | ||
.withText("Static Target View") | ||
.single()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for RouterLink
, what about having the Span as a package protected field and simply assert on its getText()
?
dc98d56
to
f2142aa
Compare
Description
Adds missing
ComponentTester
forRouterLink
. (Attempting to useAnchorTester
in its place results in an error due toAnchor
andRouterLink
being differentComponents
.Tester methods include
getHref
getPath
getQueryParameters
getRoute
click
Fixes #1805
Type of change
Checklist
Additional for
Feature
type of change