Skip to content

Commit ac42d5d

Browse files
committed
fix: Update tests/story
1 parent 39cc255 commit ac42d5d

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

__snapshots__/src/index.test.js.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Generated by [AVA](https://ava.li).
1111
<div
1212
className="react-dropdown-tree-select"
1313
id="rdts"
14+
onBlur={Function {}}
15+
onFocus={Function {}}
1416
>
1517
<div
1618
className="dropdown"
@@ -180,6 +182,8 @@ Generated by [AVA](https://ava.li).
180182
<div
181183
className="react-dropdown-tree-select"
182184
id="rdts"
185+
onBlur={Function {}}
186+
onFocus={Function {}}
183187
>
184188
<div
185189
className="dropdown"
@@ -348,6 +352,8 @@ Generated by [AVA](https://ava.li).
348352
<div
349353
className="react-dropdown-tree-select"
350354
id="rdts"
355+
onBlur={Function {}}
356+
onFocus={Function {}}
351357
>
352358
<div
353359
className="dropdown"
@@ -469,6 +475,8 @@ Generated by [AVA](https://ava.li).
469475
<div
470476
className="react-dropdown-tree-select"
471477
id="rdts"
478+
onBlur={Function {}}
479+
onFocus={Function {}}
472480
>
473481
<div
474482
className="dropdown radio-select"
@@ -620,6 +628,8 @@ Generated by [AVA](https://ava.li).
620628
<div
621629
className="react-dropdown-tree-select"
622630
id="rdts"
631+
onBlur={Function {}}
632+
onFocus={Function {}}
623633
>
624634
<div
625635
className="dropdown"
@@ -689,6 +699,8 @@ Generated by [AVA](https://ava.li).
689699
<div
690700
className="react-dropdown-tree-select"
691701
id="rdts"
702+
onBlur={Function {}}
703+
onFocus={Function {}}
692704
>
693705
<div
694706
className="dropdown"
81 Bytes
Binary file not shown.

docs/src/stories/Options/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ class WithOptions extends PureComponent {
3232
onNodeToggle = curNode => {
3333
console.log('onNodeToggle::', curNode)
3434
}
35+
onFocus = (node, action) => {
36+
console.log('onFocus::', action, node)
37+
}
38+
onBlur = (node, action) => {
39+
console.log('onBlur::', action, node)
40+
}
3541

3642
onOptionsChange = value => {
3743
this.setState({ [value]: !this.state[value] })
@@ -121,6 +127,8 @@ class WithOptions extends PureComponent {
121127
id="rdts"
122128
data={data}
123129
onChange={this.onChange}
130+
onBlur={this.onBlur}
131+
onFocus={this.onFocus}
124132
onAction={this.onAction}
125133
onNodeToggle={this.onNodeToggle}
126134
clearSearchOnChange={clearSearchOnChange}

src/index.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,16 @@ test('deactivates dropdown active on blur', t => {
243243
test('detects click outside', t => {
244244
const { tree } = t.context
245245
const wrapper = mount(<DropdownTreeSelect data={tree} />)
246-
const handleOutsideClick = spy(wrapper.instance(), 'handleOutsideClick')
246+
const handleDropdownCollapse = spy(wrapper.instance(), 'handleDropdownCollapse')
247247

248+
wrapper.instance().onFocus()
248249
wrapper.instance().handleClick()
249250
t.true(wrapper.state().showDropdown)
250251

251252
const event = new MouseEvent('click', { bubbles: true, cancelable: true })
252253
global.document.dispatchEvent(event)
253254

254-
t.true(handleOutsideClick.calledOnce)
255+
t.true(handleDropdownCollapse.calledOnce)
255256
t.false(wrapper.state().showDropdown)
256257
})
257258

@@ -270,7 +271,7 @@ test('detects click inside', t => {
270271
target: checkboxItem,
271272
})
272273
Object.defineProperty(event, 'target', { value: checkboxItem, enumerable: true })
273-
wrapper.instance().handleOutsideClick(event)
274+
wrapper.instance().handleDropdownCollapse(event)
274275

275276
t.true(wrapper.state().showDropdown)
276277
})
@@ -291,7 +292,7 @@ test('detects click outside when other dropdown instance', t => {
291292
target: searchInput,
292293
})
293294
Object.defineProperty(event, 'target', { value: searchInput, enumerable: true })
294-
wrapper1.instance().handleOutsideClick(event)
295+
wrapper1.instance().handleDropdownCollapse(event)
295296

296297
t.false(wrapper1.state().showDropdown)
297298
})

0 commit comments

Comments
 (0)