mirror of
https://github.com/apache/superset.git
synced 2026-04-10 20:06:13 +00:00
* rename /explorev2/ -> /explore/ * add redirect for existing explorev2 urls * fix long line * remove extra line * fix missed ref in spec
40 lines
1.5 KiB
JavaScript
40 lines
1.5 KiB
JavaScript
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', () => ('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();
|
|
});
|
|
});
|