-
Notifications
You must be signed in to change notification settings - Fork 21
chore(component): update utils to prepare for slider #6436
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
base: main
Are you sure you want to change the base?
Conversation
|
|
Related Previews |
6febb6f to
f60963b
Compare
| import { EMPTY_VALUES } from './property-checkers/constants'; | ||
|
|
||
| export function isValueEmpty(value: unknown): boolean { | ||
| return EMPTY_VALUES.some(v => v === 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.
I'd suggest to keep the รฌsValueEmpty` function as is but change the way we compare the values.
The following would allow us to compare NaN with NaN, beside all the other values:
return EMPTY_VALUES.some(v => Object.is(v, value));
Test:
NaN === NaN-> falseObject.is(NaN, NaN)-> true
The idea behind this is, to allow editing the tested values โโwithout touching the test logic itself, thus minimizing the risk of regressions.
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.
We didnโt notice the function wasnโt working earlier because both the function and its tests were using the same EMPTY_VALUES array. As a result, NaN === NaN evaluated to true, but only because both values referred to the exact same NaN instance from that shared array. In general, itโs best to decouple tests from implementation details as much as possible to avoid false negatives like this.
packages/components/src/utils/property-checkers/tests/check-array-of.spec.ts
Outdated
Show resolved
Hide resolved
packages/components/src/utils/property-checkers/tests/check-array-of.spec.ts
Outdated
Show resolved
Hide resolved
packages/components/src/utils/property-checkers/tests/check-array-of.spec.ts
Outdated
Show resolved
Hide resolved
|
|
||
| it('should throw error if the provided value is empty', () => { | ||
| EMPTY_VALUES.forEach(emptyValue => { | ||
| [undefined, null, '', NaN].forEach(emptyValue => { |
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.
If we have to update the values which are considered as "empty", we also have to update the test.
If on the other side we can keep the constant EMPTY_VALUES on both side, this is not the case and the maintenance effort can be kept at a minimum.
|
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.
You've requested my re-review yesterday, but I can't see any changes?



๐ Description
Update component utilities that will be used in the slider component.
๐ฎ Design review
๐ Checklist