Improving TextAreaControl to support code and modal (#2988)

This commit is contained in:
Maxime Beauchemin
2017-06-19 22:27:16 -07:00
committed by GitHub
parent b9915e7ecf
commit 7e5e229f48
4 changed files with 81 additions and 13 deletions

View File

@@ -5,6 +5,8 @@ import sinon from 'sinon';
import { expect } from 'chai';
import { describe, it, beforeEach } from 'mocha';
import { shallow } from 'enzyme';
import AceEditor from 'react-ace';
import TextAreaControl from '../../../../javascripts/explore/components/controls/TextAreaControl';
const defaultProps = {
@@ -15,7 +17,6 @@ const defaultProps = {
describe('SelectControl', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<TextAreaControl {...defaultProps} />);
});
@@ -29,4 +30,12 @@ describe('SelectControl', () => {
select.simulate('change', { target: { value: 'x' } });
expect(defaultProps.onChange.calledWith('x')).to.be.true;
});
it('renders a AceEditor when language is specified', () => {
const props = Object.assign({}, defaultProps);
props.language = 'markdown';
wrapper = shallow(<TextAreaControl {...props} />);
expect(wrapper.find(FormControl)).to.have.lengthOf(0);
expect(wrapper.find(AceEditor)).to.have.lengthOf(1);
});
});