-
Notifications
You must be signed in to change notification settings - Fork 9
Add assertContainsElement #35
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
Conversation
|
Thanks for all of these PR's. Its great to see some interest in expanding on the package. Any reason why the ide-helper.php has been changed from TestResponse to TestComponent ? |
|
@sinnbeck no problem! The reason I changed the stan return is the TestComponent macro returns $this - which is actually TestComponent not TestResponse. I think I copy pasted when I first added them 😬 - so fixing my own mistake. ( I guess there might be a few others wrong too, but will sort in a separate PR) |
|
@jackbayliss Ok I might need to test it out. I think I originally set it to TestResponse as that allows phpstorm to autocomplete after it. For instance |
|
@sinnbeck Sure, we can revert those changes for now if you want - I'm not too precious about it :) |
|
@jackbayliss I think it might be a matter of whether we are asserting on a view or a response. I wonder if it is possible to make both work. Perhaps a union value is what is needed. public function assertElement($selector = 'body', $callback = null)
{
/** @var \Illuminate\Testing\TestComponent|\Illuminate\Testing\TestResponse $instance */
return $instance;
}I am thinking it might be best to revert it in this PR, and we can look into a version that works for both in a seperate? |
|
Sorry. Just read the code again. I think yours is 100% correct. But a separate PR would be nice if you dont mind? :) |
This PR introduces a new assertion method:
assertContainsElement.It acts as a shorthand for assertElementExists, making it easier to chain assertions directly off a component/view or response keeping it fluent and great for quick, simple checks without sacrificing expressiveness.
So, all you do is the selector and the attributes.
The idea being, for simple assertions such as alert banners etc, we can just do the below, as sometimes using assertElementExists feels long:
I will probably add an
assertDoesntContainElementif this gets acceptedI've added it to the ide-helper, and improved the component dom to match the other nesting items.