Skip to content

Commit

Permalink
fix: hyperlink button bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kiram15 committed Jun 6, 2023
1 parent 4485a3c commit a98ecdb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Button/Button.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import renderer from 'react-test-renderer';

import { Close } from '../../icons';
import Button from './index';
import Hyperlink from '../Hyperlink';

describe('<Button />', () => {
describe('correct rendering', () => {
Expand Down Expand Up @@ -82,6 +83,12 @@ describe('<Button />', () => {
emptyHref.simulate('click');
expect(onClick).toHaveBeenCalled();
});
test('test button as hyperlink', () => {
const wrapper = mount((
<Button as={Hyperlink} destination='https://www.poop.com/💩'>Button</Button>
));
expect(wrapper.find('a').prop('href')).toEqual('https://www.poop.com/💩');
});
});
});
});
3 changes: 0 additions & 3 deletions src/Button/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ Button.propTypes = {
/** A function that would specify what the button should do when the `onClick` event is triggered.
* For example, the button could launch a `Modal`. The default is an empty function. */
onClick: PropTypes.func,
/** Providing a `href` will render an `<a>` element, styled as a button. */
href: PropTypes.string,
/** A function that would specify what the button should do when the `onKeyDown` event is triggered.
* For example, this could handle using the `Escape` key to trigger the button's action.
* The default is an empty function. */
Expand Down Expand Up @@ -66,7 +64,6 @@ Button.defaultProps = {
className: undefined,
iconBefore: undefined,
iconAfter: undefined,
href: undefined,
disabled: false,
};

Expand Down

0 comments on commit a98ecdb

Please sign in to comment.