Skip to content

Commit

Permalink
feat(cc-sdk): fixed-blob-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
adhmenon committed Nov 11, 2024
1 parent 99fc367 commit 5665ee1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable */
// Temporarily adding the above until a fix for the blob can be found
import { Signal } from '../Signal';
import { WebexSDK, SubscribeRequest, HTTP_METHODS, WelcomeResponse } from '../../../types';
import { SUBSCRIBE_API, WCC_API_GATEWAY } from '../../constants';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { ConnectionService } from '../../../../../../src/services/core/WebSocket/connection-service';
import { WebSocketManager } from '../../../../../../src/services/core/WebSocket/WebSocketManager';
import { Signal } from '../../../../../../src/services/core/Signal';

jest.mock('../../../../../../src/services/core/WebSocket/WebSocketManager');

describe('ConnectionService', () => {
let connectionService: ConnectionService;
let mockWebSocketManager: jest.Mocked<WebSocketManager>;

beforeEach(() => {
mockWebSocketManager = new WebSocketManager({ webex: {} as any }) as jest.Mocked<WebSocketManager>;

// Mock the onMessage and onSocketClose properties
mockWebSocketManager.onMessage = {
listen: jest.fn(),
} as any;

mockWebSocketManager.onSocketClose = {
listen: jest.fn(),
} as any;

connectionService = new ConnectionService(mockWebSocketManager);
jest.useFakeTimers();
});

afterEach(() => {
jest.clearAllMocks();
jest.useRealTimers();
});

it('should initialize ConnectionService', () => {
expect(connectionService).toBeDefined();
});

it('should set connection properties', () => {
const newProps = { lostConnectionRecoveryTimeout: 30000 };
connectionService.setConnectionProp(newProps);
expect(connectionService['connectionProp']).toEqual(newProps);
});

it('should handle ping message and update connection data', () => {
const pingMessage = JSON.stringify({ keepalive: 'true' });
connectionService['onPing'](pingMessage);
expect(connectionService['isKeepAlive']).toBe(true);
expect(connectionService['isConnectionLost']).toBe(false);
expect(connectionService['isRestoreFailed']).toBe(false);
expect(connectionService['isSocketReconnected']).toBe(false);
});
});

0 comments on commit 5665ee1

Please sign in to comment.