Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Make max as inclusive for toBeInRange() matcher #671

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/matchers/toBeInRange.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export function toBeInRange(actual, min, max) {
const { printReceived, printExpected, matcherHint } = this.utils;

const element = actual.find(option => option < min || option >= max);
const element = actual.find(option => option < min || option > max);

const pass = element === undefined;

Expand Down
2 changes: 1 addition & 1 deletion test/matchers/toBeInRange.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ expect.extend(matcher);

describe('.toBeInRange', () => {
test('passes when given array is in range', () => {
expect([4, 5, 7, 9]).toBeInRange(4, 10);
expect([4, 5, 7, 9]).toBeInRange(4, 9);
});

test('fails when given array is not in a given range', () => {
Expand Down