-
Notifications
You must be signed in to change notification settings - Fork 361
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
test: add more object utils test + remove undefined value when use with invertKeysAndValues fnc #4764
base: main
Are you sure you want to change the base?
Conversation
…th invertKeysAndValues fnc
|
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.
One optional comment but otherwise looks good! However the the build is failing. Please test your PRs locally by running yarn build && yarn test
from the monorepo root
typescript/utils/src/objects.test.ts
Outdated
expect(result).to.eql({ '1': 'a', '2': 'b' }); | ||
}); | ||
|
||
it('invertKeysAndValues should return an empty object if the object is empty', () => { |
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 is optional but consider nesting another describe
block under the outer describe
block to organize the tests by their function. E.g. a describe('invertKeysAndValues', () =>
block
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.
Thank you! Please review again
Description
Add filter
undefined/null
value when use with utils invertKeysAndValues functionAdd more test at
objects.test.ts
Drive-by changes
return Object.fromEntries( Object.entries(data) + .filter(([_, value]) => value !== undefined && value !== null) // Filter out undefined and null values .map(([key, value]) => [value, key]), );
Related issues
None
Backward compatibility
Currently, nowhere call this invertKeysAndValues func
Testing
Yes, more tests.