From c5a9731bc9bb15471145fe5bca5713dd1816a6bc Mon Sep 17 00:00:00 2001 From: mayankshukla94 Date: Wed, 8 Nov 2023 11:15:18 +0530 Subject: [PATCH 1/2] Make max as inclusive --- src/matchers/toBeInRange.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matchers/toBeInRange.js b/src/matchers/toBeInRange.js index 8a613b3d..2f9cf68b 100644 --- a/src/matchers/toBeInRange.js +++ b/src/matchers/toBeInRange.js @@ -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; From 36d612540077eee521585c151d33580e3013ba66 Mon Sep 17 00:00:00 2001 From: mayankshukla94 Date: Thu, 9 Nov 2023 10:42:09 +0530 Subject: [PATCH 2/2] Update range in spec --- test/matchers/toBeInRange.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/matchers/toBeInRange.test.js b/test/matchers/toBeInRange.test.js index 7743cdea..571f5f70 100644 --- a/test/matchers/toBeInRange.test.js +++ b/test/matchers/toBeInRange.test.js @@ -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', () => {