Lint cleanup for tests

This commit is contained in:
Ian Gulliver
2014-05-28 21:56:12 -07:00
parent d5941a49f7
commit 76bd05d03d
2 changed files with 24 additions and 16 deletions

View File

@@ -185,7 +185,7 @@ asyncTest('Duplicate message suppression', function() {
var message2 = randstring(); var message2 = randstring();
var callbacks = { var callbacks = {
'onMessage': function (msg) { 'onMessage': function(msg) {
equal(msg['subject']['name'], subject, 'subject matches'); equal(msg['subject']['name'], subject, 'subject matches');
equal(msg['message'], message1, 'message matches'); equal(msg['message'], message1, 'message matches');
cosmo.shutdown(); cosmo.shutdown();
@@ -240,8 +240,8 @@ test('getMessages/subscribe', function() {
var cosmo = new Cosmopolite({}, null, randstring()); var cosmo = new Cosmopolite({}, null, randstring());
throws( 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);
@@ -263,9 +263,12 @@ asyncTest('subscribe barrier', 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'); equal(cosmo.getMessages(subject).length, 1, 'one message');
equal(cosmo.getMessages(subject)[0]['subject']['name'], subject, 'subject matches'); equal(cosmo.getMessages(subject)[0]['subject']['name'], subject,
equal(cosmo.getMessages(subject)[0]['message'], message, 'message matches'); 'subject matches');
deepEqual(cosmo.getMessages(subject)[0], cosmo.getLastMessage(subject), 'getLastMessage works'); equal(cosmo.getMessages(subject)[0]['message'], message,
'message matches');
deepEqual(cosmo.getMessages(subject)[0], cosmo.getLastMessage(subject),
'getLastMessage works');
cosmo.shutdown(); cosmo.shutdown();
start(); start();
}); });
@@ -299,7 +302,7 @@ asyncTest('Message ordering', function() {
expect(3); expect(3);
var subject = randstring(); var subject = randstring();
var messages = [ 'A', 'B', 'C', 'D' ]; var messages = ['A', 'B', 'C', 'D'];
var cosmo = new Cosmopolite({}, null, randstring()); var cosmo = new Cosmopolite({}, null, randstring());
@@ -365,13 +368,13 @@ asyncTest('subscribe ACL', function() {
var cosmo = new Cosmopolite({}, null, randstring()); var cosmo = new Cosmopolite({}, null, randstring());
cosmo.getProfile().then(function(profile) { cosmo.getProfile().then(function(profile) {
cosmo.subscribe({ cosmo.subscribe({
'name': subject, 'name': subject,
'readable_only_by': profile, 'readable_only_by': profile,
}).then(function() { }).then(function() {
ok(true, 'correct ACL succeeds'); 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'); ok(true, 'bad ACL fails');
@@ -399,13 +402,13 @@ asyncTest('sendMessage ACL', function() {
var cosmo = new Cosmopolite({}, null, randstring()); var cosmo = new Cosmopolite({}, null, randstring());
cosmo.getProfile().then(function(profile) { cosmo.getProfile().then(function(profile) {
cosmo.sendMessage({ cosmo.sendMessage({
'name': subject, 'name': subject,
'writable_only_by': profile, 'writable_only_by': profile,
}, message).then(function() { }, message).then(function() {
ok(true, 'correct ACL succeeds'); 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'); ok(true, 'bad ACL fails');
@@ -440,7 +443,7 @@ asyncTest('pin/unpin', function() {
cosmo.shutdown(); cosmo.shutdown();
start(); start();
}, },
} };
var cosmo = new Cosmopolite(callbacks, null, randstring()); var cosmo = new Cosmopolite(callbacks, null, randstring());
cosmo.subscribe(subject); cosmo.subscribe(subject);
@@ -471,7 +474,7 @@ asyncTest('Repin', function() {
equal(subject, e['subject']['name'], 'onUnpin: subject matches'); equal(subject, e['subject']['name'], 'onUnpin: subject matches');
equal(message, e['message'], 'onUnpin: message matches'); equal(message, e['message'], 'onUnpin: message matches');
}, },
} };
var cosmo = new Cosmopolite(callbacks, null, randstring()); var cosmo = new Cosmopolite(callbacks, null, randstring());
cosmo.subscribe(subject); cosmo.subscribe(subject);
@@ -505,7 +508,7 @@ asyncTest('Duplicate subject', function() {
start(); start();
} }
}, },
} };
var cosmo = new Cosmopolite(callbacks, null, randstring()); var cosmo = new Cosmopolite(callbacks, null, randstring());
}); });
@@ -524,7 +527,9 @@ asyncTest('Login', function() {
ok(true, 'onLogout fired'); 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('/_ah/login?email=test%40example.com&action=Login&continue=/cosmopolite/static/login_complete.html'); window.open(
'/_ah/login?email=test%40example.com&action=Login' +
'&continue=/cosmopolite/static/login_complete.html');
}, },
'onLogin': function(login_url) { 'onLogin': function(login_url) {
ok(true, 'onLogin fired'); ok(true, 'onLogin fired');
@@ -559,7 +564,9 @@ asyncTest('Profile merge', function() {
if (messages == 1) { if (messages == 1) {
cosmo.unsubscribe(subject); cosmo.unsubscribe(subject);
// Entirely magic URL that sets the login cookie and redirects. // Entirely magic URL that sets the login cookie and redirects.
window.open('/_ah/login?email=test%40example.com&action=Login&continue=/cosmopolite/static/login_complete.html'); window.open(
'/_ah/login?email=test%40example.com&action=Login' +
'&continue=/cosmopolite/static/login_complete.html');
} }
if (messages == 2) { if (messages == 2) {
cosmo.shutdown(); cosmo.shutdown();

View File

@@ -14,3 +14,4 @@ curl \
echo echo
gjslint --strict --disable=0121,0233 cosmopolite.js gjslint --strict --disable=0121,0233 cosmopolite.js
gjslint --strict --disable=0121,0233 --nojsdoc test.js