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

extend toBeEmpty to support Map, Set, and any other iterable #160

Merged
merged 6 commits into from
Sep 23, 2018

Conversation

moredip
Copy link
Contributor

@moredip moredip commented Aug 15, 2018

What

Teach toBeEmpty how to test for emptiness of any Iterable.

Why

Implements #158. Adds support for testing emptiness of Map and Set, amongst others.

Notes

@mattphillips suggested implementing this using [...value].length === 0. That would have been a neat, terse implementation but would not have worked for non-terminating iterables (which admittedly is a pretty obscure edge case). A more plausible advantage of not using the destructuring approach is that we avoid unecessary evaluation of potentially large/expensive iterables - we only need to go as far as yielding one value. Not really a huge deal either way, but it seemed a good tradeoff to make the implementation a bit bigger in exchange for supporting weird custom iterables.

Housekeeping

  • Unit tests
  • Documentation is up to date
  • No additional lint warnings
  • Add yourself to contributors list (yarn contributor)
  • Typescript definitions are added/updated where relevant

@codecov-io
Copy link

codecov-io commented Aug 15, 2018

Codecov Report

Merging #160 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #160   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         103    103           
  Lines         500    505    +5     
  Branches       85     86    +1     
=====================================
+ Hits          500    505    +5
Impacted Files Coverage Δ
src/matchers/toBeEmpty/predicate.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ce675a8...7ae16bf. Read the comment docs.

Copy link
Contributor

@benjaminkay93 benjaminkay93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this alot, wd!

@mattphillips
Copy link
Member

@moredip sorry for the delay in getting this merged! Looks great thanks 👍

@mattphillips mattphillips merged commit abe047c into jest-community:master Sep 23, 2018
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.

4 participants