mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 18:07:36 -02:30
Mock web worker.
This commit is contained in:
@@ -7,6 +7,7 @@ import { mountWithContexts } from '../testUtils/enzymeHelpers';
|
|||||||
import App, { ProtectedRoute } from './App';
|
import App, { ProtectedRoute } from './App';
|
||||||
|
|
||||||
jest.mock('./api');
|
jest.mock('./api');
|
||||||
|
jest.mock('screens/TopologyView/utils/WebWorker', () => jest.fn());
|
||||||
|
|
||||||
describe('<App />', () => {
|
describe('<App />', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
|
|||||||
import App from './App';
|
import App from './App';
|
||||||
|
|
||||||
jest.mock('react-dom', () => ({ render: jest.fn() }));
|
jest.mock('react-dom', () => ({ render: jest.fn() }));
|
||||||
|
jest.mock('screens/TopologyView/utils/WebWorker', () => jest.fn());
|
||||||
|
|
||||||
describe('index.jsx', () => {
|
describe('index.jsx', () => {
|
||||||
it('renders ok', () => {
|
it('renders ok', () => {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import getRouteConfig from './routeConfig';
|
import getRouteConfig from './routeConfig';
|
||||||
|
jest.mock('screens/TopologyView/utils/WebWorker', () => jest.fn());
|
||||||
|
|
||||||
const userProfile = {
|
const userProfile = {
|
||||||
isSuperUser: false,
|
isSuperUser: false,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
// generateRandomNodes,
|
// generateRandomNodes,
|
||||||
// getRandomInt,
|
// getRandomInt,
|
||||||
} from './utils/helpers';
|
} from './utils/helpers';
|
||||||
|
import webWorker from './utils/webWorker';
|
||||||
import {
|
import {
|
||||||
DEFAULT_RADIUS,
|
DEFAULT_RADIUS,
|
||||||
DEFAULT_NODE_COLOR,
|
DEFAULT_NODE_COLOR,
|
||||||
@@ -59,10 +60,7 @@ function MeshGraph({ data, showLegend, zoom, setShowZoomControls }) {
|
|||||||
const graph = data;
|
const graph = data;
|
||||||
|
|
||||||
/* WEB WORKER */
|
/* WEB WORKER */
|
||||||
const worker = new Worker(
|
const worker = webWorker();
|
||||||
new URL('./utils/workers/simulationWorker.js', import.meta.url)
|
|
||||||
);
|
|
||||||
|
|
||||||
worker.postMessage({
|
worker.postMessage({
|
||||||
nodes: graph.nodes,
|
nodes: graph.nodes,
|
||||||
links: graph.links,
|
links: graph.links,
|
||||||
|
|||||||
3
awx/ui/src/screens/TopologyView/utils/webWorker.js
Normal file
3
awx/ui/src/screens/TopologyView/utils/webWorker.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default function webWorker() {
|
||||||
|
return new Worker(new URL('./workers/simulationWorker.js', import.meta.url));
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user