-
Notifications
You must be signed in to change notification settings - Fork 219
/
Copy pathQB-WebRTCSpec.js
78 lines (61 loc) · 2.13 KB
/
QB-WebRTCSpec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
describe('WebRTC API', function() {
'use strict';
var LOGIN_TIMEOUT = 10000;
var isNodeEnv = typeof window === 'undefined' && typeof exports === 'object';
var QB = isNodeEnv ? require('../src/qbMain') : window.QB;
var CREDENTIALS = isNodeEnv ? require('./config').CREDS : window.CREDS;
var CONFIG = isNodeEnv ? require('./config').CONFIG : window.CONFIG;
var QBUser1 = isNodeEnv ? require('./config').QBUser1 : window.QBUser1;
var QBUser2 = isNodeEnv ? require('./config').QBUser2 : window.QBUser2;
var session;
beforeAll(function(done){
QB.init(
CREDENTIALS.appId,
CREDENTIALS.authKey,
CREDENTIALS.authSecret,
CREDENTIALS.accountKey,
CONFIG
);
QB.chat.connect({userId: QBUser1.id, password: QBUser1.password}, function(err, roster) {
if(err){
done.fail("Chat login error: " + JSON.stringify(err));
}else{
done();
}
});
}, LOGIN_TIMEOUT);
it('can create a session', function() {
if(isNodeEnv) {
pending('WebRTC API isn\'t supported outside of the browser');
}
session = QB.webrtc.createNewSession([QBUser2.id], QB.webrtc.CallType.VIDEO);
expect(session).not.toBeNull();
expect(session.ID).not.toBeNull();
expect(session.opponentsIDs).toEqual( jasmine.any(Array) );
});
it('can not create a session with the same opponents', function() {
if(isNodeEnv) {
pending('WebRTC API isn\'t supported outside of the browser');
}
var errorString = 'Can\'t create a session with the same opponentsIDs. There is a session already in NEW or ACTIVE state.';
expect(function() {
QB.webrtc.createNewSession([QBUser2.id], QB.webrtc.CallType.VIDEO);
}).toThrow( new Error(errorString) );
});
it('can get devices', function(done) {
if(isNodeEnv) {
pending('WebRTC API isn\'t supported outside of the browser');
}
/**
* You need to be sure that your PC has devices
*/
QB.webrtc.getMediaDevices('videoinput').then(function(devices) {
expect(devices.length).not.toBeNull();
done();
});
});
afterAll(function(done) {
QB.chat.disconnect();
done();
});
});