You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by GitBox <gi...@apache.org> on 2018/02/12 11:30:05 UTC

[GitHub] daphne-jr commented on issue #4403: Test case not passing when callbacks are used in DateFilterControl_spec.jsx + a repeated test case

daphne-jr commented on issue #4403: Test case not passing when callbacks are used in DateFilterControl_spec.jsx + a repeated test case
URL: https://github.com/apache/incubator-superset/issues/4403#issuecomment-364896693
 
 
   After trying for some time today, this is my crude solution. Hope it helps someone and perhaps someone else would have a better solution.
   ```
   import React from 'react';
   import sinon from 'sinon';
   import { expect } from 'chai';
   import { describe, it, beforeEach } from 'mocha';
   import { mount } from 'enzyme';
   
   import DateFilterControl from '../../../../javascripts/explore/components/controls/DateFilterControl';
   import ControlHeader from '../../../../javascripts/explore/components/ControlHeader';
   
   const defaultProps = {
     animation: false,
     name: 'date',
     onChange: sinon.spy(),
     value: '90 days ago',
     label: 'date',
   };
   
   describe('DateFilterControl', () => {
     let wrapper;
   
     beforeEach(() => {
       wrapper = mount(<DateFilterControl {...defaultProps} />);
     });
   
     afterEach(() => {
       wrapper.unmount();
     })
   
     it('renders a ControlHeader', () => {
       const controlHeader = wrapper.find(ControlHeader);
       expect(controlHeader).to.have.lengthOf(1);
     });
   
     it('renders 3 Buttons', () => {
       const label = wrapper.find(OverlayTrigger).first();
       label.simulate('click');
       expect(document.getElementsByTagName("Button").length).to.be.equal(3);
     });
   
     it('loads the right state', () => {
       const label = wrapper.find('.label').first();
       label.simulate('click');
       expect(wrapper.state().num).to.equal('90');
     });
   
     it('renders 2 dimmed sections', () => {
       const label = wrapper.find('.label').first();
       expect(document.getElementsByClassName('PopoverSection dimmed').length).to.be.equal(0);
       label.simulate('click');
       expect(document.getElementsByClassName('PopoverSection dimmed').length).to.be.equal(2);
     });
   
     it('opens and closes', (done) => {
       const label = wrapper.find('.label').first();
       label.simulate('click');
       expect(document.getElementsByClassName('popover').length).to.be.equal(1);
       document.getElementsByClassName('ok')[0].click();
       setTimeout(() => {
         expect(document.getElementsByClassName('popover').length).to.be.equal(0);
         done();
       }, 10);
     });
   
   });
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services