Skip to content

Commit

Permalink
Merge pull request #64 from oslabs-beta/feature/sfu
Browse files Browse the repository at this point in the history
Feature/sfu
  • Loading branch information
fraisai authored Jan 20, 2024
2 parents e0c845c + 637b6b2 commit 60ef865
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 4,322 deletions.
66 changes: 66 additions & 0 deletions lib/__tests__/integration/server.integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
// import http from 'http';
'use strict';
import SignalingChannel from '../../server/server';
import { WebSocket } from 'ws';
// import { Server } from 'http';
// import { Event, WebSocketServer } from 'ws';

WebSocket.EventEmitter;
beforeAll((done) => {
done();
});

describe('Testing the SignalingChannel class', () => {
const sc = new SignalingChannel(65530);
const testWebsocketServer = new WebSocket.Server({ port: 5555 });
describe('Testing SignalingChannel constructor', () => {
it('WebSocket server object is initialized', () => {
expect(typeof sc.webSocketServer).toBe('object');
});

it('WebSocket server object is initialized', () => {
expect(typeof sc.webSocketServer).toBe(typeof testWebsocketServer);
});

it('Empty hashmap of users is initialized', () => {
expect(sc.peers.size).toBe(0);
});
});

afterAll((done) => {
sc.webSocketServer.close();
testWebsocketServer.close();
done();
});
});

/*
describe('Checking WebSocket response', () => {
const sc1 = new SignalingChannel(3032);
// sc1.webSocketServer.onopen;
// // Source: https://stackoverflow.com/questions/55963562/how-to-stop-jest-from-hanging-when-testing-websockets
// it('WebSocket closes connection correctly', () => {
// let disconnected = false;
// sc1.webSocketServer.addListener('close', () => {
// disconnected = true;
// sc1.webSocketServer.close();
// });
// // let error: ErrorEvent;
// // ws.onerror = (e) => {
// // console.log(error)
// // error = e;
// // };
// // expect(error.origin).toBe(`ws://localhost:${port}`);
// expect(disconnected).toBe(true);
// });
afterAll((done) => {
sc1.webSocketServer.close();
done();
});
});
*/

Loading

0 comments on commit 60ef865

Please sign in to comment.