-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from oslabs-beta/feature/sfu
Feature/sfu
- Loading branch information
Showing
3 changed files
with
93 additions
and
4,322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
*/ | ||
|
Oops, something went wrong.