|
1 | 1 | import {Avatar} from '../index';
|
2 | 2 | import {Colors} from '../../../style';
|
| 3 | +import {BADGE_SIZES} from '../../badge'; |
3 | 4 |
|
4 | 5 | describe('Avatar Badge', () => {
|
5 | 6 | describe('getStatusBadgeColor', () => {
|
@@ -58,4 +59,40 @@ describe('Avatar Badge', () => {
|
58 | 59 | expect(uut.renderBadge()).toEqual(undefined);
|
59 | 60 | });
|
60 | 61 | });
|
| 62 | + |
| 63 | + describe('badgeProps.size, supports enum or number', () => { |
| 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); |
| 72 | + }); |
| 73 | + |
| 74 | + it('should return 0 as the given size number', () => { |
| 75 | + const uut = new Avatar({badgeProps: {size: 0}}); |
| 76 | + expect(uut.getBadgeSize()).toEqual(0); |
| 77 | + }); |
| 78 | + |
| 79 | + it('should return the first badge size mapped by given key', () => { |
| 80 | + const firstSizeKey = Object.keys(BADGE_SIZES)[1]; |
| 81 | + const uut = new Avatar({badgeProps: {size: firstSizeKey}}); |
| 82 | + expect(uut.getBadgeSize()).toEqual(BADGE_SIZES[firstSizeKey]); |
| 83 | + }); |
| 84 | + |
| 85 | + it('should return the last badge size mapped by given key', () => { |
| 86 | + const keys = Object.keys(BADGE_SIZES); |
| 87 | + const lastSizeKey = keys[keys.length - 1]; |
| 88 | + const uut = new Avatar({badgeProps: {size: lastSizeKey}}); |
| 89 | + expect(uut.getBadgeSize()).toEqual(BADGE_SIZES[lastSizeKey]); |
| 90 | + }); |
| 91 | + |
| 92 | + it('should return undefined for a non-exist size type', () => { |
| 93 | + const sizeKey = '!NOT_A_VALID_ENUM$'; |
| 94 | + const uut = new Avatar({badgeProps: {size: sizeKey}}); |
| 95 | + expect(uut.getBadgeSize()).toBeUndefined(); |
| 96 | + }); |
| 97 | + }); |
61 | 98 | });
|
0 commit comments