Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed all warnings on running tests #2231

Merged
merged 2 commits into from
Jan 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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