mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-28 17:30:44 +02:00
fix(eslint): Inconsistent spacing before function parentheses (#1844)
Defines `space-before-function-paren` eslint rule and changes files accordingly.
This commit is contained in:
@@ -40,7 +40,11 @@ module.exports = {
|
||||
'one-var': [0, 'never'],
|
||||
'one-var-declaration-per-line': [2, 'always'],
|
||||
'padded-blocks': 0,
|
||||
'space-before-function-paren': 0,
|
||||
'space-before-function-paren': ['error', {
|
||||
'anonymous': 'always',
|
||||
'named': 'never',
|
||||
'asyncArrow': 'always'
|
||||
}],
|
||||
'space-in-parens': [2, 'never'],
|
||||
'spaced-comment': [2, 'always'],
|
||||
strict: 0,
|
||||
|
||||
@@ -29,7 +29,7 @@ var logger = new winston.Logger({
|
||||
// Useful for integrating with stream-related mechanism like Morgan's stream
|
||||
// option to log all HTTP requests to a file
|
||||
logger.stream = {
|
||||
write: function(msg) {
|
||||
write: function (msg) {
|
||||
logger.info(msg);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -336,7 +336,7 @@ gulp.task('karma', function (done) {
|
||||
});
|
||||
|
||||
// Run karma with coverage options set and write report
|
||||
gulp.task('karma:coverage', function(done) {
|
||||
gulp.task('karma:coverage', function (done) {
|
||||
new KarmaServer({
|
||||
configFile: __dirname + '/karma.conf.js',
|
||||
preprocessors: {
|
||||
@@ -427,12 +427,12 @@ gulp.task('protractor', ['webdriver_update'], function () {
|
||||
.pipe(protractor({
|
||||
configFile: 'protractor.conf.js'
|
||||
}))
|
||||
.on('end', function() {
|
||||
.on('end', function () {
|
||||
console.log('E2E Testing complete');
|
||||
// exit with success.
|
||||
process.exit(0);
|
||||
})
|
||||
.on('error', function(err) {
|
||||
.on('error', function (err) {
|
||||
console.error('E2E Tests failed:');
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(function () {
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
@@ -19,7 +19,7 @@
|
||||
// Remove existing Article
|
||||
function remove() {
|
||||
if ($window.confirm('Are you sure you want to delete?')) {
|
||||
vm.article.$remove(function() {
|
||||
vm.article.$remove(function () {
|
||||
$state.go('admin.articles.list');
|
||||
Notification.success({ message: '<i class="glyphicon glyphicon-ok"></i> Article deleted successfully!' });
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
}
|
||||
|
||||
// Angular-ui-notification configuration
|
||||
angular.module('ui-notification').config(function(NotificationProvider) {
|
||||
angular.module('ui-notification').config(function (NotificationProvider) {
|
||||
NotificationProvider.setOptions({
|
||||
delay: 2000,
|
||||
startTop: 20,
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
controller: 'ErrorController',
|
||||
controllerAs: 'vm',
|
||||
params: {
|
||||
message: function($stateParams) {
|
||||
message: function ($stateParams) {
|
||||
return $stateParams.message;
|
||||
}
|
||||
},
|
||||
@@ -53,7 +53,7 @@
|
||||
controller: 'ErrorController',
|
||||
controllerAs: 'vm',
|
||||
params: {
|
||||
message: function($stateParams) {
|
||||
message: function ($stateParams) {
|
||||
return $stateParams.message;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
function link(scope, element, attrs) {
|
||||
if ($window.innerWidth >= 800) {
|
||||
$timeout(function() {
|
||||
$timeout(function () {
|
||||
var el = element[0];
|
||||
el.focus();
|
||||
el.selectionStart = el.selectionEnd = el.value.length;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
separator = ' - ',
|
||||
stateTitle = applicationCoreTitle + separator;
|
||||
|
||||
toState.name.split('.').forEach(function(value, index) {
|
||||
toState.name.split('.').forEach(function (value, index) {
|
||||
stateTitle = stateTitle + value.charAt(0).toUpperCase() + value.slice(1) + separator;
|
||||
});
|
||||
if (toState.data && toState.data.pageTitle) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
.module('core')
|
||||
.factory('menuService', menuService);
|
||||
|
||||
function menuService () {
|
||||
function menuService() {
|
||||
var shouldRender;
|
||||
var service = {
|
||||
addMenu: addMenu,
|
||||
@@ -25,7 +25,7 @@
|
||||
return service;
|
||||
|
||||
// Add new menu object by menu id
|
||||
function addMenu (menuId, options) {
|
||||
function addMenu(menuId, options) {
|
||||
options = options || {};
|
||||
|
||||
// Create the new menu
|
||||
@@ -40,7 +40,7 @@
|
||||
}
|
||||
|
||||
// Add menu item object
|
||||
function addMenuItem (menuId, options) {
|
||||
function addMenuItem(menuId, options) {
|
||||
// Validate that the menu exists
|
||||
service.validateMenuExistence(menuId);
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
}
|
||||
|
||||
// Add submenu item object
|
||||
function addSubMenuItem (menuId, parentItemState, options) {
|
||||
function addSubMenuItem(menuId, parentItemState, options) {
|
||||
options = options || {};
|
||||
|
||||
// Validate that the menu exists
|
||||
@@ -95,7 +95,7 @@
|
||||
}
|
||||
|
||||
// Get the menu object by menu id
|
||||
function getMenu (menuId) {
|
||||
function getMenu(menuId) {
|
||||
// Validate that the menu exists
|
||||
service.validateMenuExistence(menuId);
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
return service.menus[menuId];
|
||||
}
|
||||
|
||||
function init () {
|
||||
function init() {
|
||||
// A private function for rendering decision
|
||||
shouldRender = function (user) {
|
||||
if (this.roles.indexOf('*') !== -1) {
|
||||
@@ -128,7 +128,7 @@
|
||||
}
|
||||
|
||||
// Remove existing menu object by menu id
|
||||
function removeMenu (menuId) {
|
||||
function removeMenu(menuId) {
|
||||
// Validate that the menu exists
|
||||
service.validateMenuExistence(menuId);
|
||||
|
||||
@@ -136,7 +136,7 @@
|
||||
}
|
||||
|
||||
// Remove existing menu object by menu id
|
||||
function removeMenuItem (menuId, menuItemState) {
|
||||
function removeMenuItem(menuId, menuItemState) {
|
||||
// Validate that the menu exists
|
||||
service.validateMenuExistence(menuId);
|
||||
|
||||
@@ -150,7 +150,7 @@
|
||||
}
|
||||
|
||||
// Remove existing menu object by menu id
|
||||
function removeSubMenuItem (menuId, subMenuItemState) {
|
||||
function removeSubMenuItem(menuId, subMenuItemState) {
|
||||
// Validate that the menu exists
|
||||
service.validateMenuExistence(menuId);
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
}
|
||||
|
||||
// Validate menu existence
|
||||
function validateMenuExistence (menuId) {
|
||||
function validateMenuExistence(menuId) {
|
||||
if (!(menuId && menuId.length)) {
|
||||
throw new Error('MenuId was not provided');
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
describe('authInterceptor', function() {
|
||||
(function () {
|
||||
describe('authInterceptor', function () {
|
||||
// Initialize global variables
|
||||
var authInterceptor,
|
||||
$q,
|
||||
@@ -13,11 +13,11 @@
|
||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
|
||||
// Load httpProvider
|
||||
beforeEach(module(function($httpProvider) {
|
||||
beforeEach(module(function ($httpProvider) {
|
||||
httpProvider = $httpProvider;
|
||||
}));
|
||||
|
||||
beforeEach(inject(function(_authInterceptor_, _$q_, _$state_, _Authentication_) {
|
||||
beforeEach(inject(function (_authInterceptor_, _$q_, _$state_, _Authentication_) {
|
||||
authInterceptor = _authInterceptor_;
|
||||
$q = _$q_;
|
||||
$state = _$state_;
|
||||
@@ -26,19 +26,19 @@
|
||||
spyOn($state, 'transitionTo');
|
||||
}));
|
||||
|
||||
it('Auth Interceptor should be object', function() {
|
||||
it('Auth Interceptor should be object', function () {
|
||||
expect(typeof authInterceptor).toEqual('object');
|
||||
});
|
||||
|
||||
it('Auth Interceptor should contain responseError function', function() {
|
||||
it('Auth Interceptor should contain responseError function', function () {
|
||||
expect(typeof authInterceptor.responseError).toEqual('function');
|
||||
});
|
||||
|
||||
it('httpProvider Interceptor should have authInterceptor', function() {
|
||||
it('httpProvider Interceptor should have authInterceptor', function () {
|
||||
expect(httpProvider.interceptors).toContain('authInterceptor');
|
||||
});
|
||||
|
||||
describe('Forbidden Interceptor', function() {
|
||||
describe('Forbidden Interceptor', function () {
|
||||
it('should redirect to forbidden route', function () {
|
||||
var response = {
|
||||
status: 403,
|
||||
@@ -50,7 +50,7 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('Authorization Interceptor', function() {
|
||||
describe('Authorization Interceptor', function () {
|
||||
it('should redirect to signIn page for unauthorized access', function () {
|
||||
var response = {
|
||||
status: 401,
|
||||
@@ -63,9 +63,9 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('Unresponsive Interceptor', function() {
|
||||
describe('Unresponsive Interceptor', function () {
|
||||
var Notification;
|
||||
beforeEach(inject(function(_Notification_) {
|
||||
beforeEach(inject(function (_Notification_) {
|
||||
Notification = _Notification_;
|
||||
spyOn(Notification, 'error');
|
||||
}));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
describe('Menus', function() {
|
||||
(function () {
|
||||
describe('Menus', function () {
|
||||
// Initialize global variables
|
||||
var scope,
|
||||
menuService;
|
||||
@@ -9,78 +9,78 @@
|
||||
// Load the main application module
|
||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
|
||||
beforeEach(inject(function(_menuService_) {
|
||||
beforeEach(inject(function (_menuService_) {
|
||||
menuService = _menuService_;
|
||||
}));
|
||||
|
||||
it('should have topbar added', function() {
|
||||
it('should have topbar added', function () {
|
||||
expect(menuService.menus.topbar).toBeDefined();
|
||||
});
|
||||
|
||||
it('should have default roles to user and admin', function() {
|
||||
it('should have default roles to user and admin', function () {
|
||||
expect(menuService.defaultRoles).toEqual(['user', 'admin']);
|
||||
});
|
||||
|
||||
describe('addMenu', function() {
|
||||
describe('with no options', function() {
|
||||
describe('addMenu', function () {
|
||||
describe('with no options', function () {
|
||||
var menuId = 'menu1',
|
||||
menu;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menu = menuService.addMenu(menuId);
|
||||
});
|
||||
|
||||
it('should return menu object', function() {
|
||||
it('should return menu object', function () {
|
||||
expect(menu).toBeDefined();
|
||||
});
|
||||
|
||||
it('should default roles', function() {
|
||||
it('should default roles', function () {
|
||||
expect(menu.roles).toEqual(menuService.defaultRoles);
|
||||
});
|
||||
|
||||
it('should have empty items', function() {
|
||||
it('should have empty items', function () {
|
||||
expect(menu.items).toEqual([]);
|
||||
});
|
||||
|
||||
it('should set shouldRender to shouldRender function handle', function() {
|
||||
it('should set shouldRender to shouldRender function handle', function () {
|
||||
expect(menu.shouldRender()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('with options', function() {
|
||||
describe('with options', function () {
|
||||
var menu,
|
||||
options = {
|
||||
roles: ['a', 'b', 'c'],
|
||||
items: ['d', 'e', 'f']
|
||||
};
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menu = menuService.addMenu('menu1', options);
|
||||
});
|
||||
|
||||
it('should set items to options.items list', function() {
|
||||
it('should set items to options.items list', function () {
|
||||
expect(menu.items).toBe(options.items);
|
||||
});
|
||||
|
||||
it('should set roles to options.roles list', function() {
|
||||
it('should set roles to options.roles list', function () {
|
||||
expect(menu.roles).toBe(options.roles);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('shouldRender', function() {
|
||||
describe('shouldRender', function () {
|
||||
var menuOptions = {
|
||||
roles: ['*', 'menurole']
|
||||
},
|
||||
menu;
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menu = menuService.addMenu('menu1', menuOptions);
|
||||
});
|
||||
|
||||
describe('when logged out', function() {
|
||||
it('should render if menu is public', function() {
|
||||
describe('when logged out', function () {
|
||||
it('should render if menu is public', function () {
|
||||
expect(menu.shouldRender()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not render if menu is private', function() {
|
||||
it('should not render if menu is private', function () {
|
||||
menu = menuService.addMenu('menu1', {
|
||||
isPublic: false
|
||||
});
|
||||
@@ -88,28 +88,28 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('when logged in', function() {
|
||||
describe('when logged in', function () {
|
||||
var user = {
|
||||
roles: ['1', 'menurole', '2']
|
||||
};
|
||||
describe('menu with * role', function() {
|
||||
it('should render', function() {
|
||||
describe('menu with * role', function () {
|
||||
it('should render', function () {
|
||||
expect(menu.shouldRender(user)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('menu without * role', function() {
|
||||
beforeEach(function() {
|
||||
describe('menu without * role', function () {
|
||||
beforeEach(function () {
|
||||
menu = menuService.addMenu('menu1', {
|
||||
roles: ['b', 'menurole', 'c']
|
||||
});
|
||||
});
|
||||
|
||||
it('should render if user has same role as menu', function() {
|
||||
it('should render if user has same role as menu', function () {
|
||||
expect(menu.shouldRender(user)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not render if user has different roles', function() {
|
||||
it('should not render if user has different roles', function () {
|
||||
user = {
|
||||
roles: ['1', '2', '3']
|
||||
};
|
||||
@@ -119,54 +119,54 @@
|
||||
});
|
||||
});
|
||||
|
||||
describe('validateMenuExistence', function() {
|
||||
describe('when menuId not provided', function() {
|
||||
it('should throw menuId error', function() {
|
||||
describe('validateMenuExistence', function () {
|
||||
describe('when menuId not provided', function () {
|
||||
it('should throw menuId error', function () {
|
||||
expect(menuService.validateMenuExistence).toThrowError('MenuId was not provided');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when menu does not exist', function() {
|
||||
it('should throw no menu error', function() {
|
||||
var target = function() {
|
||||
describe('when menu does not exist', function () {
|
||||
it('should throw no menu error', function () {
|
||||
var target = function () {
|
||||
menuService.validateMenuExistence('noMenuId');
|
||||
};
|
||||
expect(target).toThrowError('Menu does not exist');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when menu exists', function() {
|
||||
describe('when menu exists', function () {
|
||||
var menuId = 'menuId';
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menuService.menus[menuId] = {};
|
||||
});
|
||||
|
||||
it('should return truthy', function() {
|
||||
it('should return truthy', function () {
|
||||
expect(menuService.validateMenuExistence(menuId)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeMenu', function() {
|
||||
describe('removeMenu', function () {
|
||||
var menu = {
|
||||
id: 'menuId'
|
||||
};
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menuService.menus[menu.id] = menu;
|
||||
menuService.validateMenuExistence = jasmine.createSpy();
|
||||
menuService.removeMenu(menu.id);
|
||||
});
|
||||
|
||||
it('should remove existing menu from menus', function() {
|
||||
it('should remove existing menu from menus', function () {
|
||||
expect(menuService.menus).not.toContain(menu.id);
|
||||
});
|
||||
|
||||
it('validates menu existance before removing', function() {
|
||||
it('validates menu existance before removing', function () {
|
||||
expect(menuService.validateMenuExistence).toHaveBeenCalledWith(menu.id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addMenuItem', function() {
|
||||
describe('addMenuItem', function () {
|
||||
var menuId = 'menu1',
|
||||
subMenuItem1 = {
|
||||
title: 'sub1'
|
||||
@@ -187,7 +187,7 @@
|
||||
menu,
|
||||
menuItem;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menuService.validateMenuExistence = jasmine.createSpy();
|
||||
menuService.addSubMenuItem = jasmine.createSpy();
|
||||
menuService.addMenu(menuId, {
|
||||
@@ -197,84 +197,84 @@
|
||||
menuItem = menu.items[0];
|
||||
});
|
||||
|
||||
it('should validate menu existance', function() {
|
||||
it('should validate menu existance', function () {
|
||||
expect(menuService.validateMenuExistence).toHaveBeenCalledWith(menuId);
|
||||
});
|
||||
|
||||
it('should return the menu', function() {
|
||||
it('should return the menu', function () {
|
||||
expect(menu).toBeDefined();
|
||||
});
|
||||
|
||||
it('should set menu item shouldRender function', function() {
|
||||
it('should set menu item shouldRender function', function () {
|
||||
expect(menuItem.shouldRender).toBeDefined();
|
||||
});
|
||||
|
||||
describe('with options set', function() {
|
||||
it('should add menu item to menu', function() {
|
||||
describe('with options set', function () {
|
||||
it('should add menu item to menu', function () {
|
||||
expect(menu.items.length).toBe(1);
|
||||
});
|
||||
|
||||
it('should set menu item title to options title', function() {
|
||||
it('should set menu item title to options title', function () {
|
||||
expect(menuItem.title).toBe(menuItemOptions.title);
|
||||
});
|
||||
|
||||
it('should set menu item state to options state', function() {
|
||||
it('should set menu item state to options state', function () {
|
||||
expect(menuItem.state).toBe(menuItemOptions.state);
|
||||
});
|
||||
|
||||
it('should set menu item type to options type', function() {
|
||||
it('should set menu item type to options type', function () {
|
||||
expect(menuItem.type).toBe(menuItemOptions.type);
|
||||
});
|
||||
|
||||
it('should set menu item class to options class', function() {
|
||||
it('should set menu item class to options class', function () {
|
||||
expect(menuItem.class).toBe(menuItemOptions.class);
|
||||
});
|
||||
|
||||
it('should set menu item position to options position', function() {
|
||||
it('should set menu item position to options position', function () {
|
||||
expect(menuItem.position).toBe(menuItemOptions.position);
|
||||
});
|
||||
|
||||
it('should call addSubMenuItem for each item in options', function() {
|
||||
it('should call addSubMenuItem for each item in options', function () {
|
||||
expect(menuService.addSubMenuItem).toHaveBeenCalledWith(menuId, menuItemOptions.state, subMenuItem1);
|
||||
expect(menuService.addSubMenuItem).toHaveBeenCalledWith(menuId, menuItemOptions.state, subMenuItem2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('without options set', function() {
|
||||
beforeEach(function() {
|
||||
describe('without options set', function () {
|
||||
beforeEach(function () {
|
||||
menu = menuService.addMenuItem(menuId);
|
||||
menuItem = menu.items[1];
|
||||
});
|
||||
|
||||
it('should set menu item type to item', function() {
|
||||
it('should set menu item type to item', function () {
|
||||
expect(menuItem.type).toBe('item');
|
||||
});
|
||||
|
||||
it('should set menu item title to empty', function() {
|
||||
it('should set menu item title to empty', function () {
|
||||
expect(menuItem.title).toBe('');
|
||||
});
|
||||
|
||||
it('should set menu item isPublic to false', function() {
|
||||
it('should set menu item isPublic to false', function () {
|
||||
expect(menuItem.isPublic).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should set menu item roles to default roles', function() {
|
||||
it('should set menu item roles to default roles', function () {
|
||||
expect(menuItem.roles).toEqual(menuService.defaultRoles);
|
||||
});
|
||||
|
||||
it('should set menu item position to 0', function() {
|
||||
it('should set menu item position to 0', function () {
|
||||
expect(menuItem.position).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('removeMenuItem', function() {
|
||||
describe('removeMenuItem', function () {
|
||||
var menuId = 'menuId',
|
||||
menuItemState = 'menu.state1',
|
||||
menuItemState2 = 'menu.state2',
|
||||
menu;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menuService.addMenu(menuId);
|
||||
menuService.addMenuItem(menuId, { state: menuItemState });
|
||||
menuService.addMenuItem(menuId, { state: menuItemState2 });
|
||||
@@ -282,21 +282,21 @@
|
||||
menu = menuService.removeMenuItem(menuId, menuItemState);
|
||||
});
|
||||
|
||||
it('should return menu object', function() {
|
||||
it('should return menu object', function () {
|
||||
expect(menu).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should validate menu existance', function() {
|
||||
it('should validate menu existance', function () {
|
||||
expect(menuService.validateMenuExistence).toHaveBeenCalledWith(menuId);
|
||||
});
|
||||
|
||||
it('should remove sub menu items with same state', function() {
|
||||
it('should remove sub menu items with same state', function () {
|
||||
expect(menu.items.length).toBe(1);
|
||||
expect(menu.items[0].state).toBe(menuItemState2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addSubMenuItem', function() {
|
||||
describe('addSubMenuItem', function () {
|
||||
var subItemOptions = {
|
||||
title: 'title',
|
||||
state: 'sub.state',
|
||||
@@ -324,7 +324,7 @@
|
||||
subItem2,
|
||||
menu;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
menuService.validateMenuExistence = jasmine.createSpy();
|
||||
menuService.addMenu(menuId);
|
||||
menuService.addMenuItem(menuId, menuItem1Options);
|
||||
@@ -339,93 +339,93 @@
|
||||
subItem2 = menuItem1.items[1];
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
menuService.removeMenu(menuId);
|
||||
});
|
||||
|
||||
it('should return menu object', function() {
|
||||
it('should return menu object', function () {
|
||||
expect(menu).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should validate menu existance', function() {
|
||||
it('should validate menu existance', function () {
|
||||
expect(menuService.validateMenuExistence).toHaveBeenCalledWith(menuId);
|
||||
});
|
||||
|
||||
it('should not add sub menu item to menu item of different state', function() {
|
||||
it('should not add sub menu item to menu item of different state', function () {
|
||||
expect(menuItem3.items.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should set shouldRender', function() {
|
||||
it('should set shouldRender', function () {
|
||||
expect(subItem1.shouldRender).toBeDefined();
|
||||
});
|
||||
|
||||
describe('with options set', function() {
|
||||
it('should add sub menu item to menu item', function() {
|
||||
describe('with options set', function () {
|
||||
it('should add sub menu item to menu item', function () {
|
||||
expect(subItem1).toBeDefined();
|
||||
});
|
||||
|
||||
it('should set title to options title', function() {
|
||||
it('should set title to options title', function () {
|
||||
expect(subItem1.title).toBe(subItemOptions.title);
|
||||
});
|
||||
|
||||
it('should set state to options state', function() {
|
||||
it('should set state to options state', function () {
|
||||
expect(subItem1.state).toBe(subItemOptions.state);
|
||||
});
|
||||
|
||||
it('should set roles to options roles', function() {
|
||||
it('should set roles to options roles', function () {
|
||||
expect(subItem1.roles).toEqual(subItemOptions.roles);
|
||||
});
|
||||
|
||||
it('should set position to options position', function() {
|
||||
it('should set position to options position', function () {
|
||||
expect(subItem1.position).toEqual(subItemOptions.position);
|
||||
});
|
||||
|
||||
it('should set params to options params', function() {
|
||||
it('should set params to options params', function () {
|
||||
expect(subItem1.params).toEqual(subItemOptions.params);
|
||||
});
|
||||
});
|
||||
|
||||
describe('without optoins set', function() {
|
||||
it('should add sub menu item to menu item', function() {
|
||||
describe('without optoins set', function () {
|
||||
it('should add sub menu item to menu item', function () {
|
||||
expect(subItem2).toBeDefined();
|
||||
});
|
||||
|
||||
it('should set isPublic to parent isPublic', function() {
|
||||
it('should set isPublic to parent isPublic', function () {
|
||||
expect(subItem2.isPublic).toBe(menuItem1.isPublic);
|
||||
});
|
||||
|
||||
it('should set title to blank', function() {
|
||||
it('should set title to blank', function () {
|
||||
expect(subItem2.title).toBe('');
|
||||
});
|
||||
|
||||
it('should set state to blank', function() {
|
||||
it('should set state to blank', function () {
|
||||
expect(subItem2.state).toBe('');
|
||||
});
|
||||
|
||||
it('should set roles to parent roles', function() {
|
||||
it('should set roles to parent roles', function () {
|
||||
expect(subItem2.roles).toEqual(menuItem1.roles);
|
||||
});
|
||||
|
||||
it('should set position to 0', function() {
|
||||
it('should set position to 0', function () {
|
||||
expect(subItem2.position).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('then removeSubMenuItem', function() {
|
||||
beforeEach(function() {
|
||||
describe('then removeSubMenuItem', function () {
|
||||
beforeEach(function () {
|
||||
menuService.validateMenuExistence = jasmine.createSpy();
|
||||
menu = menuService.removeSubMenuItem(menuId, subItem1.state);
|
||||
});
|
||||
|
||||
it('should validate menu existance', function() {
|
||||
it('should validate menu existance', function () {
|
||||
expect(menuService.validateMenuExistence).toHaveBeenCalledWith(menuId);
|
||||
});
|
||||
|
||||
it('should return menu object', function() {
|
||||
it('should return menu object', function () {
|
||||
expect(menu).toBeDefined();
|
||||
});
|
||||
|
||||
it('should remove sub menu item', function() {
|
||||
it('should remove sub menu item', function () {
|
||||
expect(menuItem1.items.length).toBe(1);
|
||||
expect(menuItem1.items[0].state).toEqual(subItem2.state);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(function() {
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
/* Creates a mock of socket.io for the browser.
|
||||
|
||||
@@ -823,7 +823,7 @@ describe('Configuration Tests:', function () {
|
||||
|
||||
describe('Testing exposing environment as a variable to layout', function () {
|
||||
|
||||
['development', 'production', 'test'].forEach(function(env) {
|
||||
['development', 'production', 'test'].forEach(function (env) {
|
||||
it('should expose environment set to ' + env, function (done) {
|
||||
// Set env to development for this test
|
||||
process.env.NODE_ENV = env;
|
||||
|
||||
@@ -81,7 +81,7 @@ exports.changeProfilePicture = function (req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
function uploadImage () {
|
||||
function uploadImage() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
upload(req, res, function (uploadError) {
|
||||
if (uploadError) {
|
||||
@@ -93,7 +93,7 @@ exports.changeProfilePicture = function (req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
function updateUser () {
|
||||
function updateUser() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
user.profileImageURL = config.uploads.profile.image.dest + req.file.filename;
|
||||
user.save(function (err, theuser) {
|
||||
@@ -106,7 +106,7 @@ exports.changeProfilePicture = function (req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
function deleteOldImage () {
|
||||
function deleteOldImage() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
if (existingImageUrl !== User.schema.path('profileImageURL').defaultValue) {
|
||||
fs.unlink(existingImageUrl, function (unlinkError) {
|
||||
@@ -133,7 +133,7 @@ exports.changeProfilePicture = function (req, res) {
|
||||
});
|
||||
}
|
||||
|
||||
function login () {
|
||||
function login() {
|
||||
return new Promise(function (resolve, reject) {
|
||||
req.login(user, function (err) {
|
||||
if (err) {
|
||||
|
||||
@@ -40,7 +40,7 @@ var validateLocalStrategyEmail = function (email) {
|
||||
* - not begin or end with "."
|
||||
*/
|
||||
|
||||
var validateUsername = function(username) {
|
||||
var validateUsername = function (username) {
|
||||
var usernameRegex = /^(?=[\w.-]+$)(?!.*[._-]{2})(?!\.)(?!.*\.$).{3,34}$/;
|
||||
return (
|
||||
this.provider !== 'local' ||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
// Password Validator Directive Spec
|
||||
describe('PasswordValidatorDirective', function() {
|
||||
describe('PasswordValidatorDirective', function () {
|
||||
// Initialize global variables
|
||||
var scope,
|
||||
element,
|
||||
@@ -12,7 +12,7 @@
|
||||
// Load the main application module
|
||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
|
||||
beforeEach(inject(function(_$rootScope_, _$compile_) {
|
||||
beforeEach(inject(function (_$rootScope_, _$compile_) {
|
||||
// Set a new global scope
|
||||
scope = _$rootScope_.$new();
|
||||
$compile = _$compile_;
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
// inject allows you to use AngularJS dependency injection
|
||||
// to retrieve and use other services
|
||||
inject(function($compile) {
|
||||
inject(function ($compile) {
|
||||
var form = $compile(template)(scope);
|
||||
element = form.find('div');
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
describe('Initialize', function() {
|
||||
describe('Initialize', function () {
|
||||
beforeEach(function () {
|
||||
compileDirective();
|
||||
});
|
||||
@@ -65,7 +65,7 @@
|
||||
expect(scope.requirementsProgress).toEqual(undefined);
|
||||
});
|
||||
|
||||
it('should be valid when password meets requirements - "P@ssw0rd!!""', function() {
|
||||
it('should be valid when password meets requirements - "P@ssw0rd!!""', function () {
|
||||
scope.passwordMock.password = 'P@ssw0rd!!';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -76,7 +76,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('100');
|
||||
});
|
||||
|
||||
it('should be valid when password meets requirements with a passphrase', function() {
|
||||
it('should be valid when password meets requirements with a passphrase', function () {
|
||||
scope.passwordMock.password = 'Open-Source Full-Stack Solution for MEAN';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -87,7 +87,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('100');
|
||||
});
|
||||
|
||||
it('should not allow a less than 10 characters long - "P@$$w0rd!"', function() {
|
||||
it('should not allow a less than 10 characters long - "P@$$w0rd!"', function () {
|
||||
scope.passwordMock.password = 'P@$$w0rd!';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -99,7 +99,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('80');
|
||||
});
|
||||
|
||||
it('should not allow a greater than 128 characters long', function() {
|
||||
it('should not allow a greater than 128 characters long', function () {
|
||||
scope.passwordMock.password = ')!/uLT="lh&:`6X!]|15o!$!TJf,.13l?vG].-j],lFPe/QhwN#{Z<[*1nX@n1^?WW-%_.*D)m$toB+N7z}kcN#B_d(f41h%w@0F!]igtSQ1gl~6sEV&r~}~1ub>If1c+';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -111,7 +111,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('80');
|
||||
});
|
||||
|
||||
it('should not allow more than 3 or more repeating characters - "P@$$w0rd!!!"', function() {
|
||||
it('should not allow more than 3 or more repeating characters - "P@$$w0rd!!!"', function () {
|
||||
scope.passwordMock.password = 'P@$$w0rd!!!';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -123,7 +123,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('80');
|
||||
});
|
||||
|
||||
it('should not allow a password with no uppercase letters - "p@$$w0rd!!"', function() {
|
||||
it('should not allow a password with no uppercase letters - "p@$$w0rd!!"', function () {
|
||||
scope.passwordMock.password = 'p@$$w0rd!!';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -135,7 +135,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('80');
|
||||
});
|
||||
|
||||
it('should not allow a password with less than one number - "P@$$word!!"', function() {
|
||||
it('should not allow a password with less than one number - "P@$$word!!"', function () {
|
||||
scope.passwordMock.password = 'P@$$word!!';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -147,7 +147,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('80');
|
||||
});
|
||||
|
||||
it('should not allow a password with less than one special character - "Passw0rdss"', function() {
|
||||
it('should not allow a password with less than one special character - "Passw0rdss"', function () {
|
||||
scope.passwordMock.password = 'Passw0rdss';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -159,7 +159,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('80');
|
||||
});
|
||||
|
||||
it('should show 20% progress and "danger" color', function() {
|
||||
it('should show 20% progress and "danger" color', function () {
|
||||
scope.passwordMock.password = 'P';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -168,7 +168,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('20');
|
||||
});
|
||||
|
||||
it('should show 40% progress and "warning" color', function() {
|
||||
it('should show 40% progress and "warning" color', function () {
|
||||
scope.passwordMock.password = 'Pa';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -177,7 +177,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('40');
|
||||
});
|
||||
|
||||
it('should show 60% progress and "info" color', function() {
|
||||
it('should show 60% progress and "info" color', function () {
|
||||
scope.passwordMock.password = 'Pa$';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -186,7 +186,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('60');
|
||||
});
|
||||
|
||||
it('should show 80% progress and "primary" color', function() {
|
||||
it('should show 80% progress and "primary" color', function () {
|
||||
scope.passwordMock.password = 'Pa$$w0rd';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
@@ -195,7 +195,7 @@
|
||||
expect(scope.requirementsProgress).toEqual('80');
|
||||
});
|
||||
|
||||
it('should show 100% progress and "success" color', function() {
|
||||
it('should show 100% progress and "success" color', function () {
|
||||
scope.passwordMock.password = 'Pa$$w0rd!!';
|
||||
compileDirective();
|
||||
scope.$digest();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
// Password Verify Directive Spec
|
||||
describe('PasswordVerifyDirective', function() {
|
||||
describe('PasswordVerifyDirective', function () {
|
||||
// Initialize global variables
|
||||
var scope,
|
||||
element,
|
||||
@@ -12,7 +12,7 @@
|
||||
// Load the main application module
|
||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
|
||||
beforeEach(inject(function(_$rootScope_, _$compile_) {
|
||||
beforeEach(inject(function (_$rootScope_, _$compile_) {
|
||||
// Set a new global scope
|
||||
scope = _$rootScope_.$new();
|
||||
$compile = _$compile_;
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
// inject allows you to use AngularJS dependency injection
|
||||
// to retrieve and use other services
|
||||
inject(function($compile) {
|
||||
inject(function ($compile) {
|
||||
var form = $compile(template)(scope);
|
||||
element = form.find('div');
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
describe('Initialize', function() {
|
||||
describe('Initialize', function () {
|
||||
beforeEach(function () {
|
||||
compileDirective();
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
(function () {
|
||||
// Password controller Spec
|
||||
describe('PasswordController', function() {
|
||||
describe('PasswordController', function () {
|
||||
// Initialize global variables
|
||||
var PasswordController,
|
||||
scope,
|
||||
@@ -12,11 +12,11 @@
|
||||
$window,
|
||||
Notification;
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
jasmine.addMatchers({
|
||||
toEqualData: function(util, customEqualityTesters) {
|
||||
toEqualData: function (util, customEqualityTesters) {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
compare: function (actual, expected) {
|
||||
return {
|
||||
pass: angular.equals(actual, expected)
|
||||
};
|
||||
@@ -29,8 +29,8 @@
|
||||
// Load the main application module
|
||||
beforeEach(module(ApplicationConfiguration.applicationModuleName));
|
||||
|
||||
describe('Logged in user', function() {
|
||||
beforeEach(inject(function($controller, $rootScope, _UsersService_, _Authentication_, _$stateParams_, _$httpBackend_, _$location_) {
|
||||
describe('Logged in user', function () {
|
||||
beforeEach(inject(function ($controller, $rootScope, _UsersService_, _Authentication_, _$stateParams_, _$httpBackend_, _$location_) {
|
||||
// Set a new global scope
|
||||
scope = $rootScope.$new();
|
||||
|
||||
@@ -55,13 +55,13 @@
|
||||
});
|
||||
}));
|
||||
|
||||
it('should redirect logged in user to home', function() {
|
||||
it('should redirect logged in user to home', function () {
|
||||
expect($location.path).toHaveBeenCalledWith('/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Logged out user', function() {
|
||||
beforeEach(inject(function($controller, $rootScope, _$window_, _$stateParams_, _$httpBackend_, _$location_, _Notification_) {
|
||||
describe('Logged out user', function () {
|
||||
beforeEach(inject(function ($controller, $rootScope, _$window_, _$stateParams_, _$httpBackend_, _$location_, _Notification_) {
|
||||
// Set a new global scope
|
||||
scope = $rootScope.$new();
|
||||
|
||||
@@ -87,22 +87,22 @@
|
||||
});
|
||||
}));
|
||||
|
||||
it('should not redirect to home', function() {
|
||||
it('should not redirect to home', function () {
|
||||
expect($location.path).not.toHaveBeenCalledWith('/');
|
||||
});
|
||||
|
||||
describe('askForPasswordReset', function() {
|
||||
describe('askForPasswordReset', function () {
|
||||
var credentials = {
|
||||
username: 'test',
|
||||
password: 'P@ssw0rd!!'
|
||||
};
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
scope.vm.credentials = credentials;
|
||||
});
|
||||
|
||||
describe('POST error', function() {
|
||||
describe('POST error', function () {
|
||||
var errorMessage = 'No account with that username has been found';
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
$httpBackend.when('POST', '/api/auth/forgot', credentials).respond(400, {
|
||||
'message': errorMessage
|
||||
});
|
||||
@@ -111,18 +111,18 @@
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should clear form', function() {
|
||||
it('should clear form', function () {
|
||||
expect(scope.vm.credentials).toBe(null);
|
||||
});
|
||||
|
||||
it('should call Notification.error with response message', function() {
|
||||
it('should call Notification.error with response message', function () {
|
||||
expect(Notification.error).toHaveBeenCalledWith({ message: errorMessage, title: '<i class="glyphicon glyphicon-remove"></i> Failed to send password reset email!', delay: 4000 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('POST success', function() {
|
||||
describe('POST success', function () {
|
||||
var successMessage = 'An email has been sent to the provided email with further instructions.';
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
$httpBackend.when('POST', '/api/auth/forgot', credentials).respond({
|
||||
'message': successMessage
|
||||
});
|
||||
@@ -131,27 +131,27 @@
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should clear form', function() {
|
||||
it('should clear form', function () {
|
||||
expect(scope.vm.credentials).toBe(null);
|
||||
});
|
||||
|
||||
it('should call Notification.success with response message', function() {
|
||||
it('should call Notification.success with response message', function () {
|
||||
expect(Notification.success).toHaveBeenCalledWith({ message: successMessage, title: '<i class="glyphicon glyphicon-ok"></i> Password reset email sent successfully!' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('resetUserPassword', function() {
|
||||
describe('resetUserPassword', function () {
|
||||
var token = 'testToken';
|
||||
var passwordDetails = {
|
||||
password: 'test'
|
||||
};
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
$stateParams.token = token;
|
||||
scope.vm.passwordDetails = passwordDetails;
|
||||
});
|
||||
|
||||
it('POST error should call Notification.error with response message', function() {
|
||||
it('POST error should call Notification.error with response message', function () {
|
||||
var errorMessage = 'Passwords do not match';
|
||||
$httpBackend.when('POST', '/api/auth/reset/' + token, passwordDetails).respond(400, {
|
||||
'message': errorMessage
|
||||
@@ -163,26 +163,26 @@
|
||||
expect(Notification.error).toHaveBeenCalledWith({ message: errorMessage, title: '<i class="glyphicon glyphicon-remove"></i> Password reset failed!', delay: 4000 });
|
||||
});
|
||||
|
||||
describe('POST success', function() {
|
||||
describe('POST success', function () {
|
||||
var user = {
|
||||
username: 'test'
|
||||
};
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
$httpBackend.when('POST', '/api/auth/reset/' + token, passwordDetails).respond(user);
|
||||
|
||||
scope.vm.resetUserPassword(true);
|
||||
$httpBackend.flush();
|
||||
});
|
||||
|
||||
it('should clear password form', function() {
|
||||
it('should clear password form', function () {
|
||||
expect(scope.vm.passwordDetails).toBe(null);
|
||||
});
|
||||
|
||||
it('should attach user profile', function() {
|
||||
it('should attach user profile', function () {
|
||||
expect(scope.vm.authentication.user.username).toEqual(user.username);
|
||||
});
|
||||
|
||||
it('should redirect to password reset success view with Notification.success', function() {
|
||||
it('should redirect to password reset success view with Notification.success', function () {
|
||||
expect(Notification.success).toHaveBeenCalledWith({ message: '<i class="glyphicon glyphicon-ok"></i> Password reset successful!' });
|
||||
expect($location.path).toHaveBeenCalledWith('/password/reset/success');
|
||||
});
|
||||
|
||||
@@ -421,7 +421,7 @@ describe('Users E2E Tests:', function () {
|
||||
expect(element.all(by.css('.error-text')).get(1).getText()).toBe('Password is required.');
|
||||
});
|
||||
|
||||
it('Verify that the user is logged in', function() {
|
||||
it('Verify that the user is logged in', function () {
|
||||
// Make sure user is signed out first
|
||||
signout();
|
||||
// Sign in
|
||||
|
||||
@@ -186,7 +186,7 @@ describe('User Model Unit Tests:', function () {
|
||||
_user3.email = _user1.email;
|
||||
_user3.save(function (err) {
|
||||
should.exist(err);
|
||||
_user1.remove(function(err) {
|
||||
_user1.remove(function (err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
@@ -224,7 +224,7 @@ describe('User Model Unit Tests:', function () {
|
||||
_user1.save(function (err) {
|
||||
should.not.exist(err);
|
||||
_user1.password.should.not.equal(passwordBeforeSave);
|
||||
_user1.remove(function(err) {
|
||||
_user1.remove(function (err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
@@ -238,7 +238,7 @@ describe('User Model Unit Tests:', function () {
|
||||
_user1.save(function (err) {
|
||||
should.not.exist(err);
|
||||
_user1.password.should.not.equal(passwordBeforeSave);
|
||||
_user1.remove(function(err) {
|
||||
_user1.remove(function (err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
@@ -246,7 +246,7 @@ describe('User Model Unit Tests:', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('User Password Validation Tests', function() {
|
||||
describe('User Password Validation Tests', function () {
|
||||
it('should validate when the password strength passes - "P@$$w0rd!!"', function () {
|
||||
var _user1 = new User(user1);
|
||||
_user1.password = 'P@$$w0rd!!';
|
||||
@@ -351,7 +351,7 @@ describe('User Model Unit Tests:', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('User E-mail Validation Tests', function() {
|
||||
describe('User E-mail Validation Tests', function () {
|
||||
it('should not allow invalid email address - "123"', function (done) {
|
||||
var _user1 = new User(user1);
|
||||
|
||||
@@ -645,12 +645,12 @@ describe('User Model Unit Tests:', function () {
|
||||
|
||||
});
|
||||
|
||||
describe('Username Validation', function() {
|
||||
it('should show error to save username beginning with .', function(done) {
|
||||
describe('Username Validation', function () {
|
||||
it('should show error to save username beginning with .', function (done) {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = '.login';
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
@@ -660,67 +660,67 @@ describe('User Model Unit Tests:', function () {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = config.illegalUsernames[Math.floor(Math.random() * config.illegalUsernames.length)];
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show error to save username end with .', function(done) {
|
||||
it('should show error to save username end with .', function (done) {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = 'login.';
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show error to save username with ..', function(done) {
|
||||
it('should show error to save username with ..', function (done) {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = 'log..in';
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show error to save username shorter than 3 character', function(done) {
|
||||
it('should show error to save username shorter than 3 character', function (done) {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = 'lo';
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show error saving a username without at least one alphanumeric character', function(done) {
|
||||
it('should show error saving a username without at least one alphanumeric character', function (done) {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = '-_-';
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should show error saving a username longer than 34 characters', function(done) {
|
||||
it('should show error saving a username longer than 34 characters', function (done) {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = 'l'.repeat(35);
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should save username with dot', function(done) {
|
||||
it('should save username with dot', function (done) {
|
||||
var _user = new User(user1);
|
||||
|
||||
_user.username = 'log.in';
|
||||
_user.save(function(err) {
|
||||
_user.save(function (err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -427,7 +427,7 @@ describe('User CRUD tests', function () {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
User.findOne({ username: user.username.toLowerCase() }, function(err, userRes) {
|
||||
User.findOne({ username: user.username.toLowerCase() }, function (err, userRes) {
|
||||
userRes.resetPasswordToken.should.not.be.empty();
|
||||
should.exist(userRes.resetPasswordExpires);
|
||||
res.body.message.should.be.equal('Failure sending email');
|
||||
@@ -453,7 +453,7 @@ describe('User CRUD tests', function () {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
User.findOne({ username: user.username.toLowerCase() }, function(err, userRes) {
|
||||
User.findOne({ username: user.username.toLowerCase() }, function (err, userRes) {
|
||||
userRes.resetPasswordToken.should.not.be.empty();
|
||||
should.exist(userRes.resetPasswordExpires);
|
||||
res.body.message.should.be.equal('Failure sending email');
|
||||
@@ -479,7 +479,7 @@ describe('User CRUD tests', function () {
|
||||
return done(err);
|
||||
}
|
||||
|
||||
User.findOne({ username: user.username.toLowerCase() }, function(err, userRes) {
|
||||
User.findOne({ username: user.username.toLowerCase() }, function (err, userRes) {
|
||||
userRes.resetPasswordToken.should.not.be.empty();
|
||||
should.exist(userRes.resetPasswordExpires);
|
||||
|
||||
@@ -1083,7 +1083,7 @@ describe('User CRUD tests', function () {
|
||||
|
||||
user.profileImageURL = config.uploads.profile.image.dest + 'non-existing.png';
|
||||
|
||||
user.save(function(saveErr) {
|
||||
user.save(function (saveErr) {
|
||||
// Handle error
|
||||
if (saveErr) {
|
||||
return done(saveErr);
|
||||
|
||||
Reference in New Issue
Block a user