Fix/16620/button href prop (#16633)

* fix button href prop passed

* improve test
feature/default_network_editable
Garrett Bear 2 years ago committed by GitHub
parent 086a7d0483
commit e9508b4f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      ui/components/component-library/button-base/button-base.js
  2. 10
      ui/components/component-library/button-base/button-base.test.js

@ -35,6 +35,7 @@ export const ButtonBase = ({
return (
<Box
as={Tag}
href={href}
paddingLeft={size === BUTTON_BASE_SIZES.AUTO ? 0 : 4}
paddingRight={size === BUTTON_BASE_SIZES.AUTO ? 0 : 4}
className={classnames(

@ -24,11 +24,17 @@ describe('ButtonBase', () => {
expect(anchor).toBe(1);
});
it('should render anchor element correctly by href only being passed', () => {
it('should render anchor element correctly by href only being passed and href exists', () => {
const { getByTestId, container } = render(
<ButtonBase href="#" data-testid="button-base" />,
<ButtonBase href="https://www.test.com/" data-testid="button-base">
Button Base
</ButtonBase>,
);
expect(getByTestId('button-base')).toHaveClass('mm-button');
expect(getByTestId('button-base')).toHaveAttribute(
'href',
'https://www.test.com/',
);
const anchor = container.getElementsByTagName('a').length;
expect(anchor).toBe(1);
});

Loading…
Cancel
Save