File tree Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -62,13 +62,8 @@ describe('Avatar Badge', () => {
62
62
63
63
describe ( 'badgeProps.size, supports enum or number' , ( ) => {
64
64
it ( 'should return 10 as the size number given' , ( ) => {
65
- const uut = new Avatar ( { badgeProps : { size : 10 } } ) ;
66
- expect ( uut . getBadgeSize ( ) ) . toEqual ( 10 ) ;
67
- } ) ;
68
-
69
- it ( 'should return 876 as the size number given' , ( ) => {
70
- const uut = new Avatar ( { badgeProps : { size : 876 } } ) ;
71
- expect ( uut . getBadgeSize ( ) ) . toEqual ( 876 ) ;
65
+ const uut = new Avatar ( { badgeProps : { size : 99 } } ) ;
66
+ expect ( uut . getBadgeSize ( ) ) . toEqual ( 99 ) ;
72
67
} ) ;
73
68
74
69
it ( 'should return 0 as the given size number' , ( ) => {
@@ -89,10 +84,10 @@ describe('Avatar Badge', () => {
89
84
expect ( uut . getBadgeSize ( ) ) . toEqual ( BADGE_SIZES [ lastSizeKey ] ) ;
90
85
} ) ;
91
86
92
- it ( 'should return undefined for a non-exist size type' , ( ) => {
87
+ it ( 'should return a default value from Badge for a non-exist size type' , ( ) => {
93
88
const sizeKey = '!NOT_A_VALID_ENUM$' ;
94
89
const uut = new Avatar ( { badgeProps : { size : sizeKey } } ) ;
95
- expect ( uut . getBadgeSize ( ) ) . toBeUndefined ( ) ;
90
+ expect ( typeof uut . getBadgeSize ( ) ) . toBe ( 'number' ) ;
96
91
} ) ;
97
92
} ) ;
98
93
} ) ;
Original file line number Diff line number Diff line change @@ -224,9 +224,9 @@ class Avatar extends PureComponent<AvatarPropTypes> {
224
224
225
225
getBadgeSize = ( ) => {
226
226
const badgeSize = _ . get ( this . props , 'badgeProps.size' , DEFAULT_BADGE_SIZE ) ;
227
-
227
+
228
228
if ( _ . isString ( badgeSize ) ) {
229
- return BADGE_SIZES [ badgeSize ] ;
229
+ return BADGE_SIZES [ badgeSize ] || BADGE_SIZES [ DEFAULT_BADGE_SIZE ] ;
230
230
}
231
231
return badgeSize ;
232
232
}
You can’t perform that action at this time.
0 commit comments