diff --git a/src/avatar/Avatar.tsx b/src/avatar/Avatar.tsx index 14d4959568..330c82d7d2 100644 --- a/src/avatar/Avatar.tsx +++ b/src/avatar/Avatar.tsx @@ -74,8 +74,8 @@ const AvatarComponent: Avatar = ({ children, ...attributes }: React.PropsWithChildren) => { - const width = - typeof size === 'number' ? size : avatarSizes[size] || avatarSizes.small; + let width = avatarSizes.small; + width = typeof size === 'number' ? size : avatarSizes[size]; const height = width; const titleSize = width / 2; const iconSize = width / 2; diff --git a/src/avatar/__tests__/Avatar.js b/src/avatar/__tests__/Avatar.js index 7ec50a3849..ec38de87db 100644 --- a/src/avatar/__tests__/Avatar.js +++ b/src/avatar/__tests__/Avatar.js @@ -118,6 +118,14 @@ describe('Avatar Component', () => { expect(component.length).toBe(1); expect(toJson(component)).toMatchSnapshot(); }); + + it('default', () => { + const component = shallow( + + ); + expect(component.length).toBe(1); + expect(toJson(component)).toMatchSnapshot(); + }); }); describe('Placeholders', () => { @@ -170,6 +178,19 @@ describe('Avatar Component', () => { expect(toJson(component)).toMatchSnapshot(); }); + it('renders using image with imageProps', () => { + const component = shallow( + + ); + expect(toJson(component)).toMatchSnapshot(); + }); + it("shouldn't show placeholder if not using source", () => { const component = shallow( `; +exports[`Avatar Component Placeholders renders using image with imageProps 1`] = ` + + + +`; + exports[`Avatar Component Placeholders shouldn't show placeholder if not using source 1`] = ` `; +exports[`Avatar Component Sizes default 1`] = ` + + + +`; + exports[`Avatar Component allows custom imageProps 1`] = ` `; +exports[`withBadge HOC just value should render when no value 1`] = ` + + + + +`; + exports[`withBadge HOC just value should render with just a value 1`] = ` { expect(component.length).toBe(1); expect(toJson(component)).toMatchSnapshot(); }); + + it('should render when no value', () => { + const BadgedComponent = withBadge()(TouchableOpacity); + const component = shallow(); + expect(component.length).toBe(1); + expect(toJson(component)).toMatchSnapshot(); + }); }); describe('with options', () => { diff --git a/src/buttons/__tests__/Button.js b/src/buttons/__tests__/Button.js index 7dc6eb2447..13c438f01c 100644 --- a/src/buttons/__tests__/Button.js +++ b/src/buttons/__tests__/Button.js @@ -8,6 +8,20 @@ import { ThemeProvider } from '../../config'; import ThemedButton, { Button } from '../Button'; describe('Button Component', () => { + beforeEach(() => { + let useEffect = jest.spyOn(React, 'useEffect'); + useEffect.mockImplementation((f) => f()); + const app = shallow( +