Keep up with QUnit API change.
This commit is contained in:
304
static/test.js
304
static/test.js
@@ -61,35 +61,35 @@ var logout = function(callback) {
|
|||||||
QUnit.testStart(localStorage.clear.bind(localStorage));
|
QUnit.testStart(localStorage.clear.bind(localStorage));
|
||||||
QUnit.testDone(localStorage.clear.bind(localStorage));
|
QUnit.testDone(localStorage.clear.bind(localStorage));
|
||||||
|
|
||||||
module('All platforms');
|
QUnit.module('All platforms');
|
||||||
|
|
||||||
test('Construct/shutdown', function() {
|
QUnit.test('Construct/shutdown', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
var cosmo = new Cosmopolite({}, null, randstring());
|
var cosmo = new Cosmopolite({}, null, randstring());
|
||||||
ok(true, 'new Cosmopolite() succeeds');
|
assert.ok(true, 'new Cosmopolite() succeeds');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
ok(true, 'shutdown() succeeds');
|
assert.ok(true, 'shutdown() succeeds');
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('onConnect/onLogout fires', function() {
|
QUnit.asyncTest('onConnect/onLogout fires', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var numCallbacks = 0;
|
var numCallbacks = 0;
|
||||||
|
|
||||||
logout(function() {
|
logout(function() {
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onConnect': function() {
|
'onConnect': function() {
|
||||||
ok(true, 'onConnect fired');
|
assert.ok(true, 'onConnect fired');
|
||||||
if (++numCallbacks == 2) {
|
if (++numCallbacks == 2) {
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'onLogout': function(login_url) {
|
'onLogout': function(login_url) {
|
||||||
ok(true, 'onLogout fired');
|
assert.ok(true, 'onLogout fired');
|
||||||
if (++numCallbacks == 2) {
|
if (++numCallbacks == 2) {
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -97,18 +97,18 @@ asyncTest('onConnect/onLogout fires', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Message round trip', function() {
|
QUnit.asyncTest('Message round trip', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(e) {
|
'onMessage': function(e) {
|
||||||
equal(e['subject']['name'], subject, 'subject matches');
|
assert.equal(e['subject']['name'], subject, 'subject matches');
|
||||||
equal(e['message'], message, 'message matches');
|
assert.equal(e['message'], message, 'message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,18 +117,18 @@ asyncTest('Message round trip', function() {
|
|||||||
cosmo.subscribe(subject, -1);
|
cosmo.subscribe(subject, -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Message round trip without channel', function() {
|
QUnit.asyncTest('Message round trip without channel', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(e) {
|
'onMessage': function(e) {
|
||||||
equal(e['subject']['name'], subject, 'subject matches');
|
assert.equal(e['subject']['name'], subject, 'subject matches');
|
||||||
equal(e['message'], message, 'message matches');
|
assert.equal(e['message'], message, 'message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -138,8 +138,8 @@ asyncTest('Message round trip without channel', function() {
|
|||||||
cosmo.subscribe(subject, -1);
|
cosmo.subscribe(subject, -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Bulk subscribe', function() {
|
QUnit.asyncTest('Bulk subscribe', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject1 = randstring();
|
var subject1 = randstring();
|
||||||
var subject2 = randstring();
|
var subject2 = randstring();
|
||||||
@@ -149,10 +149,10 @@ asyncTest('Bulk subscribe', function() {
|
|||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(e) {
|
'onMessage': function(e) {
|
||||||
equal(e['message'], message, 'message matches');
|
assert.equal(e['message'], message, 'message matches');
|
||||||
if (++messages == 2) {
|
if (++messages == 2) {
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -163,8 +163,8 @@ asyncTest('Bulk subscribe', function() {
|
|||||||
cosmo.subscribe([subject1, subject2], -1);
|
cosmo.subscribe([subject1, subject2], -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Complex object', function() {
|
QUnit.asyncTest('Complex object', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = {
|
var message = {
|
||||||
@@ -180,10 +180,10 @@ asyncTest('Complex object', function() {
|
|||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(e) {
|
'onMessage': function(e) {
|
||||||
equal(e['subject']['name'], subject, 'subject matches');
|
assert.equal(e['subject']['name'], subject, 'subject matches');
|
||||||
deepEqual(e['message'], message, 'message matches');
|
assert.deepEqual(e['message'], message, 'message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -192,41 +192,41 @@ asyncTest('Complex object', function() {
|
|||||||
cosmo.subscribe(subject, -1);
|
cosmo.subscribe(subject, -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('sendMessage Promise', function() {
|
QUnit.asyncTest('sendMessage Promise', function(assert) {
|
||||||
expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
|
|
||||||
var cosmo = new Cosmopolite({}, null, randstring());
|
var cosmo = new Cosmopolite({}, null, randstring());
|
||||||
cosmo.sendMessage(subject, message).then(function(msg) {
|
cosmo.sendMessage(subject, message).then(function(msg) {
|
||||||
ok(true, 'sendMessage Promise fulfilled');
|
assert.ok(true, 'sendMessage Promise fulfilled');
|
||||||
equal(msg['subject']['name'], subject);
|
assert.equal(msg['subject']['name'], subject);
|
||||||
equal(msg['message'], message);
|
assert.equal(msg['message'], message);
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('subscribe/unsubscribe Promise', function() {
|
QUnit.asyncTest('subscribe/unsubscribe Promise', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
|
|
||||||
var cosmo = new Cosmopolite({}, null, randstring());
|
var cosmo = new Cosmopolite({}, null, randstring());
|
||||||
cosmo.subscribe(subject).then(function() {
|
cosmo.subscribe(subject).then(function() {
|
||||||
ok(true, 'subscribe Promise fulfilled');
|
assert.ok(true, 'subscribe Promise fulfilled');
|
||||||
cosmo.unsubscribe(subject).then(function() {
|
cosmo.unsubscribe(subject).then(function() {
|
||||||
ok(true, 'unsubscribe Promise fulfilled');
|
assert.ok(true, 'unsubscribe Promise fulfilled');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Duplicate message suppression', function() {
|
QUnit.asyncTest('Duplicate message suppression', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message1 = randstring();
|
var message1 = randstring();
|
||||||
@@ -234,10 +234,10 @@ asyncTest('Duplicate message suppression', function() {
|
|||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(msg) {
|
'onMessage': function(msg) {
|
||||||
equal(msg['subject']['name'], subject, 'subject matches');
|
assert.equal(msg['subject']['name'], subject, 'subject matches');
|
||||||
equal(msg['message'], message1, 'message matches');
|
assert.equal(msg['message'], message1, 'message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -255,8 +255,8 @@ asyncTest('Duplicate message suppression', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Message persistence', function() {
|
QUnit.asyncTest('Message persistence', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
@@ -269,10 +269,10 @@ asyncTest('Message persistence', function() {
|
|||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(msg) {
|
'onMessage': function(msg) {
|
||||||
equal(msg['subject']['name'], subject, 'subject matches');
|
assert.equal(msg['subject']['name'], subject, 'subject matches');
|
||||||
equal(msg['message'], message, 'message matches');
|
assert.equal(msg['message'], message, 'message matches');
|
||||||
cosmo2.shutdown();
|
cosmo2.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -281,25 +281,25 @@ asyncTest('Message persistence', function() {
|
|||||||
// Should pick up the message from the persistent queue.
|
// Should pick up the message from the persistent queue.
|
||||||
});
|
});
|
||||||
|
|
||||||
test('getMessages/subscribe', function() {
|
QUnit.test('getMessages/subscribe', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
|
|
||||||
var cosmo = new Cosmopolite({}, null, randstring());
|
var cosmo = new Cosmopolite({}, null, randstring());
|
||||||
throws(
|
assert.throws(
|
||||||
cosmo.getMessages.bind(undefined, subject),
|
cosmo.getMessages.bind(undefined, subject),
|
||||||
'getMessages before subscribe fails');
|
'getMessages before subscribe fails');
|
||||||
cosmo.subscribe(subject);
|
cosmo.subscribe(subject);
|
||||||
// Verify that we can call getMessages immediately after subscribe
|
// Verify that we can call getMessages immediately after subscribe
|
||||||
cosmo.getMessages(subject);
|
cosmo.getMessages(subject);
|
||||||
ok(true, 'getMessages after subscribe succeeds');
|
assert.ok(true, 'getMessages after subscribe succeeds');
|
||||||
|
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('subscribe barrier', function() {
|
QUnit.asyncTest('subscribe barrier', function(assert) {
|
||||||
expect(4);
|
assert.expect(4);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
@@ -310,21 +310,21 @@ asyncTest('subscribe barrier', function() {
|
|||||||
cosmo.subscribe(subject, -1).then(function() {
|
cosmo.subscribe(subject, -1).then(function() {
|
||||||
// We are validating that the message event generated by the subscribe
|
// We are validating that the message event generated by the subscribe
|
||||||
// call has already been processed by the time this promise fires
|
// call has already been processed by the time this promise fires
|
||||||
equal(cosmo.getMessages(subject).length, 1, 'one message');
|
assert.equal(cosmo.getMessages(subject).length, 1, 'one message');
|
||||||
equal(cosmo.getMessages(subject)[0]['subject']['name'], subject,
|
assert.equal(cosmo.getMessages(subject)[0]['subject']['name'], subject,
|
||||||
'subject matches');
|
'subject matches');
|
||||||
equal(cosmo.getMessages(subject)[0]['message'], message,
|
assert.equal(cosmo.getMessages(subject)[0]['message'], message,
|
||||||
'message matches');
|
'message matches');
|
||||||
deepEqual(cosmo.getMessages(subject)[0], cosmo.getLastMessage(subject),
|
assert.deepEqual(cosmo.getMessages(subject)[0],
|
||||||
'getLastMessage works');
|
cosmo.getLastMessage(subject), 'getLastMessage works');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('resubscribe', function() {
|
QUnit.asyncTest('resubscribe', function(assert) {
|
||||||
expect(4);
|
assert.expect(4);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
@@ -333,21 +333,21 @@ asyncTest('resubscribe', function() {
|
|||||||
|
|
||||||
cosmo.sendMessage(subject, message).then(function() {
|
cosmo.sendMessage(subject, message).then(function() {
|
||||||
cosmo.subscribe(subject).then(function() {
|
cosmo.subscribe(subject).then(function() {
|
||||||
equal(cosmo.getMessages(subject).length, 0, 'zero messages');
|
assert.equal(cosmo.getMessages(subject).length, 0, 'zero messages');
|
||||||
cosmo.subscribe(subject, -1).then(function() {
|
cosmo.subscribe(subject, -1).then(function() {
|
||||||
var messages = cosmo.getMessages(subject);
|
var messages = cosmo.getMessages(subject);
|
||||||
equal(messages.length, 1, 'one message');
|
assert.equal(messages.length, 1, 'one message');
|
||||||
equal(messages[0]['subject']['name'], subject, 'subject matches');
|
assert.equal(messages[0]['subject']['name'], subject, 'subject matches');
|
||||||
equal(messages[0]['message'], message, 'message matches');
|
assert.equal(messages[0]['message'], message, 'message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Message ordering', function() {
|
QUnit.asyncTest('Message ordering', function(assert) {
|
||||||
expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var messages = ['A', 'B', 'C', 'D'];
|
var messages = ['A', 'B', 'C', 'D'];
|
||||||
@@ -361,11 +361,11 @@ asyncTest('Message ordering', function() {
|
|||||||
cosmo.subscribe(subject, 1).then(function() {
|
cosmo.subscribe(subject, 1).then(function() {
|
||||||
cosmo.subscribe(subject, 2).then(function() {
|
cosmo.subscribe(subject, 2).then(function() {
|
||||||
var fetched = cosmo.getMessages(subject);
|
var fetched = cosmo.getMessages(subject);
|
||||||
equal(fetched.length, 2, 'two messages');
|
assert.equal(fetched.length, 2, 'two messages');
|
||||||
equal(fetched[0]['message'], 'C', 'message 0: C matches');
|
assert.equal(fetched[0]['message'], 'C', 'message 0: C matches');
|
||||||
equal(fetched[1]['message'], 'D', 'message 1: D matches');
|
assert.equal(fetched[1]['message'], 'D', 'message 1: D matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -374,24 +374,24 @@ asyncTest('Message ordering', function() {
|
|||||||
sendNextMessage();
|
sendNextMessage();
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Reconnect channel', function() {
|
QUnit.asyncTest('Reconnect channel', function(assert) {
|
||||||
expect(5);
|
assert.expect(5);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onConnect': function() {
|
'onConnect': function() {
|
||||||
ok(true, 'onConnect fired');
|
assert.ok(true, 'onConnect fired');
|
||||||
},
|
},
|
||||||
'onDisconnect': function() {
|
'onDisconnect': function() {
|
||||||
ok(true, 'onDisconnect fired');
|
assert.ok(true, 'onDisconnect fired');
|
||||||
},
|
},
|
||||||
'onMessage': function(msg) {
|
'onMessage': function(msg) {
|
||||||
equal(msg['subject']['name'], subject, 'subject matches');
|
assert.equal(msg['subject']['name'], subject, 'subject matches');
|
||||||
equal(msg['message'], message, 'message matches');
|
assert.equal(msg['message'], message, 'message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -403,8 +403,8 @@ asyncTest('Reconnect channel', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('subscribe ACL', function() {
|
QUnit.asyncTest('subscribe ACL', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
|
|
||||||
@@ -419,15 +419,15 @@ asyncTest('subscribe ACL', function() {
|
|||||||
'name': subject,
|
'name': subject,
|
||||||
'readable_only_by': profile
|
'readable_only_by': profile
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
ok(true, 'correct ACL succeeds');
|
assert.ok(true, 'correct ACL succeeds');
|
||||||
|
|
||||||
cosmo.subscribe({
|
cosmo.subscribe({
|
||||||
'name': subject,
|
'name': subject,
|
||||||
'readable_only_by': tempProfile
|
'readable_only_by': tempProfile
|
||||||
}).then(null, function() {
|
}).then(null, function() {
|
||||||
ok(true, 'bad ACL fails');
|
assert.ok(true, 'bad ACL fails');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -436,8 +436,8 @@ asyncTest('subscribe ACL', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('sendMessage ACL', function() {
|
QUnit.asyncTest('sendMessage ACL', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
@@ -453,15 +453,15 @@ asyncTest('sendMessage ACL', function() {
|
|||||||
'name': subject,
|
'name': subject,
|
||||||
'writable_only_by': profile
|
'writable_only_by': profile
|
||||||
}, message).then(function() {
|
}, message).then(function() {
|
||||||
ok(true, 'correct ACL succeeds');
|
assert.ok(true, 'correct ACL succeeds');
|
||||||
|
|
||||||
cosmo.sendMessage({
|
cosmo.sendMessage({
|
||||||
'name': subject,
|
'name': subject,
|
||||||
'writable_only_by': tempProfile
|
'writable_only_by': tempProfile
|
||||||
}, message).then(null, function() {
|
}, message).then(null, function() {
|
||||||
ok(true, 'bad ACL fails');
|
assert.ok(true, 'bad ACL fails');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -470,8 +470,8 @@ asyncTest('sendMessage ACL', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('"me" ACL', function() {
|
QUnit.asyncTest('"me" ACL', function(assert) {
|
||||||
expect(7);
|
assert.expect(7);
|
||||||
|
|
||||||
var subject = {
|
var subject = {
|
||||||
'name': randstring(),
|
'name': randstring(),
|
||||||
@@ -482,44 +482,44 @@ asyncTest('"me" ACL', function() {
|
|||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(e) {
|
'onMessage': function(e) {
|
||||||
equal(e['subject']['name'], subject['name'], 'subject matches');
|
assert.equal(e['subject']['name'], subject['name'], 'subject matches');
|
||||||
equal(e['subject']['readable_only_by'], 'me', 'readable_only_by matches');
|
assert.equal(e['subject']['readable_only_by'], 'me', 'readable_only_by matches');
|
||||||
equal(e['subject']['writable_only_by'], 'me', 'writable_only_by matches');
|
assert.equal(e['subject']['writable_only_by'], 'me', 'writable_only_by matches');
|
||||||
equal(e['message'], message, 'message matches');
|
assert.equal(e['message'], message, 'message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var cosmo = new Cosmopolite(callbacks, null, randstring());
|
var cosmo = new Cosmopolite(callbacks, null, randstring());
|
||||||
cosmo.sendMessage(subject, message).then(function(msg) {
|
cosmo.sendMessage(subject, message).then(function(msg) {
|
||||||
equal(msg['subject']['name'], subject['name'], 'subject matches');
|
assert.equal(msg['subject']['name'], subject['name'], 'subject matches');
|
||||||
equal(msg['subject']['readable_only_by'], 'me', 'readable_only_by matches');
|
assert.equal(msg['subject']['readable_only_by'], 'me', 'readable_only_by matches');
|
||||||
equal(msg['subject']['writable_only_by'], 'me', 'writable_only_by matches');
|
assert.equal(msg['subject']['writable_only_by'], 'me', 'writable_only_by matches');
|
||||||
});
|
});
|
||||||
cosmo.subscribe(subject, -1);
|
cosmo.subscribe(subject, -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('pin/unpin', function() {
|
QUnit.asyncTest('pin/unpin', function(assert) {
|
||||||
expect(5);
|
assert.expect(5);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onPin': function(e) {
|
'onPin': function(e) {
|
||||||
equal(subject, e['subject']['name'], 'onPin: subject matches');
|
assert.equal(subject, e['subject']['name'], 'onPin: subject matches');
|
||||||
equal(message, e['message'], 'onPin: message matches');
|
assert.equal(message, e['message'], 'onPin: message matches');
|
||||||
equal(cosmo.getPins(subject).length, 1);
|
assert.equal(cosmo.getPins(subject).length, 1);
|
||||||
pin.then(function(id) {
|
pin.then(function(id) {
|
||||||
cosmo.unpin(id);
|
cosmo.unpin(id);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'onUnpin': function(e) {
|
'onUnpin': function(e) {
|
||||||
equal(subject, e['subject']['name'], 'onUnpin: subject matches');
|
assert.equal(subject, e['subject']['name'], 'onUnpin: subject matches');
|
||||||
equal(message, e['message'], 'onUnpin: message matches');
|
assert.equal(message, e['message'], 'onUnpin: message matches');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -528,8 +528,8 @@ asyncTest('pin/unpin', function() {
|
|||||||
var pin = cosmo.pin(subject, message);
|
var pin = cosmo.pin(subject, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Repin', function() {
|
QUnit.asyncTest('Repin', function(assert) {
|
||||||
expect(8);
|
assert.expect(8);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
@@ -538,19 +538,19 @@ asyncTest('Repin', function() {
|
|||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onPin': function(e) {
|
'onPin': function(e) {
|
||||||
equal(subject, e['subject']['name'], 'onPin: subject matches');
|
assert.equal(subject, e['subject']['name'], 'onPin: subject matches');
|
||||||
equal(message, e['message'], 'onPin: message matches');
|
assert.equal(message, e['message'], 'onPin: message matches');
|
||||||
equal(cosmo.getPins(subject).length, 1);
|
assert.equal(cosmo.getPins(subject).length, 1);
|
||||||
if (++pins == 1) {
|
if (++pins == 1) {
|
||||||
cosmo.socket_.close();
|
cosmo.socket_.close();
|
||||||
} else {
|
} else {
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'onUnpin': function(e) {
|
'onUnpin': function(e) {
|
||||||
equal(subject, e['subject']['name'], 'onUnpin: subject matches');
|
assert.equal(subject, e['subject']['name'], 'onUnpin: subject matches');
|
||||||
equal(message, e['message'], 'onUnpin: message matches');
|
assert.equal(message, e['message'], 'onUnpin: message matches');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -559,8 +559,8 @@ asyncTest('Repin', function() {
|
|||||||
var pin = cosmo.pin(subject, message);
|
var pin = cosmo.pin(subject, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Duplicate subject', function() {
|
QUnit.asyncTest('Duplicate subject', function(assert) {
|
||||||
expect(4);
|
assert.expect(4);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message1 = randstring();
|
var message1 = randstring();
|
||||||
@@ -575,15 +575,15 @@ asyncTest('Duplicate subject', function() {
|
|||||||
cosmo.subscribe(subject, -1);
|
cosmo.subscribe(subject, -1);
|
||||||
},
|
},
|
||||||
'onMessage': function(e) {
|
'onMessage': function(e) {
|
||||||
equal(subject, e['subject']['name'], 'subject matches');
|
assert.equal(subject, e['subject']['name'], 'subject matches');
|
||||||
if (e['message'] == message1) {
|
if (e['message'] == message1) {
|
||||||
equal(message1, e['message'], 'message1 matches');
|
assert.equal(message1, e['message'], 'message1 matches');
|
||||||
} else {
|
} else {
|
||||||
equal(message2, e['message'], 'message2 matches');
|
assert.equal(message2, e['message'], 'message2 matches');
|
||||||
}
|
}
|
||||||
if (++messages == 2) {
|
if (++messages == 2) {
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -594,15 +594,15 @@ asyncTest('Duplicate subject', function() {
|
|||||||
|
|
||||||
module('dev_appserver only');
|
module('dev_appserver only');
|
||||||
|
|
||||||
asyncTest('Login', function() {
|
QUnit.asyncTest('Login', function(assert) {
|
||||||
expect(3);
|
assert.expect(3);
|
||||||
|
|
||||||
var anonymousProfile;
|
var anonymousProfile;
|
||||||
|
|
||||||
logout(function() {
|
logout(function() {
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onLogout': function(login_url) {
|
'onLogout': function(login_url) {
|
||||||
ok(true, 'onLogout fired');
|
assert.ok(true, 'onLogout fired');
|
||||||
anonymousProfile = cosmo.currentProfile();
|
anonymousProfile = cosmo.currentProfile();
|
||||||
// Entirely magic URL that sets the login cookie and redirects.
|
// Entirely magic URL that sets the login cookie and redirects.
|
||||||
window.open(
|
window.open(
|
||||||
@@ -610,19 +610,19 @@ asyncTest('Login', function() {
|
|||||||
'&continue=/cosmopolite/static/login_complete.html');
|
'&continue=/cosmopolite/static/login_complete.html');
|
||||||
},
|
},
|
||||||
'onLogin': function(login_url) {
|
'onLogin': function(login_url) {
|
||||||
ok(true, 'onLogin fired');
|
assert.ok(true, 'onLogin fired');
|
||||||
notEqual(anonymousProfile, cosmo.currentProfile(), 'profile changed');
|
assert.notEqual(anonymousProfile, cosmo.currentProfile(), 'profile changed');
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
logout();
|
logout();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var cosmo = new Cosmopolite(callbacks, null, randstring());
|
var cosmo = new Cosmopolite(callbacks, null, randstring());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Profile merge', function() {
|
QUnit.asyncTest('Profile merge', function(assert) {
|
||||||
expect(6);
|
assert.expect(6);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
@@ -633,11 +633,11 @@ asyncTest('Profile merge', function() {
|
|||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(msg) {
|
'onMessage': function(msg) {
|
||||||
messages++;
|
messages++;
|
||||||
equal(msg['subject']['name'], subject,
|
assert.equal(msg['subject']['name'], subject,
|
||||||
'message #' + messages + ': subject matches');
|
'message #' + messages + ': subject matches');
|
||||||
equal(msg['message'], message,
|
assert.equal(msg['message'], message,
|
||||||
'message #' + messages + ': message matches');
|
'message #' + messages + ': message matches');
|
||||||
equal(msg['sender'], cosmo.currentProfile(),
|
assert.equal(msg['sender'], cosmo.currentProfile(),
|
||||||
'message #' + messages + ': profile matches');
|
'message #' + messages + ': profile matches');
|
||||||
if (messages == 1) {
|
if (messages == 1) {
|
||||||
cosmo.unsubscribe(subject);
|
cosmo.unsubscribe(subject);
|
||||||
@@ -648,7 +648,7 @@ asyncTest('Profile merge', function() {
|
|||||||
}
|
}
|
||||||
if (messages == 2) {
|
if (messages == 2) {
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'onLogin': function(logout_url) {
|
'onLogin': function(logout_url) {
|
||||||
@@ -661,8 +661,8 @@ asyncTest('Profile merge', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('Two channels, one client', function() {
|
QUnit.asyncTest('Two channels, one client', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var namespace = randstring();
|
var namespace = randstring();
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
@@ -670,10 +670,10 @@ asyncTest('Two channels, one client', function() {
|
|||||||
|
|
||||||
var callbacks = {
|
var callbacks = {
|
||||||
'onMessage': function(msg) {
|
'onMessage': function(msg) {
|
||||||
equal(msg['subject']['name'], subject, 'subject matches');
|
assert.equal(msg['subject']['name'], subject, 'subject matches');
|
||||||
equal(msg['message'], message, 'message matches');
|
assert.equal(msg['message'], message, 'message matches');
|
||||||
cosmo1.shutdown();
|
cosmo1.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -686,8 +686,8 @@ asyncTest('Two channels, one client', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('subscribe admin ACL', function() {
|
QUnit.asyncTest('subscribe admin ACL', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
|
|
||||||
@@ -698,10 +698,10 @@ asyncTest('subscribe admin ACL', function() {
|
|||||||
'name': subject,
|
'name': subject,
|
||||||
'readable_only_by': 'admin'
|
'readable_only_by': 'admin'
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
ok(true, 'logged in succeeds');
|
assert.ok(true, 'logged in succeeds');
|
||||||
|
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -710,7 +710,7 @@ asyncTest('subscribe admin ACL', function() {
|
|||||||
'name': subject,
|
'name': subject,
|
||||||
'readable_only_by': 'admin'
|
'readable_only_by': 'admin'
|
||||||
}).then(null, function() {
|
}).then(null, function() {
|
||||||
ok(true, 'logged out fails');
|
assert.ok(true, 'logged out fails');
|
||||||
|
|
||||||
window.open(
|
window.open(
|
||||||
'/_ah/login?email=test%40example.com&admin=True&action=Login' +
|
'/_ah/login?email=test%40example.com&admin=True&action=Login' +
|
||||||
@@ -719,8 +719,8 @@ asyncTest('subscribe admin ACL', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest('sendMessage admin ACL', function() {
|
QUnit.asyncTest('sendMessage admin ACL', function(assert) {
|
||||||
expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var subject = randstring();
|
var subject = randstring();
|
||||||
var message = randstring();
|
var message = randstring();
|
||||||
@@ -732,10 +732,10 @@ asyncTest('sendMessage admin ACL', function() {
|
|||||||
'name': subject,
|
'name': subject,
|
||||||
'writable_only_by': 'admin'
|
'writable_only_by': 'admin'
|
||||||
}, message).then(function() {
|
}, message).then(function() {
|
||||||
ok(true, 'logged in succeeds');
|
assert.ok(true, 'logged in succeeds');
|
||||||
|
|
||||||
cosmo.shutdown();
|
cosmo.shutdown();
|
||||||
start();
|
QUnit.start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -744,7 +744,7 @@ asyncTest('sendMessage admin ACL', function() {
|
|||||||
'name': subject,
|
'name': subject,
|
||||||
'writable_only_by': 'admin'
|
'writable_only_by': 'admin'
|
||||||
}, message).then(null, function() {
|
}, message).then(null, function() {
|
||||||
ok(true, 'logged out fails');
|
assert.ok(true, 'logged out fails');
|
||||||
|
|
||||||
window.open(
|
window.open(
|
||||||
'/_ah/login?email=test%40example.com&admin=True&action=Login' +
|
'/_ah/login?email=test%40example.com&admin=True&action=Login' +
|
||||||
|
|||||||
Reference in New Issue
Block a user