Skip to content

Commit

Permalink
fix mock ChartClient
Browse files Browse the repository at this point in the history
add comments
  • Loading branch information
zhaoyongjie committed Nov 26, 2021
1 parent 196f01a commit bfb4a12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion superset-frontend/spec/helpers/setupSupersetClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
* under the License.
*/
import fetchMock from 'fetch-mock';
import { SupersetClient } from '@superset-ui/core';
// https://jestjs.io/docs/jest-object#jestmockmodulename-factory-options
// in order to mock modules in test case, so avoid absolute import module
import { SupersetClient } from '../../packages/superset-ui-core/src/connection';

export default function setupSupersetClient() {
// The following is needed to mock out SupersetClient requests
Expand Down
6 changes: 5 additions & 1 deletion superset-frontend/spec/helpers/shim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ import 'jest-enzyme';
import jQuery from 'jquery';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { configure as configureTranslation } from '@superset-ui/core';
// https://jestjs.io/docs/jest-object#jestmockmodulename-factory-options
// in order to mock modules in test case, so avoid absolute import module
import { configure as configureTranslation } from '../../packages/superset-ui-core/src/translation';
import { Worker } from './Worker';
import { IntersectionObserver } from './IntersectionObserver';
import setupSupersetClient from './setupSupersetClient';
import CacheStorage from './CacheStorage';

configure({ adapter: new Adapter() });

Expand All @@ -49,6 +52,7 @@ g.window.performance = { now: () => new Date().getTime() };
g.window.Worker = Worker;
g.window.IntersectionObserver = IntersectionObserver;
g.URL.createObjectURL = () => '';
g.caches = new CacheStorage();

Object.defineProperty(window, 'matchMedia', {
writable: true,
Expand Down

0 comments on commit bfb4a12

Please sign in to comment.