Skip to content

Commit

Permalink
Fix broken tests and remove an uneccessary test
Browse files Browse the repository at this point in the history
  • Loading branch information
KaptenJansson committed Nov 13, 2017
1 parent 86cc2cf commit b224656
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 95 deletions.
62 changes: 31 additions & 31 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"karma-eslint": ">=2.1.0",
"karma-firefox-launcher": ">=1.0.0",
"karma-jasmine": ">=1.0.2",
"travis-multirunner": ">=3.0.0",
"webrtc-adapter": ">=3.0.0"
"travis-multirunner": "^4.2.5",
"webrtc-adapter": "^6.0.0"
},
"dependencies": {
"pako": "^1.0.3"
"pako": "^1.0.6"
}
}
5 changes: 3 additions & 2 deletions src/web_app/js/call_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* More information about these options at jshint.com/docs/options */

/* globals describe, Call, expect, it, beforeEach, afterEach,
/* globals describe, Call, expect, FAKE_ICE_SERVER, beforeEach, afterEach,
SignalingChannel:true, MockWindowPort, FAKE_WSS_POST_URL, FAKE_ROOM_ID,
FAKE_CLIENT_ID, apprtc, Constants, xhrs, MockXMLHttpRequest,
XMLHttpRequest:true */
Expand Down Expand Up @@ -64,7 +64,8 @@ describe('Call test', function() {
audio: true, video: true
},
roomId: FAKE_ROOM_ID,
clientId: FAKE_CLIENT_ID
clientId: FAKE_CLIENT_ID,
peerConnectionConfig: {iceServers: FAKE_ICE_SERVER}
};

XMLHttpRequest = MockXMLHttpRequest;
Expand Down
66 changes: 9 additions & 57 deletions src/web_app/js/peerconnectionclient_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

/* More information about these options at jshint.com/docs/options */

/* globals describe, done, expect, jasmine, it, beforeEach, afterEach,
PeerConnectionClient */
/* globals describe, done, expect, FAKE_CANDIDATE, FAKE_SDP, jasmine, it,
beforeEach, afterEach, PeerConnectionClient */

'use strict';

Expand Down Expand Up @@ -139,16 +139,15 @@ describe('PeerConnectionClient Test', function() {
this.realRTCPeerConnection = window.RTCPeerConnection;
window.RTCPeerConnection = MockRTCPeerConnection;

peerConnections.length = 0;
this.pcClient = new PeerConnectionClient(
getParams(FAKEPCCONFIG, FAKEPCCONSTRAINTS), window.performance.now());
});

afterEach(function() {
peerConnections = [];
window.RTCPeerConnection = this.realRTCPeerConnection;
// this.pcClient.close();
// this.pcClient = null;
this.pcClient.close();
this.pcClient = null;
});

