jslinting on holiday ftw

v1.18.x
psychobunny 10 years ago
parent 112a1e8c85
commit f3a113d318

@ -1,3 +1,5 @@
'use strict';
/*global require, process, after*/
var winston = require('winston'); var winston = require('winston');

@ -1,6 +1,8 @@
'use strict';
/*global require*/
var assert = require('assert'), var assert = require('assert'),
db = require('./mocks/databasemock'), db = require('./mocks/databasemock');
async = require('async');
describe('Test database', function() { describe('Test database', function() {

@ -1,3 +1,6 @@
'use strict';
/*global require, before, after*/
var assert = require('assert'), var assert = require('assert'),
async = require('async'), async = require('async'),

@ -1,3 +1,6 @@
'use strict';
/*global require, before, after*/
var assert = require('assert'), var assert = require('assert'),
db = require('./mocks/databasemock'), db = require('./mocks/databasemock'),
async = require('async'), async = require('async'),
@ -6,7 +9,7 @@ var assert = require('assert'),
Messaging = require('../src/messaging'), Messaging = require('../src/messaging'),
testUids; testUids;
describe("Messaging Library", function() { describe('Messaging Library', function() {
before(function(done) { before(function(done) {
// Create 3 users: 1 admin, 2 regular // Create 3 users: 1 admin, 2 regular
async.parallel([ async.parallel([
@ -22,7 +25,7 @@ describe("Messaging Library", function() {
}); });
}); });
describe(".canMessage()", function() { describe('.canMessage()', function() {
it('should not error out', function(done) { it('should not error out', function(done) {
Messaging.canMessage(testUids[1], testUids[2], function(err, allowed) { Messaging.canMessage(testUids[1], testUids[2], function(err, allowed) {
assert.ifError(err); assert.ifError(err);
@ -30,14 +33,14 @@ describe("Messaging Library", function() {
}); });
}); });
it("should allow messages to be sent to an unrestricted user", function(done) { it('should allow messages to be sent to an unrestricted user', function(done) {
Messaging.canMessage(testUids[1], testUids[2], function(err, allowed) { Messaging.canMessage(testUids[1], testUids[2], function(err, allowed) {
assert.strictEqual(allowed, true, 'should be true, received ' + allowed); assert.strictEqual(allowed, true, 'should be true, received ' + allowed);
done(); done();
}); });
}); });
it("should NOT allow messages to be sent to a restricted user", function(done) { it('should NOT allow messages to be sent to a restricted user', function(done) {
User.setSetting(testUids[1], 'restrictChat', '1', function() { User.setSetting(testUids[1], 'restrictChat', '1', function() {
Messaging.canMessage(testUids[2], testUids[1], function(err, allowed) { Messaging.canMessage(testUids[2], testUids[1], function(err, allowed) {
assert.strictEqual(allowed, false, 'should be false, received ' + allowed); assert.strictEqual(allowed, false, 'should be false, received ' + allowed);
@ -46,14 +49,14 @@ describe("Messaging Library", function() {
}); });
}); });
it("should always allow admins through", function(done) { it('should always allow admins through', function(done) {
Messaging.canMessage(testUids[0], testUids[1], function(err, allowed) { Messaging.canMessage(testUids[0], testUids[1], function(err, allowed) {
assert.strictEqual(allowed, true, 'should be true, received ' + allowed); assert.strictEqual(allowed, true, 'should be true, received ' + allowed);
done(); done();
}); });
}); });
it("should allow messages to be sent to a restricted user if restricted user follows sender", function(done) { it('should allow messages to be sent to a restricted user if restricted user follows sender', function(done) {
User.follow(testUids[1], testUids[2], function() { User.follow(testUids[1], testUids[2], function() {
Messaging.canMessage(testUids[2], testUids[1], function(err, allowed) { Messaging.canMessage(testUids[2], testUids[1], function(err, allowed) {
assert.strictEqual(allowed, true, 'should be true, received ' + allowed); assert.strictEqual(allowed, true, 'should be true, received ' + allowed);

@ -1,4 +1,5 @@
'use strict'; 'use strict';
/*global require, before, beforeEach, after*/
var assert = require('assert'), var assert = require('assert'),
db = require('./mocks/databasemock'), db = require('./mocks/databasemock'),

@ -1,3 +1,6 @@
'use strict';
/*global require, process, before, beforeEach, after*/
var winston = require('winston'); var winston = require('winston');
process.on('uncaughtException', function (err) { process.on('uncaughtException', function (err) {

@ -1,35 +1,38 @@
'use strict';
/*global require*/
var assert = require('assert'), var assert = require('assert'),
utils = require('./../public/src/utils.js'); utils = require('./../public/src/utils.js');
describe("Utility Methods", function(){ describe('Utility Methods', function(){
describe("username validation", function(){ describe('username validation', function(){
it("accepts latin-1 characters", function(){ it('accepts latin-1 characters', function(){
var username = "John\"'-. Doeäâèéë1234"; var username = "John\"'-. Doeäâèéë1234";
assert(utils.isUserNameValid(username), 'invalid username'); assert(utils.isUserNameValid(username), 'invalid username');
}); });
it("rejects empty string", function(){ it('rejects empty string', function(){
var username = ""; var username = '';
assert.ifError(utils.isUserNameValid(username), 'accepted as valid username'); assert.ifError(utils.isUserNameValid(username), 'accepted as valid username');
}); });
}); });
describe("email validation", function(){ describe('email validation', function(){
it("accepts sample address", function(){ it('accepts sample address', function(){
var email = 'sample@example.com'; var email = 'sample@example.com';
assert(utils.isEmailValid(email), 'invalid email'); assert(utils.isEmailValid(email), 'invalid email');
}); });
it("rejects empty address", function(){ it('rejects empty address', function(){
var email = ''; var email = '';
assert.ifError(utils.isEmailValid(email), 'accepted as valid email'); assert.ifError(utils.isEmailValid(email), 'accepted as valid email');
}); });
}); });
describe("UUID generation", function(){ describe('UUID generation', function(){
it("return unique random value every time", function(){ it('return unique random value every time', function(){
var uuid1 = utils.generateUUID(), var uuid1 = utils.generateUUID(),
uuid2 = utils.generateUUID(); uuid2 = utils.generateUUID();
assert.notEqual(uuid1, uuid2, "matches"); assert.notEqual(uuid1, uuid2, 'matches');
}); });
}); });
}); });

Loading…
Cancel
Save