From 1324583cba794495fd34386dd84ec98aeb9e63c3 Mon Sep 17 00:00:00 2001 From: Nimish Jha Date: Fri, 25 May 2018 17:13:36 +1000 Subject: [PATCH] Fix CheckboxGroup tests to use process.nextTick() to ensure state is updated --- .../adslot-ui/CheckboxGroup/index.spec.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/adslot-ui/CheckboxGroup/index.spec.jsx b/src/components/adslot-ui/CheckboxGroup/index.spec.jsx index db7a39bb5..03d20ddf5 100644 --- a/src/components/adslot-ui/CheckboxGroup/index.spec.jsx +++ b/src/components/adslot-ui/CheckboxGroup/index.spec.jsx @@ -30,12 +30,13 @@ describe('CheckboxGroup', () => { ); - const childCheckboxes = component.find('Checkbox'); const firstChild = childCheckboxes.at(0); - const event = { target: { value: 'terminator', checked: false } }; + const event = { target: { value: 'terminator' } }; firstChild.simulate('change', event); - expect(component.state().value).to.eql({ terminator: false, predator: true, soundofmusic: false }); + process.nextTick(() => { + expect(component.state().value).to.eql({ terminator: false, predator: true, soundofmusic: false }); + }); expect(onChangeGroup.callCount).to.equal(1); expect(onChangeIndividual.callCount).to.equal(1); }); @@ -54,7 +55,7 @@ describe('CheckboxGroup', () => { }); it('should handle change events without a custom onChange handler', () => { - const event = { target: { value: 'terminator', checked: true } }; + const event = { target: { value: 'terminator' } }; const component = shallow( @@ -64,7 +65,9 @@ describe('CheckboxGroup', () => { ); const firstChild = component.find('Checkbox').at(0); firstChild.simulate('change', event); - expect(component.state().value).to.eql({ terminator: true, predator: false, soundofmusic: false }); + process.nextTick(() => { + expect(component.state().value).to.eql({ terminator: true, predator: false, soundofmusic: false }); + }); }); it('should handle props changes', () => {