Skip to content

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

Merged
merged 5 commits into from
Jul 19, 2020

Conversation

mendyEdri
Copy link
Contributor

Added numeric value support for Avatar's badge size.

@mendyEdri mendyEdri requested a review from ArnonZ July 12, 2020 07:10
const uut = new Avatar({badgeProps: {size: 0}});
expect(uut.getBadgeSize()).toEqual(0);
});

Copy link
Contributor

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...

Copy link
Contributor Author

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

const badgeSize = _.get(this.props, 'badgeProps.size', DEFAULT_BADGE_SIZE);

if (_.isString(badgeSize)) {
return BADGE_SIZES[badgeSize];
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, added.

Copy link
Contributor

@ArnonZ ArnonZ left a 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.
@mendyEdri mendyEdri requested a review from ArnonZ July 13, 2020 09:11
Copy link
Contributor

@ArnonZ ArnonZ left a comment

Choose a reason for hiding this comment

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

Small typo

@mendyEdri mendyEdri requested a review from ArnonZ July 19, 2020 12:50
@ArnonZ ArnonZ merged commit 63e9377 into master Jul 19, 2020
@mendyEdri mendyEdri deleted the avatar-support-numeric-badge-size branch September 15, 2020 14:45
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.

2 participants