diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index 64a049a63d..c1905bc13b 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -147,6 +147,10 @@ export type Props = $Omit, 'mode'> & { * testID to be used on tests. */ testID?: string; + /** + * Number of lines the label text is limited to. Defaults to 1 + */ + numberOfLines?: number; }; /** @@ -196,6 +200,7 @@ const Button = ( background, maxFontSizeMultiplier, touchableRef, + numberOfLines = 1, ...rest }: Props, ref: React.ForwardedRef @@ -383,7 +388,7 @@ const Button = ( { transform: [{ scale: 1.5 }], }); }); + +describe('numberOfLines', ()=> { + it('defaults to 1', () => { + const { getByTestId } = render( + + ); + expect(getByTestId('button-text')).toHaveProp('numberOfLines', 1); + }) + it('matches specified prop', () => { + const { getByTestId } = render( + + ); + expect(getByTestId('button-text')).toHaveProp('numberOfLines', 2); + }) +}); +