forked from lynckia/licode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnuve-api-spec.js
115 lines (95 loc) · 2.95 KB
/
nuve-api-spec.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
var assert = require('chai').assert;
var N = require('../nuve/nuveClient/dist/nuve'),
config = require('../licode_config');
var TIMEOUT=10000,
ROOM_NAME="myTestRoom";
var id;
describe("nuve", function () {
this.timeout (TIMEOUT);
beforeEach(function () {
N.API.init(config.nuve.superserviceID, config.nuve.superserviceKey, 'http://localhost:3000/');
});
it("should not list rooms with wrong credentials", function () {
var rooms;
var received = false, ok = false;
N.API.init("Jose Antonio", config.nuve.superserviceKey, 'http://localhost:3000/');
N.API.getRooms(function(rooms_) {
ok = true;
throw "Succeeded and it should fail with bad credentials";
}, function(error) {
ok = false;
done();
});
});
it("should list rooms", function () {
var rooms;
var received = false, ok = false;
N.API.getRooms(function(rooms_) {
assert.isArray(rooms_, "This should be an array of rooms");
done();
}, function(error) {
throw error;
});
});
it("should create normal rooms", function () {
N.API.createRoom(ROOM_NAME, function(room) {
done();
});
});
it("should get normal rooms", function () {
N.API.getRoom(id, function(result) {
done();
}, function(error) {
throw error;
});
});
it("should create tokens for users in normal rooms", function () {
N.API.createToken(id, "user", "presenter", function(token) {
done();
}, function(error) {
throw error;
});
});
it("should create tokens for users with special characters in normal rooms", function () {
N.API.createToken(id, "user_with_$?üóñ", "role", function(token) {
done()
}, function(error) {
throw error;
});
});
it("should get users in normal rooms", function () {
N.API.getUsers(id, function(token) {
done()
}, function(error) {
throw error;
});
});
it("should delete normal rooms", function () {
N.API.deleteRoom(id, function(result) {
done;
}, function(error) {
throw error;
});
});
it("should create p2p rooms", function () {
N.API.createRoom(ROOM_NAME, function(room) {
id = room._id;
assert.notEqual(id, undefined, 'Did not provide a valid id');
done()
}, function() {}, {p2p: true});
});
it("should get p2p rooms", function () {
N.API.getRoom(id, function(result) {
done()
}, function(error) {
throw error;
});
});
it("should delete p2p rooms", function () {
N.API.deleteRoom(id, function(result) {
done()
}, function(error) {
throw error;
});
});
});