Skip to content

Commit 2562bb2

Browse files
[STREAM-151] Codacy any -> unknown
Co-authored-by: codacy-production[bot] <61871480+codacy-production[bot]@users.noreply.github.com>
1 parent 276f2be commit 2562bb2

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/stats-aggregator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,6 @@ export class StatsAggregator {
229229

230230
this.sdk.logger.debug('Sending stats over XMPP');
231231
this.sdk._streamingConnection._webrtcSessions.sendIq(iq)
232-
.catch((err: any) => this.sdk.logger.warn('Failed to send stats via XMPP', err));
232+
.catch((err: unknown) => this.sdk.logger.warn('Failed to send stats via XMPP', err));
233233
}
234234
}

test/unit/stats-aggregator.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ describe('StatsAggregator', () => {
1414
describe('shouldGatherImmediately / eager persistent connection', () => {
1515
it('should not start gathering stats immediately for eager persistent connections (privAnswerMode === Auto)', () => {
1616
const mockSession = new MockSession() as unknown as IExtendedMediaSession;
17-
(mockSession as any).privAnswerMode = 'Auto';
17+
(mockSession as unknown).privAnswerMode = 'Auto';
1818
const sdk = new SimpleMockSdk() as unknown as GenesysCloudWebrtSdk;
1919
const statsAggregator = new StatsAggregator(mockSession, sdk);
2020

@@ -24,7 +24,7 @@ describe('StatsAggregator', () => {
2424

2525
it('should start gathering stats immediately for non-eager sessions', () => {
2626
const mockSession = new MockSession() as unknown as IExtendedMediaSession;
27-
(mockSession as any).privAnswerMode = 'Manual';
27+
(mockSession as unknown).privAnswerMode = 'Manual';
2828
const sdk = new SimpleMockSdk() as unknown as GenesysCloudWebrtSdk;
2929
const statsAggregator = new StatsAggregator(mockSession, sdk);
3030

@@ -42,7 +42,7 @@ describe('StatsAggregator', () => {
4242
expect(statsAggregator['statsGatherer']).toBeFalsy();
4343

4444
// Emit sessionStarted with the same session
45-
(sdk as any).emit('sessionStarted', mockSession);
45+
(sdk as unknown).emit('sessionStarted', mockSession);
4646

4747
expect(statsAggregator['statsGatherer']).toBeTruthy();
4848
expect(statsAggregator['setBaseline']).toBe(true);
@@ -55,7 +55,7 @@ describe('StatsAggregator', () => {
5555
const statsAggregator = new StatsAggregator(mockSession, sdk);
5656

5757
const otherSession = new MockSession() as unknown as IExtendedMediaSession;
58-
(sdk as any).emit('sessionStarted', otherSession);
58+
(sdk as unknown).emit('sessionStarted', otherSession);
5959

6060
expect(statsAggregator['statsGatherer']).toBeFalsy();
6161
});
@@ -69,7 +69,7 @@ describe('StatsAggregator', () => {
6969

7070
expect(statsAggregator['statsGatherer']).toBeTruthy();
7171

72-
(sdk as any).emit('sessionEnded', mockSession);
72+
(sdk as unknown).emit('sessionEnded', mockSession);
7373

7474
expect(statsAggregator['statsGatherer']).toBeFalsy();
7575
});
@@ -80,7 +80,7 @@ describe('StatsAggregator', () => {
8080
const statsAggregator = new StatsAggregator(mockSession, sdk);
8181

8282
const otherSession = new MockSession() as unknown as IExtendedMediaSession;
83-
(sdk as any).emit('sessionEnded', otherSession);
83+
(sdk as unknown).emit('sessionEnded', otherSession);
8484

8585
expect(statsAggregator['statsGatherer']).toBeTruthy();
8686
});
@@ -94,13 +94,13 @@ describe('StatsAggregator', () => {
9494

9595
expect(statsAggregator['statsGatherer']).toBeTruthy();
9696

97-
const listenerCountBefore = (sdk as any).listenerCount('sessionStarted');
97+
const listenerCountBefore = (sdk as unknown).listenerCount('sessionStarted');
9898

99-
(mockSession as any).emit('terminated');
99+
(mockSession as unknown).emit('terminated');
100100

101101
expect(statsAggregator['statsGatherer']).toBeFalsy();
102102
// SDK listeners for sessionStarted/sessionEnded should be removed
103-
expect((sdk as any).listenerCount('sessionStarted')).toBe(listenerCountBefore - 1);
103+
expect((sdk as unknown).listenerCount('sessionStarted')).toBe(listenerCountBefore - 1);
104104
});
105105
});
106106

@@ -331,7 +331,7 @@ describe('StatsAggregator', () => {
331331
it('should call sendIq with correct IQ stanza', () => {
332332
const mockSession = new MockSession() as unknown as IExtendedMediaSession;
333333
const sdk = new SimpleMockSdk() as unknown as GenesysCloudWebrtSdk;
334-
const sendIqMock = (sdk as any)._streamingConnection._webrtcSessions.sendIq;
334+
const sendIqMock = (sdk as unknown)._streamingConnection._webrtcSessions.sendIq;
335335
const statsAggregator = new StatsAggregator(mockSession, sdk);
336336
const rtpStats = {
337337
packetsReceived: 5,
@@ -341,7 +341,7 @@ describe('StatsAggregator', () => {
341341
const participant = {
342342
calls: [{ id: 'testCall' }]
343343
};
344-
mockSession.pcParticipant = participant as any;
344+
mockSession.pcParticipant = participant as unknown;
345345

346346
statsAggregator['sendStats'](rtpStats, new Date());
347347

@@ -387,19 +387,19 @@ describe('StatsAggregator', () => {
387387
};
388388

389389
const participantA = { calls: [] };
390-
mockSession.pcParticipant = participantA as any;
390+
mockSession.pcParticipant = participantA as unknown;
391391
statsAggregator['sendStats'](rtpStats, new Date());
392392
expect(sendIqMock).not.toHaveBeenCalled();
393393

394394
const participantB = {};
395-
mockSession.pcParticipant = participantB as any;
395+
mockSession.pcParticipant = participantB as unknown;
396396
statsAggregator['sendStats'](rtpStats, new Date());
397397
expect(sendIqMock).not.toHaveBeenCalled();
398398
});
399399

400400
it('should not call sendIq if session.peerID is falsy', () => {
401401
const mockSession = new MockSession() as unknown as IExtendedMediaSession;
402-
(mockSession as any).peerID = '';
402+
(mockSession as unknown).peerID = '';
403403
const sdk = new SimpleMockSdk() as unknown as GenesysCloudWebrtSdk;
404404
const sendIqMock = (sdk as any)._streamingConnection._webrtcSessions.sendIq;
405405
const statsAggregator = new StatsAggregator(mockSession, sdk);
@@ -408,7 +408,7 @@ describe('StatsAggregator', () => {
408408
averageJitter: 0.1,
409409
estimatedAverageMos: 5
410410
};
411-
mockSession.pcParticipant = { calls: [{ id: 'testCall' }] } as any;
411+
mockSession.pcParticipant = { calls: [{ id: 'testCall' }] } as unknown;
412412

413413
statsAggregator['sendStats'](rtpStats, new Date());
414414

@@ -418,7 +418,7 @@ describe('StatsAggregator', () => {
418418
it('should not throw when streaming connection webrtcSessions is unavailable', () => {
419419
const mockSession = new MockSession() as unknown as IExtendedMediaSession;
420420
const sdk = new SimpleMockSdk() as unknown as GenesysCloudWebrtSdk;
421-
(sdk as any)._streamingConnection._webrtcSessions = null;
421+
(sdk as unknown)._streamingConnection._webrtcSessions = null;
422422
const statsAggregator = new StatsAggregator(mockSession, sdk);
423423
const rtpStats = {
424424
packetsReceived: 5,
@@ -435,7 +435,7 @@ describe('StatsAggregator', () => {
435435
it('should catch sendIq rejection and log a warning', async () => {
436436
const mockSession = new MockSession() as unknown as IExtendedMediaSession;
437437
const sdk = new SimpleMockSdk() as unknown as GenesysCloudWebrtSdk;
438-
(sdk as any)._streamingConnection._webrtcSessions.sendIq = jest.fn().mockRejectedValue(new Error('XMPP error'));
438+
(sdk as unknown)._streamingConnection._webrtcSessions.sendIq = jest.fn().mockRejectedValue(new Error('XMPP error'));
439439
const statsAggregator = new StatsAggregator(mockSession, sdk);
440440
const rtpStats = {
441441
packetsReceived: 5,

0 commit comments

Comments
 (0)