From 0213219b288367cbf0297204825ef25141533e4c Mon Sep 17 00:00:00 2001 From: Yuri S Date: Sun, 24 Dec 2017 00:38:11 +0200 Subject: [PATCH] Added missing tests for Async.js --- test/Async-test.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/test/Async-test.js b/test/Async-test.js index f76bb19801..d8b2607aeb 100644 --- a/test/Async-test.js +++ b/test/Async-test.js @@ -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 @@ -502,8 +503,7 @@ describe('Async', () => { describe('props sync test', () => { it('should update options on componentWillReceiveProps', () => { - createControl({ - }); + createControl({}); asyncInstance.componentWillReceiveProps({ options: [{ label: 'bar', @@ -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); + }); }); });