More test
This commit is contained in:
parent
102b39f066
commit
6a1b20f80e
@ -27,6 +27,7 @@ describe('PeerServer', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#_initializeWSS', function() {
|
describe('#_initializeWSS', function() {
|
||||||
|
WebSocketServer = sinon.stub();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -35,6 +36,42 @@ describe('PeerServer', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#_checkKey', function() {
|
describe('#_checkKey', function() {
|
||||||
|
var p;
|
||||||
|
before(function() {
|
||||||
|
PeerServer.prototype._initializeHTTP = sinon.stub();
|
||||||
|
p = new PeerServer({ port: 8000 });
|
||||||
|
p._checkKey('peerjs', 'myip', function() {});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject keys that are not the default', function(done) {
|
||||||
|
p._checkKey('bad key', null, function(response) {
|
||||||
|
expect(response).to.be('Invalid key provided');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should accept valid key/ip pairs', function(done) {
|
||||||
|
p._checkKey('peerjs', 'myip', function(response) {
|
||||||
|
expect(response).to.be(null);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject ips that are at their limit', function(done) {
|
||||||
|
p._options.ip_limit = 0;
|
||||||
|
p._checkKey('peerjs', 'myip', function(response) {
|
||||||
|
expect(response).to.be('myip has reached its concurrent user limit');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject when the server is at its limit', function(done) {
|
||||||
|
p._options.concurrent_limit = 0;
|
||||||
|
p._checkKey('peerjs', 'myip', function(response) {
|
||||||
|
expect(response).to.be('Server has reached its concurrent user limit');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,10 +96,18 @@ describe('PeerServer', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#_handleTransmission', function() {
|
describe('#_handleTransmission', function() {
|
||||||
|
// TODO: this is probably the most important method to test.
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#_generateClientId', function() {
|
describe('#_generateClientId', function() {
|
||||||
|
var p;
|
||||||
|
before(function() {
|
||||||
|
PeerServer.prototype._initializeHTTP = sinon.stub();
|
||||||
|
p = new PeerServer({ port: 8000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should generate a 16-character ID', function() {
|
||||||
|
expect(p._generateClientId('anykey').length).to.be(16);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user