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

New toBeEmpty custom matcher #8

Closed
gnapse opened this issue Apr 11, 2018 · 3 comments
Closed

New toBeEmpty custom matcher #8

gnapse opened this issue Apr 11, 2018 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed needs discussion We need to discuss this to come up with a good solution

Comments

@gnapse
Copy link
Member

gnapse commented Apr 11, 2018

As discussed in #4, this library needs some sort of .toBeEmpty custom matcher. This will pass if the given element does not contain any child elements.

expect(element).toBeEmpty()

A few aspects of this are open to discussion. We'd like to come up with a different name that would be clearer and avoid name clashes with other matchers out there that might be checking emptiness of other things (e.g. array or collections of some sort).

How?

// TODO

Why?

Presumably doing the equivalent checks on one's own is not straightforward and concise enough.

@gnapse gnapse added enhancement New feature or request help wanted Extra attention is needed labels Apr 11, 2018
@gnapse gnapse added the needs discussion We need to discuss this to come up with a good solution label Apr 11, 2018
@smacpherson64
Copy link
Collaborator

smacpherson64 commented Jul 4, 2018

@gnapse with empty does this mean text nodes as well as element nodes?

If we want no text and elements we could use: element.innerHTML === ''
If we want no element children we could use element.children.length === 0

@kentcdodds
Copy link
Member

As a user I would expect empty to mean that element.innerHTML === ''

@smacpherson64
Copy link
Collaborator

Sounds good!

@smacpherson64 smacpherson64 mentioned this issue Jul 4, 2018
4 tasks
kentcdodds pushed a commit that referenced this issue Jul 5, 2018
* #8: Added test for toBeEmpty matcher

* #8: Added toBeEmpty matcher

* #8: Added documentation for toBeEmpty matcher

* #8: Updated types for toBeEmpty matcher

* Added user as contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed needs discussion We need to discuss this to come up with a good solution
Projects
None yet
Development

No branches or pull requests

3 participants