mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-04 21:15:55 +01:00
jslinting on holiday ftw
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
/*global require, process, after*/
|
||||
|
||||
var winston = require('winston');
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
/*global require*/
|
||||
|
||||
var assert = require('assert'),
|
||||
db = require('./mocks/databasemock'),
|
||||
async = require('async');
|
||||
db = require('./mocks/databasemock');
|
||||
|
||||
|
||||
describe('Test database', function() {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
'use strict';
|
||||
/*global require, before, after*/
|
||||
|
||||
var assert = require('assert'),
|
||||
async = require('async'),
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
'use strict';
|
||||
/*global require, before, after*/
|
||||
|
||||
var assert = require('assert'),
|
||||
db = require('./mocks/databasemock'),
|
||||
async = require('async'),
|
||||
@@ -6,7 +9,7 @@ var assert = require('assert'),
|
||||
Messaging = require('../src/messaging'),
|
||||
testUids;
|
||||
|
||||
describe("Messaging Library", function() {
|
||||
describe('Messaging Library', function() {
|
||||
before(function(done) {
|
||||
// Create 3 users: 1 admin, 2 regular
|
||||
async.parallel([
|
||||
@@ -22,7 +25,7 @@ describe("Messaging Library", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe(".canMessage()", function() {
|
||||
describe('.canMessage()', function() {
|
||||
it('should not error out', function(done) {
|
||||
Messaging.canMessage(testUids[1], testUids[2], function(err, allowed) {
|
||||
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) {
|
||||
assert.strictEqual(allowed, true, 'should be true, received ' + allowed);
|
||||
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() {
|
||||
Messaging.canMessage(testUids[2], testUids[1], function(err, 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) {
|
||||
assert.strictEqual(allowed, true, 'should be true, received ' + allowed);
|
||||
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() {
|
||||
Messaging.canMessage(testUids[2], testUids[1], function(err, allowed) {
|
||||
assert.strictEqual(allowed, true, 'should be true, received ' + allowed);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use strict';
|
||||
/*global require, before, beforeEach, after*/
|
||||
|
||||
var assert = require('assert'),
|
||||
db = require('./mocks/databasemock'),
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
'use strict';
|
||||
/*global require, process, before, beforeEach, after*/
|
||||
|
||||
var winston = require('winston');
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
|
||||
@@ -1,35 +1,38 @@
|
||||
'use strict';
|
||||
/*global require*/
|
||||
|
||||
var assert = require('assert'),
|
||||
utils = require('./../public/src/utils.js');
|
||||
|
||||
|
||||
describe("Utility Methods", function(){
|
||||
describe("username validation", function(){
|
||||
it("accepts latin-1 characters", function(){
|
||||
describe('Utility Methods', function(){
|
||||
describe('username validation', function(){
|
||||
it('accepts latin-1 characters', function(){
|
||||
var username = "John\"'-. Doeäâèéë1234";
|
||||
assert(utils.isUserNameValid(username), 'invalid username');
|
||||
});
|
||||
it("rejects empty string", function(){
|
||||
var username = "";
|
||||
it('rejects empty string', function(){
|
||||
var username = '';
|
||||
assert.ifError(utils.isUserNameValid(username), 'accepted as valid username');
|
||||
});
|
||||
});
|
||||
|
||||
describe("email validation", function(){
|
||||
it("accepts sample address", function(){
|
||||
describe('email validation', function(){
|
||||
it('accepts sample address', function(){
|
||||
var email = 'sample@example.com';
|
||||
assert(utils.isEmailValid(email), 'invalid email');
|
||||
});
|
||||
it("rejects empty address", function(){
|
||||
it('rejects empty address', function(){
|
||||
var email = '';
|
||||
assert.ifError(utils.isEmailValid(email), 'accepted as valid email');
|
||||
});
|
||||
});
|
||||
|
||||
describe("UUID generation", function(){
|
||||
it("return unique random value every time", function(){
|
||||
describe('UUID generation', function(){
|
||||
it('return unique random value every time', function(){
|
||||
var uuid1 = utils.generateUUID(),
|
||||
uuid2 = utils.generateUUID();
|
||||
assert.notEqual(uuid1, uuid2, "matches");
|
||||
assert.notEqual(uuid1, uuid2, 'matches');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user