You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
875 B

const { layout } = jest.requireActual('../../app/plugins/panel/nodeGraph/layout.worker.js');
class LayoutMockWorker {
timeout: number | undefined;
constructor() {}
postMessage(data: any) {
const { nodes, edges, config } = data;
this.timeout = setTimeout(() => {
this.timeout = undefined;
layout(nodes, edges, config);
// @ts-ignore
this.onmessage({ data: { nodes, edges } });
}, 1) as any;
}
terminate() {
if (this.timeout) {
clearTimeout(this.timeout);
}
}
}
jest.mock('../../app/plugins/panel/nodeGraph/createLayoutWorker', () => ({
createWorker: () => new LayoutMockWorker(),
}));
class BasicMockWorker {
postMessage() {}
}
const mockCreateWorker = {
createWorker: () => new BasicMockWorker(),
};
jest.mock('../../app/features/live/centrifuge/createCentrifugeServiceWorker', () => mockCreateWorker);