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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Feature toBeHexadecimal Matcher #152

Merged

Conversation

mvpowers
Copy link
Contributor

What

Feature

Why

This feature satisfies #149. This is a new matcher to verify a string is a valid HTML hex color.

Notes

Please let me know if I need to make any modifications 馃憤

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 Jul 31, 2018

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #152   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         101    103    +2     
  Lines         488    500   +12     
  Branches       83     85    +2     
=====================================
+ Hits          488    500   +12
Impacted Files Coverage 螖
src/matchers/toBeHexadecimal/predicate.js 100% <100%> (酶)
src/matchers/toBeHexadecimal/index.js 100% <100%> (酶)
src/matchers/index.js 100% <0%> (酶) 猬嗭笍

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 9a0f118...c51a2e0. Read the comment docs.

expect(() => expect('#eeggee').toBeHexadecimal()).toThrowErrorMatchingSnapshot();
});

test('fails when given non-string', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth having a test for a string that isn't hexadecimal as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. This boundary is already covered in the predicate test.

export default expected => {
const re1 = RegExp(/^#\b[a-f0-9]{6}\b/gi);
const re2 = RegExp(/^#\b[a-f0-9]{3}\b/gi);
return re1.test(expected) || re2.test(expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth naming these a bit more explicitly, e.g.
shortRegex
longRedex
I only ask because i read the regex 3 times before i spotted the 6 and 3 馃寽

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. This was lazy on my part.

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.

Looks good, nice one 馃憤 I can only give approval and nod quietly in the corner unfortunately though :P

@mattphillips
Copy link
Member

LGTM thanks @mvpowers

I am on my phone atm I鈥檒l release this when I鈥檓 at my computer next 馃槃

@mattphillips mattphillips merged commit 71a2e2f into jest-community:master Aug 3, 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.

None yet

4 participants