Skip to content

Commit

Permalink
Fixed autofocus warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sakharov committed Dec 19, 2017
1 parent 3a3bf6f commit 1565164
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4435,31 +4435,37 @@ describe('Select', () => {
autoFocus: true,
options: defaultOptions,
});
var input = ReactDOM.findDOMNode(instance.input).querySelector('input');
const input = ReactDOM.findDOMNode(instance.input).querySelector('input');
expect(input, 'to equal', document.activeElement);
});
it('with autofocus as well, calls focus() only once', () => {
const warn = sinon.stub(console, 'warn');
wrapper = createControl({
autofocus: true,
autoFocus: true,
options: defaultOptions,
});
var focus = sinon.spy(instance, 'focus');
const focus = sinon.spy(instance, 'focus');
instance.componentDidMount();
expect(focus, 'was called once');

warn.restore();
});
});
describe('with autofocus', () => {
it('focuses the select input on mount', () => {
const warn = sinon.stub(console, 'warn');
wrapper = createControl({
autofocus: true,
options: defaultOptions,
});
var input = ReactDOM.findDOMNode(instance.input).querySelector('input');
const input = ReactDOM.findDOMNode(instance.input).querySelector('input');
expect(input, 'to equal', document.activeElement);

warn.restore();
});
it('calls console.warn', () => {
var warn = sinon.spy(console, 'warn');
const warn = sinon.stub(console, 'warn');
wrapper = createControl({
autofocus: true,
options: defaultOptions,
Expand Down

0 comments on commit 1565164

Please sign in to comment.