Skip to content

Commit

Permalink
tests: clarify orchestrator mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tracernz committed Jan 17, 2025
1 parent 7fdf024 commit 4ad7fb6
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { FailuresOrchestrator } from '.';
import { flushPromises } from './test-functions';

// mock enough of JS GenericDataListener to ensure the right calls are made for JS interop
const genericDataListenerSend = jest.fn();

jest.mock('../GenericDataListenerSync', () => ({
GenericDataListenerSync: jest.fn().mockImplementation(() => {
return {
Expand All @@ -11,21 +11,16 @@ jest.mock('../GenericDataListenerSync', () => ({
}),
}));

let sendRequestForFailuresHandler = undefined;
const sendRequestForFailures = () => {
if (!sendRequestForFailuresHandler) {
throw new Error('View Listener never registered!');
}
sendRequestForFailuresHandler();
};
let sendRequestForFailures = undefined;

global.RegisterViewListener = (name: string, callback?: any): ViewListener.ViewListener => {
callback({
on: (topic, requestFailuresCallback) => (sendRequestForFailuresHandler = requestFailuresCallback),
on: (topic, requestFailuresCallback) => (sendRequestForFailures = requestFailuresCallback),
});
return undefined as any;
};

// mock enough of COMM BUS to ensure the right calls are made for WASM interop
const failuresUpdateReceiver = jest.fn();
(global as any).RegisterGenericDataListener = jest.fn();
(global as any).Coherent = {
Expand Down

0 comments on commit 4ad7fb6

Please sign in to comment.