Skip to content

Commit

Permalink
Merge pull request #2231 from yuri-sakharov/fix/warnings-in-tests-2
Browse files Browse the repository at this point in the history
Fixed all warnings on running tests
  • Loading branch information
JedWatson authored Jan 4, 2018
2 parents d12ea53 + 1565164 commit c01031f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 1 addition & 2 deletions test/AsyncCreatable-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ var sinon = require('sinon');
var Select = require('../src');

describe('AsyncCreatable', () => {
let creatableInstance, creatableNode, filterInputNode, loadOptions, renderer;
let creatableInstance, creatableNode, filterInputNode, loadOptions;

beforeEach(() => {
loadOptions = sinon.stub();
renderer = TestUtils.createRenderer();
});

function createControl (props = {}) {
Expand Down
6 changes: 2 additions & 4 deletions test/Creatable-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ var TestUtils = require('react-dom/test-utils');
var Select = require('../src');

describe('Creatable', () => {
let creatableInstance, creatableNode, filterInputNode, innerSelectInstance, renderer;

beforeEach(() => renderer = TestUtils.createRenderer());
let creatableInstance, creatableNode, filterInputNode, innerSelectInstance;

const defaultOptions = [
{ value: 'one', label: 'One' },
Expand Down Expand Up @@ -221,7 +219,7 @@ describe('Creatable', () => {
expect(test(newOption('qux', 4)), 'to be', true);
expect(test(newOption('Foo', 11)), 'to be', true);
});

it('default: isOptionUnique function should always return true if given options are empty', () => {
const options = [];

Expand Down
16 changes: 12 additions & 4 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4435,36 +4435,44 @@ 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,
});
expect(warn, 'was called once');

warn.restore();
});
});
describe('rtl', () => {
Expand Down

0 comments on commit c01031f

Please sign in to comment.