Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shaed-parkar committed Jan 29, 2025
1 parent 0e5e95c commit 6a243b5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,16 @@ describe('HeartbeatService', () => {
expect(heartbeatSpy.kill).toHaveBeenCalledTimes(1);
expect(sut.heartbeat).toBeFalsy();
});

it('should do nothing if the heartbeat is null', () => {
// Arrange
sut.heartbeat = null;

// Act
sut.stopHeartbeat();

// Assert
expect(loggerSpy.debug).toHaveBeenCalledWith(jasmine.stringMatching(/Couldn't stop the heartbeat as it didn't exist/));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -795,4 +795,31 @@ describe('SelfTestComponent', () => {
expect(retrieveSelfTestScoreSpy).toHaveBeenCalledTimes(1);
}));
});

describe('setupPexipClient', () => {
it('should subscribe to video call events and set up the pexip client', async () => {
// Arrange
videoCallServiceSpy.onCallSetup.and.returnValue(of(new CallSetup(new MediaStream())));
videoCallServiceSpy.onCallConnected.and.returnValue(of(new ConnectedCall(new MediaStream())));
videoCallServiceSpy.onError.and.returnValue(of(new CallError('error')));
videoCallServiceSpy.onCallDisconnected.and.returnValue(of(new DisconnectedCall('reason')));

const handleCallSetupSpy = spyOn(component, 'handleCallSetup');
const handleCallConnectedSpy = spyOn(component, 'handleCallConnected');
const handleCallErrorSpy = spyOn(component, 'handleCallError');
const handleCallDisconnectSpy = spyOn(component, 'handleCallDisconnect');

videoCallServiceSpy.setupClient.and.resolveTo();

// Act
await component.setupPexipClient();

// Assert
expect(handleCallSetupSpy).toHaveBeenCalledTimes(1);
expect(handleCallConnectedSpy).toHaveBeenCalledTimes(1);
expect(handleCallErrorSpy).toHaveBeenCalledTimes(1);
expect(handleCallDisconnectSpy).toHaveBeenCalledTimes(1);
expect(videoCallServiceSpy.setupClient).toHaveBeenCalledTimes(1);
});
});
});

0 comments on commit 6a243b5

Please sign in to comment.