Skip to content

Commit

Permalink
Fix OrchestratorClient.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
mareklibra committed Nov 23, 2024
1 parent f537b5d commit 139629f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions plugins/orchestrator/src/api/OrchestratorClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ describe('OrchestratorClient', () => {
mockExecResponse: ExecuteWorkflowResponseDTO,
executeWorkflowSpy: jest.SpyInstance,
parameters: JsonObject,
businessKey?: string,
) => {
return () => {
expect(result).toBeDefined();
expect(result.data).toEqual(mockExecResponse);
expect(axios.request).toHaveBeenCalledTimes(1);
expect(axios.request).toHaveBeenCalledWith({
...getAxiosTestRequest(`/v2/workflows/${workflowId}/execute`),
...getAxiosTestRequest(
`/v2/workflows/${workflowId}/execute${businessKey ? `?businessKey=${businessKey}` : ''}`,
),
data: JSON.stringify({ inputData: parameters }),
method: 'POST',
headers: {
Expand All @@ -116,6 +119,7 @@ describe('OrchestratorClient', () => {
expect(executeWorkflowSpy).toHaveBeenCalledWith(
workflowId,
{ inputData: parameters },
businessKey,
getDefaultTestRequestConfig(),
);
};
Expand All @@ -138,25 +142,33 @@ describe('OrchestratorClient', () => {
});
it('should execute workflow with business key', async () => {
// Given
const businessKey = 'business123';
const { mockExecResponse, executeWorkflowSpy, args } = setupTest(
'execId001',
{},
'business123',
businessKey,
);

const result = await orchestratorClient.executeWorkflow(args);

expect(
getExpectations(result, mockExecResponse, executeWorkflowSpy, {}),
getExpectations(
result,
mockExecResponse,
executeWorkflowSpy,
{},
businessKey,
),
).not.toThrow();
});
it('should execute workflow with parameters and business key', async () => {
// Given
const businessKey = 'business123';
const parameters = { param1: 'one', param2: 2, param3: true };
const { mockExecResponse, executeWorkflowSpy, args } = setupTest(
'execId001',
parameters,
'business123',
businessKey,
);

const result = await orchestratorClient.executeWorkflow(args);
Expand All @@ -167,6 +179,7 @@ describe('OrchestratorClient', () => {
mockExecResponse,
executeWorkflowSpy,
parameters,
businessKey,
),
).not.toThrow();
});
Expand Down

0 comments on commit 139629f

Please sign in to comment.