Skip to content

Commit db0e59c

Browse files
kYemmrchief
andauthored
fix: Add default onAction prop (#382)
* fix: Add default onAction prop PropTypes define onAction property as optional, however in class its used unconditionally. * fix: Add console error spy check Co-authored-by: Hrusikesh Panda <[email protected]>
1 parent ee752c6 commit db0e59c

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

__snapshots__/src/index.test.js.md

+2
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ Generated by [AVA](https://ava.li).
459459
id="rdts"
460460
inlineSearchInput={false}
461461
mode="radioSelect"
462+
onAction={Function onAction {}}
462463
onBlur={Function onBlur {}}
463464
onChange={Function onChange {}}
464465
onFocus={Function onFocus {}}
@@ -609,6 +610,7 @@ Generated by [AVA](https://ava.li).
609610
}
610611
id="rdts"
611612
inlineSearchInput={false}
613+
onAction={Function onAction {}}
612614
onBlur={Function onBlur {}}
613615
onChange={Function onChange {}}
614616
onFocus={Function onFocus {}}

__snapshots__/src/index.test.js.snap

39 Bytes
Binary file not shown.

src/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class DropdownTreeSelect extends Component {
5050
}
5151

5252
static defaultProps = {
53+
onAction: () => {},
5354
onFocus: () => {},
5455
onBlur: () => {},
5556
onChange: () => {},

src/index.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ test('notifies on action', t => {
107107
t.true(handler.calledWithExactly(node0, action))
108108
})
109109

110+
test('notifies on action without onAction handler', t => {
111+
const handler = spy(console, 'error')
112+
const { tree } = t.context
113+
const wrapper = mount(<DropdownTreeSelect id={dropdownId} data={tree} showDropdown="initial" />)
114+
wrapper.find('i.fa-ban').simulate('click')
115+
t.true(handler.notCalled)
116+
handler.restore()
117+
})
118+
110119
test('notifies on node toggle', t => {
111120
const handler = spy()
112121
const { tree } = t.context

0 commit comments

Comments
 (0)