mirror of
https://github.com/apache/superset.git
synced 2026-04-09 03:16:07 +00:00
* move to explore folder and delete explorev2 folder * add tests for fetchDatasourceMetadata * tests for fetchDatasources, fetchDatasourceMetadata * use $.ajax for fetch dashboards and write test
39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
/* eslint-disable no-unused-expressions */
|
|
import React from 'react';
|
|
import { FormControl } from 'react-bootstrap';
|
|
import sinon from 'sinon';
|
|
import { expect } from 'chai';
|
|
import { describe, it, beforeEach } from 'mocha';
|
|
import { mount } from 'enzyme';
|
|
|
|
import BoundsControl from '../../../../javascripts/explore/components/controls/BoundsControl';
|
|
|
|
const defaultProps = {
|
|
name: 'y_axis_bounds',
|
|
label: 'Bounds of the y axis',
|
|
onChange: sinon.spy(),
|
|
};
|
|
|
|
describe('BoundsControl', () => {
|
|
let wrapper;
|
|
|
|
beforeEach(() => {
|
|
wrapper = mount(<BoundsControl {...defaultProps} />);
|
|
});
|
|
|
|
it('renders two FormControls', () => {
|
|
expect(wrapper.find(FormControl)).to.have.lengthOf(2);
|
|
});
|
|
|
|
it('errors on non-numeric', () => {
|
|
wrapper.find(FormControl).first().simulate('change', { target: { value: 's' } });
|
|
expect(defaultProps.onChange.calledWith([null, null])).to.be.true;
|
|
expect(defaultProps.onChange.getCall(0).args[1][0]).to.contain('value should be numeric');
|
|
});
|
|
it('casts to numeric', () => {
|
|
wrapper.find(FormControl).first().simulate('change', { target: { value: '1' } });
|
|
wrapper.find(FormControl).last().simulate('change', { target: { value: '5' } });
|
|
expect(defaultProps.onChange.calledWith([1, 5])).to.be.true;
|
|
});
|
|
});
|