Skip to content

Commit 6a243b5

Browse files
committed
add more tests
1 parent 0e5e95c commit 6a243b5

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Diff for: VideoWeb/VideoWeb/ClientApp/src/app/services/conference/heartbeat.service.spec.ts

+11
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,16 @@ describe('HeartbeatService', () => {
224224
expect(heartbeatSpy.kill).toHaveBeenCalledTimes(1);
225225
expect(sut.heartbeat).toBeFalsy();
226226
});
227+
228+
it('should do nothing if the heartbeat is null', () => {
229+
// Arrange
230+
sut.heartbeat = null;
231+
232+
// Act
233+
sut.stopHeartbeat();
234+
235+
// Assert
236+
expect(loggerSpy.debug).toHaveBeenCalledWith(jasmine.stringMatching(/Couldn't stop the heartbeat as it didn't exist/));
237+
});
227238
});
228239
});

Diff for: VideoWeb/VideoWeb/ClientApp/src/app/shared/self-test/self-test.component.spec.ts

+27
Original file line numberDiff line numberDiff line change
@@ -795,4 +795,31 @@ describe('SelfTestComponent', () => {
795795
expect(retrieveSelfTestScoreSpy).toHaveBeenCalledTimes(1);
796796
}));
797797
});
798+
799+
describe('setupPexipClient', () => {
800+
it('should subscribe to video call events and set up the pexip client', async () => {
801+
// Arrange
802+
videoCallServiceSpy.onCallSetup.and.returnValue(of(new CallSetup(new MediaStream())));
803+
videoCallServiceSpy.onCallConnected.and.returnValue(of(new ConnectedCall(new MediaStream())));
804+
videoCallServiceSpy.onError.and.returnValue(of(new CallError('error')));
805+
videoCallServiceSpy.onCallDisconnected.and.returnValue(of(new DisconnectedCall('reason')));
806+
807+
const handleCallSetupSpy = spyOn(component, 'handleCallSetup');
808+
const handleCallConnectedSpy = spyOn(component, 'handleCallConnected');
809+
const handleCallErrorSpy = spyOn(component, 'handleCallError');
810+
const handleCallDisconnectSpy = spyOn(component, 'handleCallDisconnect');
811+
812+
videoCallServiceSpy.setupClient.and.resolveTo();
813+
814+
// Act
815+
await component.setupPexipClient();
816+
817+
// Assert
818+
expect(handleCallSetupSpy).toHaveBeenCalledTimes(1);
819+
expect(handleCallConnectedSpy).toHaveBeenCalledTimes(1);
820+
expect(handleCallErrorSpy).toHaveBeenCalledTimes(1);
821+
expect(handleCallDisconnectSpy).toHaveBeenCalledTimes(1);
822+
expect(videoCallServiceSpy.setupClient).toHaveBeenCalledTimes(1);
823+
});
824+
});
798825
});

0 commit comments

Comments
 (0)