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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed logic in "42" tests #2203

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed logic in "42" tests #2203

wants to merge 1 commit into from

Conversation

rmc29
Copy link

@rmc29 rmc29 commented Apr 19, 2024

The logic in the "42" tests was backwards. It was checking that the number didn't equal 42, when it should check the number does equal 42.

The logic in the "42" tests was backwards. It was checking that the number didn't equal 42, when it should check the number does equal 42.
@@ -779,7 +779,7 @@ For instance this will work:
let schema = number().test(
'is-42',
"this isn't the number i want",
(value) => value != 42,
(value) => value === 42,
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
(value) => value === 42,
(value) => value == null || value === 42,

Copy link
Author

Choose a reason for hiding this comment

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

Are you saying you want the test to pass if the value is null?

Copy link
Owner

Choose a reason for hiding this comment

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

if its undefined or null. that is handled by required, defined etc

@@ -789,7 +789,7 @@ however this will not:

```js
let schema = number().test('is-42', "this isn't the number i want", (value) =>
Promise.resolve(value != 42),
Promise.resolve(value === 42),
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Promise.resolve(value === 42),
Promise.resolve(value == null || value === 42,),

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

2 participants