diff --git a/src/services/experiments/execution/__tests__/running-simulation-service.test.js b/src/services/experiments/execution/__tests__/running-simulation-service.test.js index 12fc0bc083cc8f8ea88b41f1be446fc42d2e6dda..d93d97310c081ab0c30da23c0466b4985907a2de 100644 --- a/src/services/experiments/execution/__tests__/running-simulation-service.test.js +++ b/src/services/experiments/execution/__tests__/running-simulation-service.test.js @@ -109,32 +109,32 @@ test('register for ROS status information', () => { }); let progressMessageCallback = jest.fn(); - // we register twice to check that the original sub is conserved without error + // we register twice to check that original sub is destroyed and re-created without error RunningSimulationService.instance.addRosStatusInfoCallback('test-ros-ws-url', progressMessageCallback); RunningSimulationService.instance.addRosStatusInfoCallback('test-ros-ws-url', progressMessageCallback); - expect(RoslibService.instance.getConnection.mock.calls.length).toBe(1); - expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(0); + expect(RoslibService.instance.getConnection.mock.calls.length).toBe(2); + expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(1); // send status update with task info let rosStatusData = { - task: 'test-some-task', - subtask: 'test-some-subtask' + progress: { + task: 'test-some-task', + subtask: 'test-some-subtask' + } }; statusUpdateCallback({ data: JSON.stringify(rosStatusData) }); expect(progressMessageCallback).toHaveBeenCalledWith({ - task: rosStatusData.task, - subtask: rosStatusData.subtask + main: rosStatusData.progress.task, + sub: rosStatusData.progress.subtask }); // send status update indicating we're done - rosStatusData = { - done: true - } + rosStatusData.progress.done = true; statusUpdateCallback({ data: JSON.stringify(rosStatusData) }); expect(progressMessageCallback).toHaveBeenCalledWith({ - done: true + main: 'Simulation initialized.' }); - expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(0); + expect(mockStatusListener.removeAllListeners.mock.calls.length).toBe(2); }); test('can retrieve the state of a simulation', async () => {