jest-extended icon indicating copy to clipboard operation
jest-extended copied to clipboard

expect: Add matcher `toBeInRange()` to validate if array elements are within the specified range

Open mayankshukla94 opened this issue 1 year ago β€’ 8 comments

What

In this PR, I have created a new matcher toBeInRange.

Why

Recently, I came across a use case where I had to validate if Year dropdown has options within the specified range. When I checked for assertions, then no such assertion found where I can specify the range and validate or assert.

Notes

Housekeeping

  • [x] Unit tests
  • [x] Documentation is up to date
  • [x] No additional lint warnings
  • [x] Typescript definitions are added/updated where relevant

mayankshukla94 avatar Jul 07 '22 09:07 mayankshukla94

@keeganwitt @mattphillips thoughts?

SimenB avatar Jul 13 '22 13:07 SimenB

Codecov Report

Merging #461 (2d7adc5) into main (bbbe109) will not change coverage. The diff coverage is 100.00%.

@@            Coverage Diff            @@
##              main      #461   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           72        73    +1     
  Lines          594       601    +7     
  Branches       151       153    +2     
=========================================
+ Hits           594       601    +7     
Impacted Files Coverage Ξ”
src/matchers/toBeInRange.js 100.00% <100.00%> (ΓΈ)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Jul 13 '22 13:07 codecov[bot]

@keeganwitt @mattphillips thoughts?

@keeganwitt @mattphillips Could you please provide your input?

mayankshukla94 avatar Aug 01 '22 10:08 mayankshukla94

This seems reasonable to me. We could make the inclusive vs exclusive more flexible, but I don't think that'd add much value, and being inclusive is what I'd kinda expect.

keeganwitt avatar Aug 03 '22 15:08 keeganwitt

Also add this matcher to the README.

keeganwitt avatar Aug 03 '22 22:08 keeganwitt

@mattphillips Thank you for the detailed review. I have made the changes. Please review again.

mayankshukla94 avatar Aug 05 '22 12:08 mayankshukla94

Hello @keeganwitt @mattphillips,

Could you please review this again?

Thanks!

mayankshukla94 avatar Aug 16 '22 03:08 mayankshukla94

@mattphillips @keeganwitt I have resolved the conflicts. Please have a look again.

mayankshukla94 avatar Sep 06 '22 03:09 mayankshukla94

Hello @SimenB @keeganwitt @mattphillips

Any update on this?

mayankshukla94 avatar Oct 04 '22 10:10 mayankshukla94

Sorry, I haven't had a chance to get back to this. I'll take a look this week.

keeganwitt avatar Oct 13 '22 14:10 keeganwitt

A few more things are needed before this is ready:

  1. https://github.com/jest-community/jest-extended/blob/main/website/docs/matchers/index.md should be updated to include this new matcher.
  2. There are two places in index.d.ts that get updated every time a new matcher is added: the Matchers interface and Expect interface. This PR only has the latter.

keeganwitt avatar Oct 14 '22 19:10 keeganwitt

A few more things are needed before this is ready:

  1. https://github.com/jest-community/jest-extended/blob/main/website/docs/matchers/index.md should be updated to include this new matcher.
  2. There are two places in index.d.ts that get updated every time a new matcher is added: the Matchers interface and Expect interface. This PR only has the latter.

Sure will update.

mayankshukla94 avatar Oct 15 '22 03:10 mayankshukla94

A few more things are needed before this is ready:

  1. https://github.com/jest-community/jest-extended/blob/main/website/docs/matchers/index.md should be updated to include this new matcher.
  2. There are two places in index.d.ts that get updated every time a new matcher is added: the Matchers interface and Expect interface. This PR only has the latter.

Sure will update.

Sounds good! Thanks for your persistence!

keeganwitt avatar Oct 15 '22 03:10 keeganwitt

@keeganwitt I have updated now. Please review

mayankshukla94 avatar Oct 15 '22 18:10 mayankshukla94