From 3a3bf6f5907cc136ef549fd59df42cf36b5ca972 Mon Sep 17 00:00:00 2001 From: Yuri S Date: Tue, 19 Dec 2017 11:17:29 +0200 Subject: [PATCH 1/2] Fixed two warnings on running tests --- test/AsyncCreatable-test.js | 3 +-- test/Creatable-test.js | 6 ++---- test/Select-test.js | 2 ++ 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/test/AsyncCreatable-test.js b/test/AsyncCreatable-test.js index 514a40bd8e..c891f981f5 100644 --- a/test/AsyncCreatable-test.js +++ b/test/AsyncCreatable-test.js @@ -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 = {}) { diff --git a/test/Creatable-test.js b/test/Creatable-test.js index 5a58726e3a..488eb1f78f 100644 --- a/test/Creatable-test.js +++ b/test/Creatable-test.js @@ -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' }, @@ -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 = []; diff --git a/test/Select-test.js b/test/Select-test.js index 3b00677e4d..5bee909129 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -4465,6 +4465,8 @@ describe('Select', () => { options: defaultOptions, }); expect(warn, 'was called once'); + + warn.restore(); }); }); describe('rtl', () => { From 15651643f6522c2792515a40d38ec3329d55aacd Mon Sep 17 00:00:00 2001 From: Yuri S Date: Tue, 19 Dec 2017 11:28:49 +0200 Subject: [PATCH 2/2] Fixed autofocus warnings --- test/Select-test.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/Select-test.js b/test/Select-test.js index 5bee909129..356b5fafeb 100644 --- a/test/Select-test.js +++ b/test/Select-test.js @@ -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,