it('Constructor', function() {
Expand All @@ -165,59 +164,12 @@ describe('PeerConnectionClient Test', function() {
});

it('Start as a caller', function(done) {
var fakeCandidate = 'fake candidate';
var pc = peerConnections[0];
var event = {
candidate: {
sdpMLineIndex: 0,
sdpMid: '1',
candidate: fakeCandidate
}
};
var expectedMessage = {
type: 'candidate',
label: event.candidate.sdpMLineIndex,
id: event.candidate.sdpMid,
candidate: event.candidate.candidate
};
// Verify the input to setLocalDesciption.
pc.onlocaldescription = function() {
expect(pc.localDescriptions.length).toEqual(1);
expect(pc.localDescriptions[0].description.type).toEqual('offer');
expect(pc.localDescriptions[0].description.sdp).toEqual(fakeSdp);
};

this.pcClient.onsignalingmessage = function(msg) {
// Verify the output signaling message for the offer.
if (msg.type === 'offer') {
expect(msg.sdp).toEqual(fakeSdp);
// Trigger the candidate event test.
pc.onicecandidate(event);
// Verify the output signaling messages for the ICE candidates.
} else {
expect(msg.type).toEqual('candidate');
expect(msg).toEqual(expectedMessage);
done();
}
};

expect(this.pcClient.startAsCaller(null)).toBeTruthy();

expect(pc.createSdpRequests.length).toEqual(1);
var request = pc.createSdpRequests[0];
expect(request.type).toEqual('offer');

var fakeSdp = 'fake sdp';
pc.resolveLastCreateSdpRequest(fakeSdp);
});

it('Caller receive signaling message', function(done) {
var pc = peerConnections[0];
var self = this;
var candidate = {
type: 'candidate',
label: 0,
candidate: 'fake candidate'
candidate: FAKE_CANDIDATE
};
var remoteAnswer = {
type: 'answer',
Expand Down Expand Up @@ -258,12 +210,12 @@ describe('PeerConnectionClient Test', function() {

var remoteOffer = {
type: 'offer',
sdp: 'fake sdp'
sdp: FAKE_SDP
};
var candidate = {
type: 'candidate',
label: 0,
candidate: 'fake candidate'
candidate: FAKE_CANDIDATE
};
var initialMsgs = [
JSON.stringify(candidate),
Expand Down Expand Up @@ -307,7 +259,7 @@ describe('PeerConnectionClient Test', function() {
it('Receive remote offer before started', function() {
var remoteOffer = {
type: 'offer',
sdp: 'fake sdp'
sdp: FAKE_CANDIDATE
};
this.pcClient.receiveSignalingMessage(JSON.stringify(remoteOffer));
this.pcClient.startAsCallee(null);
Expand Down Expand Up @@ -338,7 +290,7 @@ describe('PeerConnectionClient Test', function() {

var remoteOffer = {
type: 'offer',
sdp: 'fake sdp'
sdp: FAKE_SDP
};
var initialMsgs = [JSON.stringify(remoteOffer)];
expect(this.pcClient.startAsCallee(initialMsgs)).toBeTruthy();
Expand Down
39 changes: 37 additions & 2 deletions src/web_app/js/test_mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
/* More information about these options at jshint.com/docs/options */

/* globals expect */
/* exported FAKE_WSS_POST_URL, FAKE_WSS_URL, FAKE_WSS_POST_URL, FAKE_ROOM_ID,
/* exported FAKE_CANDIDATE, FAKE_SDP, FAKE_ICE_SERVER, FAKE_SEND_EXCEPTION,
FAKE_WSS_POST_URL, FAKE_WSS_URL, FAKE_WSS_POST_URL, FAKE_ROOM_ID,
FAKE_CLIENT_ID, MockWebSocket, MockXMLHttpRequest, webSockets, xhrs,
MockWindowPort, FAKE_SEND_EXCEPTION, Mock */
MockWindowPort, Mock */

'use strict';

Expand All @@ -20,6 +21,40 @@ var FAKE_WSS_POST_URL = 'https://foo.com';
var FAKE_ROOM_ID = 'bar';
var FAKE_CLIENT_ID = 'barbar';
var FAKE_SEND_EXCEPTION = 'Send exception';
var FAKE_ICE_SERVER = [
{
credential: 'foobar',
urls: ['turn:192.168.1.200:19305?transport:udp'],
username: 'barfoo',
},
{urls: ['stun:stun.l.google.com:19302']}
];

var FAKE_CANDIDATE = 'candidate:702786350 2 udp 41819902 8.8.8.8 60769 ' +
'typ relay raddr 8.8.8.8 rport 1234 ' +
'tcptype active ' +
'ufrag abc ' +
'generation 0';

var FAKE_SDP = 'v=0\r\n' +
'o=- 166855176514521964 2 IN IP4 127.0.0.1\r\n' +
's=-\r\n' +
't=0 0\r\n' +
'a=msid-semantic:WMS *\r\n' +
'm=audio 9 UDP/TLS/RTP/SAVPF 111\r\n' +
'c=IN IP4 0.0.0.0\r\n' +
'a=rtcp:9 IN IP4 0.0.0.0\r\n' +
'a=ice-ufrag:someufrag\r\n' +
'a=ice-pwd:somelongpwdwithenoughrandomness\r\n' +
'a=fingerprint:sha-256 8C:71:B3:8D:A5:38:FD:8F:A4:2E:A2:65:6C:86:52' +
':BC:E0:6E:94:F2:9F:7C:4D:B5:DF:AF:AA:6F:44:90:8D:F4\r\n' +
'a=setup:actpass\r\n' +
'a=rtcp-mux\r\n' +
'a=mid:mid1\r\n' +
'a=sendonly\r\n' +
'a=rtpmap:111 opus/48000/2\r\n' +
'a=msid:stream1 track1\r\n' +
'a=ssrc:1001 cname:some\r\n';

var webSockets = [];
var MockWebSocket = function(url) {
Expand Down

0 comments on commit b224656

Please sign in to comment.