2019-01-15 18:53:27 -05:00
|
|
|
/**
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
* or more contributor license agreements. See the NOTICE file
|
|
|
|
* distributed with this work for additional information
|
|
|
|
* regarding copyright ownership. The ASF licenses this file
|
|
|
|
* to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance
|
|
|
|
* with the License. You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing,
|
|
|
|
* software distributed under the License is distributed on an
|
|
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
* KIND, either express or implied. See the License for the
|
|
|
|
* specific language governing permissions and limitations
|
|
|
|
* under the License.
|
|
|
|
*/
|
2016-11-08 13:28:51 -05:00
|
|
|
/* eslint-disable no-unused-expressions */
|
|
|
|
import React from 'react';
|
|
|
|
import { FormControl } from 'react-bootstrap';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import { shallow } from 'enzyme';
|
2017-06-20 01:27:16 -04:00
|
|
|
import AceEditor from 'react-ace';
|
|
|
|
|
2018-04-18 00:05:01 -04:00
|
|
|
import TextAreaControl from '../../../../src/explore/components/controls/TextAreaControl';
|
2016-11-08 13:28:51 -05:00
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
name: 'x_axis_label',
|
|
|
|
label: 'X Axis Label',
|
|
|
|
onChange: sinon.spy(),
|
|
|
|
};
|
|
|
|
|
2017-02-22 11:36:47 -05:00
|
|
|
describe('SelectControl', () => {
|
2016-11-08 13:28:51 -05:00
|
|
|
let wrapper;
|
|
|
|
beforeEach(() => {
|
2017-02-22 11:36:47 -05:00
|
|
|
wrapper = shallow(<TextAreaControl {...defaultProps} />);
|
2016-11-08 13:28:51 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders a FormControl', () => {
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(wrapper.find(FormControl)).toHaveLength(1);
|
2016-11-08 13:28:51 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
it('calls onChange when toggled', () => {
|
|
|
|
const select = wrapper.find(FormControl);
|
|
|
|
select.simulate('change', { target: { value: 'x' } });
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(defaultProps.onChange.calledWith('x')).toBe(true);
|
2016-11-08 13:28:51 -05:00
|
|
|
});
|
2017-06-20 01:27:16 -04:00
|
|
|
|
|
|
|
it('renders a AceEditor when language is specified', () => {
|
|
|
|
const props = Object.assign({}, defaultProps);
|
|
|
|
props.language = 'markdown';
|
|
|
|
wrapper = shallow(<TextAreaControl {...props} />);
|
2018-10-15 16:10:18 -04:00
|
|
|
expect(wrapper.find(FormControl)).toHaveLength(0);
|
|
|
|
expect(wrapper.find(AceEditor)).toHaveLength(1);
|
2017-06-20 01:27:16 -04:00
|
|
|
});
|
2016-11-08 13:28:51 -05:00
|
|
|
});
|