mirror of
https://github.com/apache/superset.git
synced 2026-05-12 19:35:17 +00:00
refactor: Upgrade to React 17 (#31961)
This commit is contained in:
committed by
GitHub
parent
aa74ba3da2
commit
7e2b7941f3
@@ -18,10 +18,16 @@
|
||||
*/
|
||||
import fetchMock from 'fetch-mock';
|
||||
import WS from 'jest-websocket-mock';
|
||||
import sinon from 'sinon';
|
||||
import * as uiCore from '@superset-ui/core';
|
||||
import { parseErrorJson, isFeatureEnabled } from '@superset-ui/core';
|
||||
import * as asyncEvent from 'src/middleware/asyncEvent';
|
||||
|
||||
jest.mock('@superset-ui/core', () => ({
|
||||
...jest.requireActual('@superset-ui/core'),
|
||||
isFeatureEnabled: jest.fn(),
|
||||
}));
|
||||
|
||||
const mockedIsFeatureEnabled = isFeatureEnabled as jest.Mock;
|
||||
|
||||
describe('asyncEvent middleware', () => {
|
||||
const asyncPendingEvent = {
|
||||
status: 'pending',
|
||||
@@ -80,16 +86,16 @@ describe('asyncEvent middleware', () => {
|
||||
|
||||
const EVENTS_ENDPOINT = 'glob:*/api/v1/async_event/*';
|
||||
const CACHED_DATA_ENDPOINT = 'glob:*/api/v1/chart/data/*';
|
||||
let featureEnabledStub: any;
|
||||
|
||||
beforeEach(async () => {
|
||||
featureEnabledStub = sinon.stub(uiCore, 'isFeatureEnabled');
|
||||
featureEnabledStub.withArgs('GLOBAL_ASYNC_QUERIES').returns(true);
|
||||
mockedIsFeatureEnabled.mockImplementation(
|
||||
featureFlag => featureFlag === 'GLOBAL_ASYNC_QUERIES',
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fetchMock.reset();
|
||||
featureEnabledStub.restore();
|
||||
mockedIsFeatureEnabled.mockRestore();
|
||||
});
|
||||
|
||||
afterAll(fetchMock.reset);
|
||||
@@ -128,7 +134,7 @@ describe('asyncEvent middleware', () => {
|
||||
status: 200,
|
||||
body: { result: [asyncErrorEvent] },
|
||||
});
|
||||
const errorResponse = await uiCore.parseErrorJson(asyncErrorEvent);
|
||||
const errorResponse = await parseErrorJson(asyncErrorEvent);
|
||||
await expect(
|
||||
asyncEvent.waitForAsyncData(asyncPendingEvent),
|
||||
).rejects.toEqual(errorResponse);
|
||||
@@ -203,7 +209,7 @@ describe('asyncEvent middleware', () => {
|
||||
|
||||
wsServer.send(JSON.stringify(asyncErrorEvent));
|
||||
|
||||
const errorResponse = await uiCore.parseErrorJson(asyncErrorEvent);
|
||||
const errorResponse = await parseErrorJson(asyncErrorEvent);
|
||||
|
||||
await expect(promise).rejects.toEqual(errorResponse);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user