Skip to content

Commit

Permalink
fix(Alert): Fix transition prop to allow bools
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletsang committed Jul 14, 2020
1 parent efa79cd commit f4e7630
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Alert.tsx
Expand Up @@ -77,8 +77,12 @@ const propTypes = {
*/
closeLabel: PropTypes.string,

/** A `react-transition-group` Transition component used to animate the Alert on dismissal. */
transition: elementType,
/**
* Animate the alert dismissal. Defaults to using `<Fade>` animation or use
* `false` to disable. A custom `react-transition-group` Transition can also
* be provided.
*/
transition: PropTypes.oneOfType([PropTypes.bool, elementType]),
};

const defaultProps = {
Expand Down
22 changes: 22 additions & 0 deletions test/AlertSpec.js
Expand Up @@ -43,6 +43,28 @@ describe('<Alert>', () => {
ref.current.tagName.should.equal('DIV');
});

it('should not have fade class when transition=false', () => {
const wrapper = mount(<Alert transition={false}>Message</Alert>);
expect(wrapper.find('.fade').length).to.equal(0);
});

it('should use Fade when transition=true', () => {
mount(
<Alert variant="danger" transition>
Message
</Alert>,
).assertSingle('.fade');
});

it('should render null when transition and show are false', () => {
const wrapper = mount(
<Alert transition={false} show={false}>
Message
</Alert>,
);
expect(wrapper.isEmptyRender()).to.be.true;
});

describe('Web Accessibility', () => {
it('Should have alert role', () => {
mount(<Alert>Message</Alert>).assertSingle('[role="alert"]');
Expand Down

0 comments on commit f4e7630

Please sign in to comment.