Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Dec 5, 2017
1 parent fecfa03 commit b11e5d8
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions superset/assets/spec/javascripts/sqllab/SaveQuery_spec.jsx
@@ -1,9 +1,10 @@
import React from 'react';
import { Overlay, Popover, FormControl } from 'react-bootstrap';
import { FormControl } from 'react-bootstrap';
import { shallow } from 'enzyme';
import { describe, it } from 'mocha';
import { expect } from 'chai';
import SaveQuery from '../../../javascripts/SqlLab/components/SaveQuery';
import ModalTrigger from '../../../javascripts/components/ModalTrigger';

describe('SavedQuery', () => {
const mockedProps = {
Expand All @@ -23,25 +24,18 @@ describe('SavedQuery', () => {
React.isValidElement(<SaveQuery {...mockedProps} />),
).to.equal(true);
});
it('has an Overlay and a Popover', () => {
it('has a ModalTrigger', () => {
const wrapper = shallow(<SaveQuery {...mockedProps} />);
expect(wrapper.find(Overlay)).to.have.length(1);
expect(wrapper.find(Popover)).to.have.length(1);
});
it('pops and hides', () => {
const wrapper = shallow(<SaveQuery {...mockedProps} />);
expect(wrapper.state().showSave).to.equal(false);
wrapper.find('.toggleSave').simulate('click', { target: { value: 'test' } });
expect(wrapper.state().showSave).to.equal(true);
wrapper.find('.toggleSave').simulate('click', { target: { value: 'test' } });
expect(wrapper.state().showSave).to.equal(false);
expect(wrapper.find(ModalTrigger)).to.have.length(1);
});
it('has a cancel button', () => {
const wrapper = shallow(<SaveQuery {...mockedProps} />);
expect(wrapper.find('.cancelQuery')).to.have.length(1);
const modal = shallow(wrapper.instance().renderModalBody());
expect(modal.find('.cancelQuery')).to.have.length(1);
});
it('has 2 FormControls', () => {
const wrapper = shallow(<SaveQuery {...mockedProps} />);
expect(wrapper.find(FormControl)).to.have.length(2);
const modal = shallow(wrapper.instance().renderModalBody());
expect(modal.find(FormControl)).to.have.length(2);
});
});

0 comments on commit b11e5d8

Please sign in to comment.