Skip to content

Commit

Permalink
added handshake for future use
Browse files Browse the repository at this point in the history
  • Loading branch information
necccc committed Jul 9, 2014
1 parent 107907a commit 704beb1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ustream-embedapi",
"version": "0.0.1",
"version": "0.0.2",
"devDependencies": {
"grunt": "latest",
"grunt-mocha": "~0.4.6",
Expand Down
2 changes: 1 addition & 1 deletion pkg/ustream-embedapi.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 54 additions & 32 deletions tests/tests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@



suite('Ustream EmbedAPI tests', function() {

var MTE = createMockFrame;
Expand Down Expand Up @@ -73,11 +76,15 @@ suite('Ustream EmbedAPI tests', function() {

mte.send('ready', true);



setTimeout(function () {
var received = JSON.parse(spy.args[0][0]);
var received1 = JSON.parse(spy.args[0][0]),
received2 = JSON.parse(spy.args[1][0]);

sinon.assert.calledOnce(spy);
assert.equal(received.cmd, 'play');
sinon.assert.calledTwice(spy);
assert.equal(received1.cmd, 'apihandshake');
assert.equal(received2.cmd, 'play');
done();
}, 30);

Expand All @@ -98,10 +105,12 @@ suite('Ustream EmbedAPI tests', function() {
mte.send('ready', true);

setTimeout(function () {
var received = JSON.parse(spy.args[0][0]);
var received1 = JSON.parse(spy.args[0][0]),
received2 = JSON.parse(spy.args[1][0]);

sinon.assert.calledOnce(spy);
assert.equal(received.cmd, 'pause');
sinon.assert.calledTwice(spy);
assert.equal(received1.cmd, 'apihandshake');
assert.equal(received2.cmd, 'pause');
done();
}, 30);

Expand All @@ -122,10 +131,12 @@ suite('Ustream EmbedAPI tests', function() {
mte.send('ready', true);

setTimeout(function () {
var received = JSON.parse(spy.args[0][0]);
var received1 = JSON.parse(spy.args[0][0]),
received2 = JSON.parse(spy.args[1][0]);

sinon.assert.calledOnce(spy);
assert.equal(received.cmd, 'stop');
sinon.assert.calledTwice(spy);
assert.equal(received1.cmd, 'apihandshake');
assert.equal(received2.cmd, 'stop');
done();
}, 30);

Expand All @@ -145,12 +156,14 @@ suite('Ustream EmbedAPI tests', function() {
mte.send('ready', true);

setTimeout(function () {
var received = JSON.parse(spy.args[0][0]);

sinon.assert.calledOnce(spy);
assert.equal(received.cmd, 'load');
assert.equal(received.args[0], 'channel');
assert.equal(received.args[1], 1524);
var received1 = JSON.parse(spy.args[0][0]),
received2 = JSON.parse(spy.args[1][0]);

sinon.assert.calledTwice(spy);
assert.equal(received1.cmd, 'apihandshake');
assert.equal(received2.cmd, 'load');
assert.equal(received2.args[0], 'channel');
assert.equal(received2.args[1], 1524);
done();
}, 30);

Expand All @@ -170,11 +183,13 @@ suite('Ustream EmbedAPI tests', function() {
mte.send('ready', true);

setTimeout(function () {
var received = JSON.parse(spy.args[0][0]);
var received1 = JSON.parse(spy.args[0][0]),
received2 = JSON.parse(spy.args[1][0]);

sinon.assert.calledOnce(spy);
assert.equal(received.cmd, 'seek');
assert.equal(received.args[0], 180);
sinon.assert.calledTwice(spy);
assert.equal(received1.cmd, 'apihandshake');
assert.equal(received2.cmd, 'seek');
assert.equal(received2.args[0], 180);
done();
}, 30);

Expand All @@ -193,11 +208,13 @@ suite('Ustream EmbedAPI tests', function() {
mte.send('ready', true);

setTimeout(function () {
var received = JSON.parse(spy.args[0][0]);
var received1 = JSON.parse(spy.args[0][0]),
received2 = JSON.parse(spy.args[1][0]);

sinon.assert.calledOnce(spy);
assert.equal(received.cmd, 'volume');
assert.equal(received.args[0], 30);
sinon.assert.calledTwice(spy);
assert.equal(received1.cmd, 'apihandshake');
assert.equal(received2.cmd, 'volume');
assert.equal(received2.args[0], 30);
done();
}, 30);

Expand All @@ -217,11 +234,13 @@ suite('Ustream EmbedAPI tests', function() {
mte.send('ready', true);

setTimeout(function () {
var received = JSON.parse(spy.args[0][0]);
var received1 = JSON.parse(spy.args[0][0]),
received2 = JSON.parse(spy.args[1][0]);

sinon.assert.calledOnce(spy);
assert.equal(received.cmd, 'quality');
assert.equal(received.args[0], 16);
sinon.assert.calledTwice(spy);
assert.equal(received1.cmd, 'apihandshake');
assert.equal(received2.cmd, 'quality');
assert.equal(received2.args[0], 16);
done();
}, 30);
});
Expand Down Expand Up @@ -321,12 +340,15 @@ suite('Ustream EmbedAPI tests', function() {
sstream.socialsend('load', ['video',123456]);


var received = JSON.parse(mspy.args[0][0]);
var received1 = JSON.parse(mspy.args[0][0]),
received2 = JSON.parse(mspy.args[1][0]);

sinon.assert.calledTwice(mspy);
assert.equal(received1.cmd, 'apihandshake');

sinon.assert.calledOnce(mspy);
assert.equal(received.cmd, 'load');
assert.equal(received.args[0], 'video');
assert.equal(received.args[1], 123456);
assert.equal(received2.cmd, 'load');
assert.equal(received2.args[0], 'video');
assert.equal(received2.args[1], 123456);

done();

Expand Down

0 comments on commit 704beb1

Please sign in to comment.