-
Notifications
You must be signed in to change notification settings - Fork 19
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
refactor: add number util #408
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding some appropriate tests?
558d4a0
to
97dee4a
Compare
97dee4a
to
aa9bb7b
Compare
react/lib/tests/number.test.ts
Outdated
expect(zero.isEqualTo(0)).toBe(true); | ||
}); | ||
|
||
it('resolveNumber should convert various types to BigNumber', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's tests floats too (42.0, 42.5) and string floats ('42.0', '42.5'). Also, they shouldn't be in the same tests
react/lib/tests/number.test.ts
Outdated
}); | ||
|
||
it('isLessThanZero should correctly identify values less than zero', () => { | ||
expect(isLessThanZero(-1)).toBe(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isLessThanZero(-1) returns false? why?
react/lib/util/number.ts
Outdated
return new BigNumber(value); | ||
}; | ||
|
||
export const isLessThanZero = (value: BigNumber.Value) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is implemented backwards. It's named isLessThanZero
but it checks if zeroIsLessThan
020c9b7
to
a4a26f5
Compare
4eb35d3
to
fe749fd
Compare
Related to #405
Description
Added handler with BigNumber logic in utils
Test plan
yarn build && yarn dev