import React from 'react'; 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 = { dbId: 1, schema: 'main', sql: 'SELECT * FROM t', defaultLabel: 'untitled', animation: false, }; it('is valid', () => { expect( React.isValidElement(), ).to.equal(true); }); it('is valid with props', () => { expect( React.isValidElement(), ).to.equal(true); }); it('has a ModalTrigger', () => { const wrapper = shallow(); expect(wrapper.find(ModalTrigger)).to.have.length(1); }); it('has a cancel button', () => { const wrapper = shallow(); const modal = shallow(wrapper.instance().renderModalBody()); expect(modal.find('.cancelQuery')).to.have.length(1); }); it('has 2 FormControls', () => { const wrapper = shallow(); const modal = shallow(wrapper.instance().renderModalBody()); expect(modal.find(FormControl)).to.have.length(2); }); });