Skip to content
This repository was archived by the owner on Dec 23, 2022. It is now read-only.

Commit 27670af

Browse files
committed
Add a test for onUpdateInput and let warnings fail the tests. Fixes #178
1 parent 169d5df commit 27670af

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/ChipInput.js

+1
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ class ChipInput extends React.Component {
406406
onBlur, // eslint-disable-line no-unused-vars
407407
onChange, // eslint-disable-line no-unused-vars
408408
onFocus, // eslint-disable-line no-unused-vars
409+
onUpdateInput, // eslint-disable-line
409410
placeholder,
410411
required,
411412
rootRef,

src/ChipInput.spec.js

+11
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,17 @@ describe('uncontrolled mode', () => {
106106
tree.find('input').simulate('keyDown', { keyCode: 13 }) // press enter
107107
expect(handleChange).toBeCalledWith(['a', 'a'])
108108
})
109+
110+
it('calls onUpdateInput when the input changes', () => {
111+
const handleUpdateInput = jest.fn()
112+
const tree = mount(
113+
<ChipInput onUpdateInput={handleUpdateInput} />
114+
)
115+
116+
tree.find('input').getDOMNode().value = 'foo'
117+
tree.find('input').simulate('change', { target: tree.find('input').getDOMNode() })
118+
expect(handleUpdateInput).toBeCalledWith('foo')
119+
})
109120
})
110121

111122
describe('chip focusing', () => {

test/jestsetup.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import Adapter from 'enzyme-adapter-react-16'
33
// React 16 Enzyme adapter
44
Enzyme.configure({ adapter: new Adapter() })
55
// Fail tests on any warning
6-
// console.error = message => {
7-
// throw new Error(message)
8-
// }
6+
console.error = message => {
7+
throw new Error(message)
8+
}

0 commit comments

Comments
 (0)