Remove duplication in app test code
This commit is contained in:
parent
13872686b6
commit
6f2cf5c206
@ -122,11 +122,13 @@ global.ModalServiceMock = function() {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
global.SettingsServiceMock = function() {
|
var users = [
|
||||||
var userList = [
|
|
||||||
{ id: 1, username: 'tester', security_level: 2 },
|
{ id: 1, username: 'tester', security_level: 2 },
|
||||||
{ id: 2, username: 'test', security_level: 3, default_board_id: 0 }
|
{ id: 2, username: 'test', security_level: 3, default_board_id: 0 }
|
||||||
],
|
];
|
||||||
|
|
||||||
|
global.SettingsServiceMock = function() {
|
||||||
|
var userList = users,
|
||||||
boardsList = [
|
boardsList = [
|
||||||
{ id: 1, name: 'Testing' }
|
{ id: 1, name: 'Testing' }
|
||||||
];
|
];
|
||||||
@ -160,10 +162,7 @@ global.SettingsServiceMock = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
global.UserAdminServiceMock = function() {
|
global.UserAdminServiceMock = function() {
|
||||||
var userList = [
|
var userList = users;
|
||||||
{ id: 1, username: 'tester', security_level: 2 },
|
|
||||||
{ id: 2, username: 'test', security_level: 3, default_board_id: 0 }
|
|
||||||
];
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
addUser: user => {
|
addUser: user => {
|
||||||
|
@ -83,16 +83,7 @@ describe('UserSettings', () => {
|
|||||||
it('has a function to update username', done => {
|
it('has a function to update username', done => {
|
||||||
userSettings.changeUsername = { newName: '' };
|
userSettings.changeUsername = { newName: '' };
|
||||||
|
|
||||||
var first = true;
|
checkNotifications(done);
|
||||||
notifications.noteAdded.subscribe(note => {
|
|
||||||
if (first) {
|
|
||||||
expect(note.type).to.equal('error');
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
expect(note.type).to.equal('success');
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
userSettings.updateUsername();
|
userSettings.updateUsername();
|
||||||
|
|
||||||
userSettings.changeUsername = { newName: 'test' };
|
userSettings.changeUsername = { newName: 'test' };
|
||||||
@ -102,6 +93,14 @@ describe('UserSettings', () => {
|
|||||||
it('has a function to update email', done => {
|
it('has a function to update email', done => {
|
||||||
userSettings.changeEmail = { newEmail: 'asdf' };
|
userSettings.changeEmail = { newEmail: 'asdf' };
|
||||||
|
|
||||||
|
checkNotifications(done);
|
||||||
|
userSettings.updateEmail();
|
||||||
|
|
||||||
|
userSettings.changeEmail.newEmail = 'test@example.com';
|
||||||
|
userSettings.updateEmail();
|
||||||
|
});
|
||||||
|
|
||||||
|
function checkNotifications(done) {
|
||||||
var first = true;
|
var first = true;
|
||||||
notifications.noteAdded.subscribe(note => {
|
notifications.noteAdded.subscribe(note => {
|
||||||
if (first) {
|
if (first) {
|
||||||
@ -112,10 +111,6 @@ describe('UserSettings', () => {
|
|||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
userSettings.updateEmail();
|
}
|
||||||
|
|
||||||
userSettings.changeEmail.newEmail = 'test@example.com';
|
|
||||||
userSettings.updateEmail();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user