Skip to content

Commit

Permalink
fix(Alert): Properly spread props when transition={false} (#5545)
Browse files Browse the repository at this point in the history
* Invert ternary

* Add test(s) for prop resting

Co-authored-by: iLan Epstein <iepstein@tableau.com>
  • Loading branch information
thepuzzlemaster and iLan Epstein committed Dec 3, 2020
1 parent d337c95 commit 1352a87
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const Alert = (React.forwardRef<HTMLDivElement, AlertProps>(
const alert = (
<div
role="alert"
{...(Transition ? props : undefined)}
{...(!Transition ? props : undefined)}
ref={ref}
className={classNames(
className,
Expand Down
20 changes: 20 additions & 0 deletions test/AlertSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ describe('<Alert>', () => {
expect(wrapper.find('.fade').length).to.equal(0);
});

it('should spread props to alert when transition=false', () => {
const alertId = 'alert-id';
const wrapper = mount(
<Alert transition={false} id={alertId}>
Message
</Alert>,
);
expect(wrapper.getDOMNode().getAttribute('id')).to.equal(alertId);
});

it('should spread props to alert when transition=true', () => {
const alertId = 'alert-id';
const wrapper = mount(
<Alert transition id={alertId}>
Message
</Alert>,
);
expect(wrapper.getDOMNode().getAttribute('id')).to.equal(alertId);
});

it('should use Fade when transition=true', () => {
mount(
<Alert variant="danger" transition>
Expand Down

0 comments on commit 1352a87

Please sign in to comment.