Skip to content

Commit 9aeb895

Browse files
author
dimaspirit
committed
review Specs
modify for Node env. [part1]
1 parent f4f6d43 commit 9aeb895

14 files changed

+276
-268
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ npm-debug.log
1010

1111
# Use command grunt for create quickblox.js
1212
quickblox.js
13+
14+
#jasmine-npm generate
15+
.grunt

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
"grunt-contrib-watch": "^0.6.1",
5454
"grunt-notify": "^0.4.1",
5555
"grunt-parallel": "^0.4.1",
56-
"load-grunt-tasks": "^1.0.0",
57-
"xml2js": "^0.4.12"
56+
"jasmine": "^2.4.1",
57+
"load-grunt-tasks": "^1.0.0"
5858
},
5959
"autoupdate": {
6060
"source": "git",

quickblox.min.js

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/QB-ChatSpec.js

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
var LOGIN_TIMEOUT = 10000;
2-
var MESSAGING_TIMEOUT = 1500;
3-
var IQ_TIMEOUT = 1000;
4-
var REST_REQUESTS_TIMEOUT = 3000;
5-
61
describe('Chat API', function() {
2+
var LOGIN_TIMEOUT = 10000;
3+
var MESSAGING_TIMEOUT = 1500;
4+
var IQ_TIMEOUT = 1000;
5+
var REST_REQUESTS_TIMEOUT = 3000;
76

87
describe('XMPP (real time messaging)', function() {
98

10-
// beforeAll
11-
//
129
beforeAll(function(done){
13-
1410
QB.init(CREDENTIALS.appId, CREDENTIALS.authKey, CREDENTIALS.authSecret, CONFIG);
1511

1612
QB.chat.connect({userId: QBUser1.id, password: QBUser1.password}, function(err, roster) {
@@ -21,18 +17,15 @@ describe('Chat API', function() {
2117
done();
2218
}
2319
});
24-
2520
}, LOGIN_TIMEOUT);
2621

2722

2823
// 1-1 mesasging
2924
//
3025
it('can send and receive private messages', function(done) {
31-
3226
var self = this;
3327

3428
QB.chat.onMessageListener = function(userId, receivedMessage){
35-
3629
expect(receivedMessage).not.toBeNull();
3730
expect(receivedMessage.type).toEqual("chat");
3831
expect(userId).toEqual(QBUser1.id);
@@ -55,16 +48,15 @@ describe('Chat API', function() {
5548
},
5649
markable: 1
5750
};
58-
QB.chat.send(QBUser1.id, message);
59-
this.messageId = message.id;
6051

52+
QB.chat.send(QBUser1.id, message);
53+
self.messageId = message.id;
6154
}, MESSAGING_TIMEOUT);
6255

6356

6457
// System messages
6558
//
6659
it('can send and receive system messages', function(done) {
67-
6860
var self = this;
6961

7062
QB.chat.onSystemMessageListener = function(receivedMessage){
@@ -87,15 +79,14 @@ describe('Chat API', function() {
8779
}
8880
};
8981
QB.chat.sendSystemMessage(QBUser1.id, message);
90-
this.messageId = message.id;
82+
self.messageId = message.id;
9183

9284
}, MESSAGING_TIMEOUT);
9385

9486

9587
// 'Delivered' status
9688
//
9789
it("can send and receive 'delivered' status", function(done) {
98-
9990
var self = this;
10091

10192
QB.chat.onDeliveredStatusListener = function(messageId, dialogId, userId){
@@ -112,7 +103,7 @@ describe('Chat API', function() {
112103
userId: QBUser1.id,
113104
dialogId: "507f191e810c19729de860ea"
114105
};
115-
this.params = params;
106+
self.params = params;
116107

117108
QB.chat.sendDeliveredStatus(params);
118109

@@ -122,7 +113,6 @@ describe('Chat API', function() {
122113
// 'Read' status
123114
//
124115
it("can send and receive 'read' status", function(done) {
125-
126116
var self = this;
127117

128118
QB.chat.onReadStatusListener = function(messageId, dialogId, userId){
@@ -139,7 +129,7 @@ describe('Chat API', function() {
139129
userId: QBUser1.id,
140130
dialogId: "507f191e810c19729de860ea"
141131
};
142-
this.params = params;
132+
self.params = params;
143133

144134
QB.chat.sendReadStatus(params);
145135

@@ -149,7 +139,6 @@ describe('Chat API', function() {
149139
// 'Is typing' status
150140
//
151141
it("can send and receive 'is typing' status (private)", function(done) {
152-
153142
QB.chat.onMessageTypingListener = function(composing, userId, dialogId){
154143
expect(composing).toEqual(true);
155144
expect(userId).toEqual(QBUser1.id);
@@ -166,7 +155,6 @@ describe('Chat API', function() {
166155
// 'Stop typing' status
167156
//
168157
it("can send and receive 'stop typing' status (private)", function(done) {
169-
170158
QB.chat.onMessageTypingListener = function(composing, userId, dialogId){
171159
expect(composing).toEqual(false);
172160
expect(userId).toEqual(QBUser1.id);
@@ -408,13 +396,12 @@ describe('Chat API', function() {
408396
// Dialog update
409397
//
410398
it('can update a dialog (group)', function(done) {
411-
412399
var toUpdate = {
413400
name: "GroupDialogNewName",
414401
pull_all: {occupants_ids: [QBUser2.id]}
415402
};
416-
QB.chat.dialog.update(dialogId, toUpdate, function(err, res) {
417403

404+
QB.chat.dialog.update(dialogId, toUpdate, function(err, res) {
418405
if(err){
419406
done.fail("Update dialog " + dialogId + " error: " + JSON.stringify(err));
420407
}else{
@@ -428,16 +415,13 @@ describe('Chat API', function() {
428415
});
429416
}, REST_REQUESTS_TIMEOUT);
430417

431-
432418
// Can create a message
433419
//
434420
it('can create a mesasge', function(done) {
435-
436421
var params = {chat_dialog_id: dialogId,
437422
message: "hello world",
438423
};
439424
QB.chat.message.create(params, function(err, res) {
440-
441425
if(err){
442426
done.fail("Create a mesasge error: " + JSON.stringify(err));
443427
}else{
@@ -457,10 +441,9 @@ describe('Chat API', function() {
457441
// Messages list
458442
//
459443
it('can list messages', function(done) {
460-
461444
var filters = {chat_dialog_id: dialogId};
462-
QB.chat.message.list(filters, function(err, res) {
463445

446+
QB.chat.message.list(filters, function(err, res) {
464447
if(err){
465448
done.fail("List messages error: " + JSON.stringify(err));
466449
}else{
@@ -469,18 +452,16 @@ describe('Chat API', function() {
469452

470453
done();
471454
}
472-
473455
});
474456
}, REST_REQUESTS_TIMEOUT);
475457

476458

477459
// Unread messages count
478460
//
479461
it('can request unread messages count', function(done) {
480-
481462
var params = {chat_dialog_ids: [dialogId]};
482-
QB.chat.message.unreadCount(params, function(err, res) {
483463

464+
QB.chat.message.unreadCount(params, function(err, res) {
484465
if(err){
485466
done.fail("Request unread messages count error: " + JSON.stringify(err));
486467
}else{
@@ -501,7 +482,6 @@ describe('Chat API', function() {
501482
console.log("messageId: " + messageId);
502483

503484
QB.chat.message.delete([messageId, "notExistentId"], {force: 1}, function(err, res) {
504-
505485
if(err){
506486
done.fail("Delete message " + messageId + " error: " + JSON.stringify(err));
507487
}else{
@@ -517,9 +497,7 @@ describe('Chat API', function() {
517497
// Dialog delete
518498
//
519499
it('can delete a dialog (group)', function(done) {
520-
521500
QB.chat.dialog.delete([dialogId, "notExistentId"], {force: 1}, function(err, res) {
522-
523501
if(err){
524502
done.fail("Delete dialog " + dialogId + " error: " + JSON.stringify(err));
525503
}else{
@@ -532,7 +510,5 @@ describe('Chat API', function() {
532510

533511
});
534512
}, REST_REQUESTS_TIMEOUT);
535-
536513
});
537-
538514
});

spec/QB-ContentSpec.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
var REST_REQUESTS_TIMEOUT = 3000;
2-
31
describe('Content API', function() {
2+
var REST_REQUESTS_TIMEOUT = 3000;
3+
44
var token,
55
data = {};
66

7-
// beforeAll
8-
//
97
beforeAll(function(done){
108
QB.init(CREDENTIALS.appId, CREDENTIALS.authKey, CREDENTIALS.authSecret);
119

@@ -58,12 +56,14 @@ describe('Content API', function() {
5856
done.fail("Create and upload files error: " + JSON.stringify(err));
5957
}else{
6058
var elemId = response.id;
59+
6160
QB.content.delete(elemId, function(err, result) {
6261
if (err) {
6362
done.fail("Delete content objects error: " + JSON.stringify(err));
6463
}else{
6564
expect(result).toEqual(true);
6665
console.info('can delete content objects');
66+
6767
done();
6868
}
6969
});
@@ -92,7 +92,8 @@ describe('Content API', function() {
9292
var fileUID = "97f5802dcbd34a59a4921d73f6baedd000",
9393
privateURL = QB.content.privateUrl(fileUID);
9494

95-
expect(privateURL).toBe("https://api.quickblox.com/blobs/97f5802dcbd34a59a4921d73f6baedd000?token="+token);
95+
expect(privateURL).toBe("https://api.quickblox.com/blobs/97f5802dcbd34a59a4921d73f6baedd000?token=" + token);
96+
9697
console.info('can access private URL');
9798
});
9899

0 commit comments

Comments
 (0)