Skip to content

Commit

Permalink
Update event handlers from iframeLocation change (#243)
Browse files Browse the repository at this point in the history
* Update event handlers from iframeLocation change

* Update tests
  • Loading branch information
esme authored Nov 19, 2024
1 parent af36e46 commit 6db0517
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const RECORDING_URL =
function CallEndedScreen({
cti,
engagementId,
handleSaveCall,
handleCallCompleted,
dialNumber,
incomingNumber,
direction,
Expand Down Expand Up @@ -46,7 +46,7 @@ function CallEndedScreen({
hs_call_recording_url: isCallRecorded ? RECORDING_URL : null,
},
});
handleSaveCall();
handleCallCompleted();
};

return (
Expand Down
4 changes: 2 additions & 2 deletions demos/demo-react-ts/src/components/screens/CallingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function CallingScreen({
setNotes,
setIsCallRecorded,
callDurationString,
handleEndCall,
handleCallEnded,
direction,
}: ScreenProps) {
const [toggleRecord, setToggleRecord] = useState(false);
Expand All @@ -58,7 +58,7 @@ function CallingScreen({
callEndStatus: "COMPLETED",
});

handleEndCall();
handleCallEnded();
};

const content = useMemo(() => {
Expand Down
4 changes: 2 additions & 2 deletions demos/demo-react-ts/src/types/ScreenTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export interface ScreenProps {
callDurationString: string;
startTimer: Function;
stopTimer: Function;
handleEndCall: Function;
handleSaveCall: Function;
handleCallEnded: Function;
handleCallCompleted: Function;
fromNumber: string;
setFromNumber: Function;
availability: Availability;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ const props: Partial<ScreenProps> = {
callDurationString: "",
startTimer: noop,
stopTimer: noop,
handleEndCall: noop,
handleSaveCall: noop,
handleCallEnded: noop,
handleCallCompleted: noop,
fromNumber: "",
setFromNumber: noop,
direction: "OUTBOUND",
};

describe("CallEndedScreen", () => {
beforeEach(() => {
props.handleSaveCall = jasmine.createSpy("handleSaveCall");
props.handleCallCompleted = jasmine.createSpy("handleCallCompleted");
cti.callCompleted = jasmine.createSpy("callCompleted");
});

Expand Down Expand Up @@ -61,7 +61,7 @@ describe("CallEndedScreen", () => {
);
const button = getByRole("button", { name: /save-call/ });
button.click();
expect(props.handleSaveCall).toHaveBeenCalled();
expect(props.handleCallCompleted).toHaveBeenCalled();
expect(cti.callCompleted).toHaveBeenCalledWith({
engagementId: 1,
hideWidget: false,
Expand All @@ -86,7 +86,7 @@ describe("CallEndedScreen", () => {
);
const button = getByRole("button", { name: /save-call/ });
button.click();
expect(props.handleSaveCall).toHaveBeenCalled();
expect(props.handleCallCompleted).toHaveBeenCalled();
expect(cti.callCompleted).toHaveBeenCalledWith({
engagementId: 1,
hideWidget: false,
Expand All @@ -112,7 +112,7 @@ describe("CallEndedScreen", () => {
);
const button = getByRole("button", { name: /save-call/ });
button.click();
expect(props.handleSaveCall).toHaveBeenCalled();
expect(props.handleCallCompleted).toHaveBeenCalled();
expect(
(cti.callCompleted as jasmine.Spy).calls.argsFor(0)[0]
.engagementProperties.hs_call_status
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const props: Partial<ScreenProps> = {
callDurationString: "",
startTimer: noop,
stopTimer: noop,
handleEndCall: noop,
handleCallEnded: noop,
handleSaveCall: noop,
fromNumber: "",
setFromNumber: noop,
Expand All @@ -32,15 +32,15 @@ const props: Partial<ScreenProps> = {

describe("CallingScreen", () => {
beforeEach(() => {
props.handleEndCall = jasmine.createSpy("handleEndCall");
props.handleCallEnded = jasmine.createSpy("handleCallEnded");
cti.callEnded = jasmine.createSpy("callEnded");
});

it("Ends call", () => {
const { getByRole } = renderWithContext(<CallingScreen {...props} />);
const button = getByRole("button", { name: /end-call/ });
button.click();
expect(props.handleEndCall).toHaveBeenCalled();
expect(props.handleCallEnded).toHaveBeenCalled();
expect(cti.callEnded).toHaveBeenCalledWith({
callEndStatus: "COMPLETED",
});
Expand Down

0 comments on commit 6db0517

Please sign in to comment.