Skip to content

Commit

Permalink
Added missing tests for Async.js
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sakharov committed Dec 23, 2017
1 parent d2a3afd commit 0213219
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/Async-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
/* global describe, it, beforeEach */
/* eslint react/jsx-boolean-value: 0 */

// Emulating the DOM here, only so that if this test file gets
Expand Down Expand Up @@ -502,8 +503,7 @@ describe('Async', () => {

describe('props sync test', () => {
it('should update options on componentWillReceiveProps', () => {
createControl({
});
createControl({});
asyncInstance.componentWillReceiveProps({
options: [{
label: 'bar',
Expand All @@ -513,5 +513,27 @@ describe('Async', () => {
expect(asyncNode.querySelectorAll('[role=option]').length, 'to equal', 1);
expect(asyncNode.querySelector('[role=option]').textContent, 'to equal', 'bar');
});

it('should not update options on componentWillReceiveProps', () => {
const props = {options: []};
createControl(props);

const setStateStub = sinon.stub(asyncInstance, 'setState');
asyncInstance.componentWillReceiveProps(props);

expect(setStateStub, 'was not called');

setStateStub.restore();
});
});

describe('componentWillUnmount', () => {
it('should set _callback to null', () => {
createControl({});
expect(asyncInstance._callback, 'not to equal', null);

asyncInstance.componentWillUnmount();
expect(asyncInstance._callback, 'to equal', null);
});
});
});

0 comments on commit 0213219

Please sign in to comment.