Skip to content

Commit 76ce13f

Browse files
committed
Fix Banner onDismiss not being called
1 parent 0ef2663 commit 76ce13f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/components/Banner/Banner.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ export default function Banner({
114114
const dismissButton = onDismiss
115115
? (
116116
<div className={styles.Dismiss}>
117-
<Button plain icon="cancelSmall" accessibilityLabel="Dismiss notification" />
117+
<Button
118+
plain
119+
icon="cancelSmall"
120+
onClick={onDismiss}
121+
accessibilityLabel="Dismiss notification"
122+
/>
118123
</div>
119124
)
120125
: null;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as React from 'react';
2+
import {shallow} from 'enzyme';
3+
import Banner from '..';
4+
import Button from '../../Button';
5+
6+
describe('<Banner />', () => {
7+
describe('onDismiss()', () => {
8+
it('is called when the dismiss button is clicked', () => {
9+
const spy = jest.fn();
10+
const banner = shallow(<Banner onDismiss={spy} />);
11+
banner.find(Button).simulate('click');
12+
expect(spy).toHaveBeenCalled();
13+
});
14+
});
15+
});

0 commit comments

Comments
 (0)