mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
refactor: Upgrade Redux (#11967)
* upgrade redux and react-redux, adjust types * first round of test fixes * fix rest of unit tests * lint Co-authored-by: Phillip Kelley-Dotson <pkelleydotson@yahoo.com>
This commit is contained in:
committed by
GitHub
parent
9121482479
commit
6270fa2026
@@ -17,9 +17,11 @@
|
||||
* under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import * as ReactAll from 'react';
|
||||
import configureStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
import sinon from 'sinon';
|
||||
import { Subscription } from 'react-redux';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import getInitialState from 'src/explore/reducers/getInitialState';
|
||||
@@ -36,6 +38,13 @@ describe('ExploreViewContainer', () => {
|
||||
let wrapper;
|
||||
let isFeatureEnabledMock;
|
||||
|
||||
jest.spyOn(ReactAll, 'useContext').mockImplementation(() => {
|
||||
return {
|
||||
store,
|
||||
subscription: new Subscription(store),
|
||||
};
|
||||
});
|
||||
|
||||
beforeAll(() => {
|
||||
isFeatureEnabledMock = jest
|
||||
.spyOn(featureFlags, 'isFeatureEnabled')
|
||||
@@ -57,10 +66,11 @@ describe('ExploreViewContainer', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<ExploreViewContainer />, {
|
||||
context: { store },
|
||||
wrapper = shallow(<ExploreViewContainer store={store} />, {
|
||||
disableLifecycleMethods: true,
|
||||
}).dive();
|
||||
})
|
||||
.dive()
|
||||
.dive();
|
||||
});
|
||||
|
||||
it('renders', () => {
|
||||
|
||||
@@ -29,9 +29,7 @@ describe('MetricDefinitionOption', () => {
|
||||
const store = mockStore({});
|
||||
|
||||
function setup(props) {
|
||||
return shallow(<MetricDefinitionOption {...props} />, {
|
||||
context: { store },
|
||||
}).dive();
|
||||
return shallow(<MetricDefinitionOption store={store} {...props} />).dive();
|
||||
}
|
||||
|
||||
it('renders a MetricOption given a saved metric', () => {
|
||||
|
||||
@@ -20,6 +20,7 @@ import React from 'react';
|
||||
import configureStore from 'redux-mock-store';
|
||||
import thunk from 'redux-thunk';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
import { styledMount as mount } from 'spec/helpers/theming';
|
||||
@@ -72,9 +73,9 @@ describe('SaveModal', () => {
|
||||
};
|
||||
|
||||
const getWrapper = () =>
|
||||
shallow(<SaveModal {...defaultProps} />, {
|
||||
context: { store },
|
||||
}).dive();
|
||||
shallow(<SaveModal {...defaultProps} store={store} />)
|
||||
.dive()
|
||||
.dive();
|
||||
|
||||
it('renders a Modal with the right set of components', () => {
|
||||
const wrapper = getWrapper();
|
||||
@@ -117,15 +118,14 @@ describe('SaveModal', () => {
|
||||
});
|
||||
|
||||
it('componentDidMount', () => {
|
||||
sinon.spy(SaveModal.prototype, 'componentDidMount');
|
||||
sinon.spy(defaultProps.actions, 'fetchDashboards');
|
||||
mount(<SaveModal {...defaultProps} />, {
|
||||
context: { store },
|
||||
});
|
||||
expect(SaveModal.prototype.componentDidMount.calledOnce).toBe(true);
|
||||
mount(
|
||||
<Provider store={store}>
|
||||
<SaveModal {...defaultProps} />
|
||||
</Provider>,
|
||||
);
|
||||
expect(defaultProps.actions.fetchDashboards.calledOnce).toBe(true);
|
||||
|
||||
SaveModal.prototype.componentDidMount.restore();
|
||||
defaultProps.actions.fetchDashboards.restore();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user