Files
superset2/superset/assets/spec/javascripts/explorev2/actions_spec.js
Alanna Scott 0c9f9b695b [clarity/consistency] rename /explorev2/ -> /explore/ (#2802)
* rename /explorev2/ -> /explore/

* add redirect for existing explorev2 urls

* fix long line

* remove extra line

* fix missed ref in spec
2017-05-24 17:12:28 -07:00

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();
});
});