Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
sastaachar committed Jan 6, 2025
1 parent a064173 commit 157d4bf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
30 changes: 23 additions & 7 deletions src/embed/hostEventClient/host-event-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,33 @@ describe('HostEventClient', () => {
description: 'Test Description',
vizId: 'testVizId',
};
const mockResponse = { answerId: 'testAnswerId' };
jest.spyOn(client, 'handleUiPassthroughForHostEvent').mockResolvedValue(mockResponse);

const mockResponse = [{
value: {
saveResponse: {
data: {
Answer__save: {
answer: {
id: 'newAnswer',
},
},
},
},
},
refId: 'testVizId',
}];
mockProcessTrigger.mockResolvedValue(mockResponse);
const result = await client.executeHostEvent(getIFrameEl(), hostEvent, payload);

expect(client.handleUiPassthroughForHostEvent).toHaveBeenCalledWith(
expect(mockProcessTrigger).toHaveBeenCalledWith(
null,
UiPassthroughEvent.saveAnswer,
payload,
'UiPassthrough',
'http://localhost',
{
parameters: payload,
type: 'saveAnswer',
},
);
expect(result).toEqual(mockResponse);
expect(result).toEqual({ answerId: 'newAnswer', ...mockResponse[0].value });
});

it('should call hostEventFallback for unmapped events', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/embed/hostEventClient/host-event-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class HostEventClient {
);
return {
...data,
answerId: data?.saveResponse?.Answer__save?.answer?.id,
answerId: data?.saveResponse?.data?.Answer__save?.answer?.id,
};
}
// fallback for save answer is Save
Expand Down

0 comments on commit 157d4bf

Please sign in to comment.