Files
superset2/superset/assets/spec/javascripts/explore/chartActions_spec.js
Grace Guo b3107bb603 [explore] Split large reducer logic in ExploreViewContainer (#3088)
* split reducer logic for ExploreViewContainer

* fix saveModal component and unit tests

* revert changes in SaveModal_spec.
will make another commit just to improve test coverage for SaveModal component.

* remove comment-out code

* fix merge confilicts
2017-08-10 14:21:45 -07:00

37 lines
997 B
JavaScript

import { it, describe } from 'mocha';
import { expect } from 'chai';
import sinon from 'sinon';
import $ from 'jquery';
import * as exploreUtils from '../../../javascripts/explore/exploreUtils';
import * as actions from '../../../javascripts/explore/actions/chartActions';
describe('chart actions', () => {
let dispatch;
let urlStub;
let ajaxStub;
let request;
beforeEach(() => {
dispatch = sinon.spy();
urlStub = sinon.stub(exploreUtils, 'getExploreUrl').callsFake(() => ('mockURL'));
ajaxStub = sinon.stub($, 'ajax');
});
afterEach(() => {
urlStub.restore();
ajaxStub.restore();
});
it('should handle query timeout', () => {
ajaxStub.yieldsTo('error', { statusText: 'timeout' });
request = actions.runQuery({});
request(dispatch, sinon.stub().returns({
explore: {
controls: [],
},
}));
expect(dispatch.callCount).to.equal(3);
expect(dispatch.args[0][0].type).to.equal(actions.CHART_UPDATE_TIMEOUT);
});
});