mirror of
https://github.com/apache/superset.git
synced 2026-04-16 22:55:52 +00:00
[js-testing] add tests for explore actions (#2976)
* move to explore folder and delete explorev2 folder * add tests for fetchDatasourceMetadata * tests for fetchDatasources, fetchDatasourceMetadata * use $.ajax for fetch dashboards and write test
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/* 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;
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user