mirror of
https://github.com/apache/superset.git
synced 2026-04-23 18:14:56 +00:00
[js-testing] more tests for SelectControl (#2877)
* rename spec folder * remove special handling for viz_type control since it now uses VizTypeControl * add test for getOptions * linting * add test for cwp * linting
This commit is contained in:
39
superset/assets/spec/javascripts/explore/actions_spec.js
Normal file
39
superset/assets/spec/javascripts/explore/actions_spec.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import $ from 'jquery';
|
||||
import * as actions from '../../../javascripts/explore/actions/exploreActions';
|
||||
import * as exploreUtils from '../../../javascripts/explore/exploreUtils';
|
||||
import { defaultState } from '../../../javascripts/explore/stores/store';
|
||||
import { exploreReducer } from '../../../javascripts/explore/reducers/exploreReducer';
|
||||
|
||||
describe('reducers', () => {
|
||||
it('sets correct control value given a key and value', () => {
|
||||
const newState = exploreReducer(
|
||||
defaultState, actions.setControlValue('x_axis_label', 'x', []));
|
||||
expect(newState.controls.x_axis_label.value).to.equal('x');
|
||||
});
|
||||
it('setControlValue works as expected with a checkbox', () => {
|
||||
const newState = exploreReducer(defaultState,
|
||||
actions.setControlValue('show_legend', true, []));
|
||||
expect(newState.controls.show_legend.value).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('runQuery', () => {
|
||||
it('should handle query timeout', () => {
|
||||
const dispatch = sinon.spy();
|
||||
const urlStub = sinon.stub(exploreUtils, 'getExploreUrl').callsFake(() => ('mockURL'));
|
||||
const ajaxStub = sinon.stub($, 'ajax');
|
||||
ajaxStub.yieldsTo('error', { statusText: 'timeout' });
|
||||
|
||||
const request = actions.runQuery({});
|
||||
request(dispatch);
|
||||
|
||||
expect(dispatch.callCount).to.equal(2);
|
||||
expect(dispatch.args[0][0].type).to.equal(actions.CHART_UPDATE_TIMEOUT);
|
||||
|
||||
urlStub.restore();
|
||||
ajaxStub.restore();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user