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 #15 from lovebear/tests
Tests thanks @LoveBear
- Loading branch information
Showing
7 changed files
with
271 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
{ | ||
"name": "peerjs", | ||
"version": "0.1.0", | ||
"description": "PeerJS client library" | ||
"description": "PeerJS client library", | ||
"devDependencies": { | ||
"uglify-js": "*", | ||
"mocha": "*", | ||
"expect.js": "*" | ||
} | ||
} |
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,19 @@ | ||
describe('adapter', function() { | ||
|
||
it('sets browerisms', function() { | ||
expect(exports.util.browserisms).to.match(/^Firefox||Webkit$/); | ||
}) | ||
|
||
it('sets RTCPeerConnection', function() { | ||
expect(RTCPeerConnection).to.be.a('function'); | ||
}) | ||
|
||
it('sets RTCSessionDescription', function() { | ||
expect(RTCSessionDescription).to.be.a('function'); | ||
}) | ||
|
||
it('sets getUserMedia', function() { | ||
expect(getUserMedia).to.be.a('function'); | ||
}) | ||
|
||
}); |
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,65 @@ | ||
describe('DataConnection', function() { | ||
|
||
it('constructor'); | ||
|
||
it('inherits from EventEmitter'); | ||
|
||
it('initialize'); | ||
|
||
it('_setupOffer', function() { | ||
|
||
}); | ||
|
||
it('_setupDataChannel', function() { | ||
|
||
}); | ||
|
||
it('_startPeerConnection', function() { | ||
|
||
}); | ||
|
||
it('_setupIce', function() { | ||
|
||
}); | ||
|
||
it('_configureDataChannel', function() { | ||
|
||
}); | ||
|
||
it('_makeOffer', function() { | ||
|
||
}); | ||
|
||
it('_makeAnswer', function() { | ||
|
||
}); | ||
|
||
it('_cleanup', function() { | ||
|
||
}); | ||
|
||
it('_handleDataMessage', function() { | ||
|
||
}); | ||
|
||
it('close', function() { | ||
|
||
}); | ||
|
||
it('send', function() { | ||
|
||
}); | ||
|
||
it('handleSDP', function() { | ||
|
||
}); | ||
|
||
it('handleCandidate', function() { | ||
|
||
}); | ||
|
||
it('handleLeave"', function() { | ||
|
||
}); | ||
|
||
}); |
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,25 @@ | ||
describe('Peer', function() { | ||
|
||
it('constructor') | ||
|
||
it('inherits from EventEmitter') | ||
|
||
it('_getId') | ||
|
||
it('_init') | ||
|
||
it('_handleServerJSONMessage') | ||
|
||
it('_processQueue') | ||
|
||
it('_abort') | ||
|
||
it('_cleanup') | ||
|
||
it('_attachConnectionListeners') | ||
|
||
it('connect') | ||
|
||
it('destroy') | ||
|
||
}); |
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,23 @@ | ||
describe('Socket', function() { | ||
|
||
it('constructor') | ||
|
||
it('inherits from EventEmitter') | ||
|
||
it('start') | ||
|
||
it('_startWebSocket') | ||
|
||
it('_startXhrStream') | ||
|
||
it('_handleStream') | ||
|
||
it('_setHTTPTimeout') | ||
|
||
it('send') | ||
|
||
it('close') | ||
|
||
it('_wsOpen') | ||
|
||
}); |
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,35 @@ | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Mocha Tests</title> | ||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" /> | ||
</head> | ||
<body> | ||
<div id="mocha"></div> | ||
<script> | ||
var exports = this; | ||
</script> | ||
<script src="../deps/js-binarypack/lib/bufferbuilder.js"></script> | ||
<script src="../deps/js-binarypack/lib/binarypack.js"></script> | ||
<script src="../deps/EventEmitter/EventEmitter.js"></script> | ||
<script src="../lib/util.js"></script> | ||
<script src="../lib/adapter.js"></script> | ||
<script src="../lib/connection.js"></script> | ||
<script src="../lib/peer.js"></script> | ||
<script src="../lib/socket.js"></script> | ||
|
||
<script src="../node_modules/expect.js/expect.js"></script> | ||
<script src="../node_modules/mocha/mocha.js"></script> | ||
<script>mocha.setup('bdd')</script> | ||
|
||
<script src="adapter.js"></script> | ||
<script src="util.js"></script> | ||
<script src="connection.js"></script> | ||
<script src="peer.js"></script> | ||
<script src="socket.js"></script> | ||
|
||
<script> | ||
mocha.run(); | ||
</script> | ||
</body> | ||
</html> |
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,98 @@ | ||
describe('util', function() { | ||
|
||
var testRandom = function(fn) { | ||
var i = 0 | ||
, generated = {}; | ||
while(i < 25) { | ||
var p = fn(); | ||
if (generated[p]) throw new Error('not so random') | ||
generated[p] = 1; | ||
i++; | ||
} | ||
} | ||
|
||
it('inherits', function() { | ||
function ctor() {} | ||
function superCtor() {} | ||
superCtor.prototype.test = function() { return 5; } | ||
util.inherits(ctor, superCtor); | ||
expect(new ctor()).to.be.a(superCtor); | ||
expect(new ctor().test()).to.be.equal(5); | ||
}) | ||
|
||
/* | ||
* extend overwrites keys if already exists | ||
* leaves existing keys alone otherwise | ||
*/ | ||
it('extend', function() { | ||
var a = {a: 1, b: 2, c: 3, d: 4} | ||
, b = {d: 2}; | ||
util.extend(b, a); | ||
expect(b).to.eql(a); | ||
expect(b.d).to.be.equal(4); | ||
b = {z: 2}; | ||
util.extend(b, a); | ||
expect(b.z).to.be.equal(2); | ||
}) | ||
|
||
it('pack', function() { | ||
expect(util.pack).to.be.equal(BinaryPack.pack); | ||
}) | ||
|
||
it('unpack', function() { | ||
expect(util.unpack).to.be.equal(BinaryPack.unpack); | ||
}) | ||
|
||
it('randomPort', function() { | ||
testRandom(util.randomPort); | ||
}) | ||
|
||
// FF no like | ||
it('log', function(done) { | ||
var consolelog = console.log; | ||
// default is false | ||
expect(util.debug).to.be.equal(false); | ||
util.debug = true; | ||
console.log = function() { | ||
var arg = Array.prototype.slice.call(arguments); | ||
expect(arg.join(' ')).to.be.equal('PeerJS: hi'); | ||
done(); | ||
} | ||
util.log('hi'); | ||
// reset | ||
console.log = consolelog; | ||
util.debug = false; | ||
}) | ||
|
||
it('setZeroTimeout') | ||
|
||
it('blobToArrayBuffer', function(done) { | ||
var blob = new Blob(['hi']); | ||
util.blobToArrayBuffer(blob, function(result) { | ||
expect(result.byteLength).to.be.equal(2); | ||
expect(result.slice).to.be.a('function'); | ||
expect(result instanceof ArrayBuffer).to.be.equal(true); | ||
done(); | ||
}); | ||
}) | ||
|
||
it('blobToBinaryString', function(done) { | ||
var blob = new Blob(['hi']); | ||
util.blobToBinaryString(blob, function(result) { | ||
expect(result).to.equal('hi'); | ||
done(); | ||
}); | ||
}) | ||
|
||
it('binaryStringToArrayBuffer', function() { | ||
var ba = util.binaryStringToArrayBuffer('\0\0'); | ||
expect(ba.byteLength).to.be.equal(2); | ||
expect(ba.slice).to.be.a('function'); | ||
expect(ba instanceof ArrayBuffer).to.be.equal(true); | ||
}) | ||
|
||
it('randomToken', function() { | ||
testRandom(util.randomToken); | ||
}) | ||
|
||
}); |