-
Notifications
You must be signed in to change notification settings - Fork 734
add numeric size support to Avatar's badge + unit-tests #850
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
Conversation
const uut = new Avatar({badgeProps: {size: 0}}); | ||
expect(uut.getBadgeSize()).toEqual(0); | ||
}); | ||
|
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.
Not the end of the world obviously but having 3 tests testing numeric input might be 2 tests too much 😸 .
If one of these tests fail, all of them will fail for the same reason.
For your consideration...
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.
right, keeping two for zero/undefined check + some number
src/components/avatar/index.tsx
Outdated
const badgeSize = _.get(this.props, 'badgeProps.size', DEFAULT_BADGE_SIZE); | ||
|
||
if (_.isString(badgeSize)) { | ||
return BADGE_SIZES[badgeSize]; |
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.
When you split the logic between enum and numeric size you eliminated the fallback of DEFAULT_BADGE_SIZE
for string-based sizes (currently returns undefined if sending a bad enum). Consider adding DEFAULT_BADGE_SIZE
fallback if supplied enum size isn't included in BADGE_SIZES
- to maintain old fallback logic.
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.
Right, added.
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.
Cool.
Small issues to consider 👍
…rding to default value change, removed redundant test.
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.
Small typo
fix typo Co-authored-by: Arnon <[email protected]>
Added numeric value support for Avatar's badge size.