Update for code quality

This commit is contained in:
Matthew Ross 2016-11-23 11:21:44 -05:00
parent a02e8e6636
commit 3f439d5fb4
7 changed files with 44 additions and 44 deletions

View File

@ -32,7 +32,7 @@ global.TitleMock = function() {
getTitle: () => {
return title;
},
setTitle: (text) => {
setTitle: text => {
title = text;
}
};
@ -58,7 +58,7 @@ global.AuthServiceMock = {
default_board_id: 0,
security_level: 2
}),
updateUser: (user) => {
updateUser: user => {
},
login: () => {
return RxJs.Observable.of({
@ -81,7 +81,7 @@ global.NotificationsServiceMock = function() {
return {
noteAdded: notes.asObservable(),
add: (note) => {
add: note => {
notes.next(note);
}
};
@ -94,7 +94,7 @@ global.ResponseMock = function(endpoint) {
alerts: [],
data: [ 'jwt', 'true', 'true' ],
status: 'success',
endpoint: endpoint
endpoint
};
}
};
@ -110,7 +110,7 @@ global.ModalServiceMock = function() {
openCalled: opened.asObservable(),
registerCalled: register.asObservable(),
open: (id) => {
open: id => {
opened.next(id);
},
close: () => {
@ -135,7 +135,7 @@ global.SettingsServiceMock = function() {
usersChanged: RxJs.Observable.of(userList),
boardsChanged: RxJs.Observable.of(boardsList),
updateUsers: (users) => {
updateUsers: users => {
userList = users;
},
getUsers: () => {
@ -146,7 +146,7 @@ global.SettingsServiceMock = function() {
});
},
updateBoards: (boards) => {
updateBoards: boards => {
boardsList = boards;
},
getBoards: () => {
@ -166,7 +166,7 @@ global.UserAdminServiceMock = function() {
];
return {
addUser: (user) => {
addUser: user => {
return RxJs.Observable.of({
status: 'success',
alerts: [],
@ -176,7 +176,7 @@ global.UserAdminServiceMock = function() {
]
});
},
editUser: (user) => {
editUser: user => {
return RxJs.Observable.of({
status: 'success',
alerts: [],
@ -190,7 +190,7 @@ global.UserAdminServiceMock = function() {
]
});
},
removeUser: (userId) => {
removeUser: userId => {
return RxJs.Observable.of({
status: 'success',
alerts: [],
@ -204,28 +204,28 @@ global.UserAdminServiceMock = function() {
};
global.UserSettingsServiceMock = {
changeUserOptions: (opts) => {
changeUserOptions: opts => {
return RxJs.Observable.of({
alerts: []
});
},
changeDefaultBoard: (boardId) => {
changeDefaultBoard: boardId => {
return RxJs.Observable.of({
alerts: [{ type: 'success', text: '' }],
data: [ '', '{}' ]
});
},
changeUsername: (newName) => {
changeUsername: newName => {
return RxJs.Observable.of({
alerts: [{ type: 'success', text: '' }]
});
},
changePassword: (newPass) => {
changePassword: newPass => {
return RxJs.Observable.of({
alerts: [{ type: 'success', text: '' }]
});
},
changeEmail: (newEmail) => {
changeEmail: newEmail => {
return RxJs.Observable.of({
alerts: [{ type: 'success', text: '' }]
});
@ -237,11 +237,11 @@ global.HttpMock = {
var response = new global.ResponseMock(url);
return RxJs.Observable.of(response);
},
get: (url) => {
get: url => {
var response = new global.ResponseMock(url);
return RxJs.Observable.of(response);
},
delete: (url) => {
delete: url => {
var response = new global.ResponseMock(url);
return RxJs.Observable.of(response);
}

View File

@ -9,24 +9,24 @@ describe('UserAdminService', () => {
settingsService = new SettingsService(HttpMock);
});
it('provides a list of users', (done) => {
it('provides a list of users', done => {
settingsService.getUsers().subscribe(users => {
expect(users.endpoint).to.equal('api/users');
done();
});
});
it('provides a list of boards', (done) => {
it('provides a list of boards', done => {
settingsService.getBoards().subscribe(users => {
expect(users.endpoint).to.equal('api/boards');
done();
});
});
it('allows updating users and notifies subscribers', (done) => {
it('allows updating users and notifies subscribers', done => {
var first = true;
settingsService.usersChanged.subscribe((users) => {
settingsService.usersChanged.subscribe(users => {
expect(users).to.be.an('array');
if (first) {
@ -40,10 +40,10 @@ describe('UserAdminService', () => {
settingsService.updateUsers([]);
});
it('allows updating boards and notifies subscribers', (done) => {
it('allows updating boards and notifies subscribers', done => {
var first = true;
settingsService.boardsChanged.subscribe((boards) => {
settingsService.boardsChanged.subscribe(boards => {
expect(boards).to.be.an('array');
if (first) {

View File

@ -14,7 +14,7 @@ describe('UserAdmin', () => {
new SettingsServiceMock(), modalService);
});
it('has a function to add or edit a user - Add', (done) => {
it('has a function to add or edit a user - Add', done => {
userAdmin.modalProps.title = 'Add';
userAdmin.modalProps.user = {
username: 'testing',
@ -31,7 +31,7 @@ describe('UserAdmin', () => {
}, 10);
});
it('has a function to add or edit a user - Edit', (done) => {
it('has a function to add or edit a user - Edit', done => {
userAdmin.modalProps.title = 'Edit';
userAdmin.modalProps.user = {
id: 1,
@ -72,7 +72,7 @@ describe('UserAdmin', () => {
expect(userAdmin.validateModalUser()).to.equal(true);
});
it('has a function to remove a user', (done) => {
it('has a function to remove a user', done => {
userAdmin.userToRemove = { id: 1 };
userAdmin.removeUser();
@ -82,8 +82,8 @@ describe('UserAdmin', () => {
}, 10);
});
it('has a showModal function', (done) => {
modalService.openCalled.subscribe((modalId) => {
it('has a showModal function', done => {
modalService.openCalled.subscribe(modalId => {
expect(modalId).to.equal(userAdmin.MODAL_ID);
done();
});
@ -91,7 +91,7 @@ describe('UserAdmin', () => {
userAdmin.showModal('Add');
});
it('has a showConfirmModal function', (done) => {
it('has a showConfirmModal function', done => {
modalService.openCalled.subscribe((modalId) => {
expect(modalId).to.equal(userAdmin.MODAL_CONFIRM_ID);
expect(userAdmin.userToRemove).to.equal(true);

View File

@ -35,7 +35,7 @@ describe('UserSettings', () => {
expect(userSettings.userOptions.show_assignee).to.equal(true);
});
it('has a function to update default board', (done) => {
it('has a function to update default board', done => {
notifications.noteAdded.subscribe(note => {
expect(note.type).to.equal('success');
done();
@ -44,7 +44,7 @@ describe('UserSettings', () => {
userSettings.updateDefaultBoard('1');
});
it('has a function to update password', (done) => {
it('has a function to update password', done => {
userSettings.changePassword = {
current: ''
};
@ -80,7 +80,7 @@ describe('UserSettings', () => {
userSettings.updatePassword();
});
it('has a function to update username', (done) => {
it('has a function to update username', done => {
userSettings.changeUsername = { newName: '' };
var first = true;
@ -99,7 +99,7 @@ describe('UserSettings', () => {
userSettings.updateUsername();
});
it('has a function to update email', (done) => {
it('has a function to update email', done => {
userSettings.changeEmail = { newEmail: 'asdf' };
var first = true;

View File

@ -11,35 +11,35 @@ describe('UserSettingsService', () => {
HttpMock);
});
it('calls the api to change the default board', (done) => {
it('calls the api to change the default board', done => {
userSettingsService.changeDefaultBoard('1').subscribe(data => {
expect(data.endpoint).to.equal('api/users/1');
done();
});
});
it('calls the api to change a password', (done) => {
it('calls the api to change a password', done => {
userSettingsService.changePassword('old', 'new').subscribe(data => {
expect(data.endpoint).to.equal('api/users/1');
done();
});
});
it('calls the api to change a username', (done) => {
it('calls the api to change a username', done => {
userSettingsService.changeUsername('tester').subscribe(data => {
expect(data.endpoint).to.equal('api/users/1');
done();
});
});
it('calls the api to change an email', (done) => {
it('calls the api to change an email', done => {
userSettingsService.changeEmail('newEmail').subscribe(data => {
expect(data.endpoint).to.equal('api/users/1');
done();
});
});
it('calls the api to change a user option', (done) => {
it('calls the api to change a user option', done => {
userSettingsService.changeUserOptions({}).subscribe(data => {
expect(data.endpoint).to.equal('api/users/1/opts');
done();

View File

@ -9,7 +9,7 @@ describe('InlineEdit', () => {
inlineEdit = new InlineEdit();
});
it('has a beginEdit method', (done) => {
it('has a beginEdit method', done => {
expect(inlineEdit.beginEdit).to.be.a('function');
var called = false,
@ -28,10 +28,10 @@ describe('InlineEdit', () => {
}, 110);
});
it('has an editDone function', (done) => {
it('has an editDone function', done => {
expect(inlineEdit.editDone).to.be.a('function');
inlineEdit.edit.subscribe((text) => {
inlineEdit.edit.subscribe(text => {
expect(text).to.equal('test');
done();
});

View File

@ -27,7 +27,7 @@ describe('Modal', () => {
expect(modal.isOpen).to.be.a('boolean');
});
it('registers itself with the modal service on init', (done) => {
it('registers itself with the modal service on init', done => {
modalService.registerCalled.subscribe(called => {
expect(called).to.equal(true);
done();
@ -35,7 +35,7 @@ describe('Modal', () => {
modal.ngOnInit();
});
it('calls the close function on the service', (done) => {
it('calls the close function on the service', done => {
modalService.closeCalled.subscribe(called => {
expect(called).to.equal(true);
done();
@ -43,7 +43,7 @@ describe('Modal', () => {
modal.close();
});
it('calls close on Escape keypress', (done) => {
it('calls close on Escape keypress', done => {
modalService.closeCalled.subscribe(called => {
expect(called).to.equal(true);
done();