Skip to content

fix(prefer-to-have-attribute): Handle case where matcher value is empty string #180

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

Merged

Conversation

mdotwills
Copy link
Contributor

What:

Bugfix to handle case where in circumstances that the matcher value has been intended as an empty string, the fixer incorrectly assumes the .not case.

Why:

The purpose of this fix is so that the code fixer can correctly match empty string attributes as differentiated from null or missing values.

How:

Do not treat an empty string as a null value.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

Feel free to merge if approved.

…pty string value

This change purposefully treats an empty string value for certain matchers as
value instead of as null. Prior to this change, the fixer was incorrectly
inferring a .not.

Matchers affected are:

- toBe
- toStrictEqual
- toEqual
@codecov
Copy link

codecov bot commented Jun 12, 2021

Codecov Report

Merging #180 (1dd641b) into main (58998b3) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 1dd641b differs from pull request most recent head 5f69ea8. Consider uploading reports for the commit 5f69ea8 to get more accurate results
Impacted file tree graph

@@            Coverage Diff            @@
##              main      #180   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines          555       555           
  Branches       152       152           
=========================================
  Hits           555       555           
Impacted Files Coverage Δ
src/rules/prefer-to-have-attribute.js 100.00% <100.00%> (ø)

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 6bc032d...5f69ea8. Read the comment docs.

@benmonro
Copy link
Member

@all-contributors add @mdotwills for bugs, code

@allcontributors
Copy link
Contributor

@benmonro

I've put up a pull request to add @mdotwills! 🎉

@benmonro benmonro merged commit 1e20f0c into testing-library:main Sep 11, 2021
@github-actions
Copy link

🎉 This PR is included in version 3.9.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants