Update app unit tests
This commit is contained in:
parent
922f5c6030
commit
d6e54e6675
@ -52,5 +52,16 @@ describe('Login', () => {
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
|
||||
it('calls the AuthService during ngOnInit', (done) => {
|
||||
expect(login.ngOnInit).to.be.a('function');
|
||||
|
||||
login.ngOnInit();
|
||||
|
||||
setTimeout(() => {
|
||||
expect(router.path).to.equal('/boards');
|
||||
done();
|
||||
}, 10);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -70,7 +70,7 @@ global.AuthServiceMock = {
|
||||
});
|
||||
},
|
||||
authenticate: () => {
|
||||
return false;
|
||||
return RxJs.Observable.of(true);
|
||||
}
|
||||
};
|
||||
|
||||
@ -207,19 +207,25 @@ global.UserSettingsServiceMock = {
|
||||
alerts: []
|
||||
});
|
||||
},
|
||||
changeDefaultBoard: (boardId) => {
|
||||
return RxJs.Observable.of({
|
||||
alerts: [{ type: 'success', text: '' }],
|
||||
data: [ '', '{}' ]
|
||||
});
|
||||
},
|
||||
changeUsername: (newName) => {
|
||||
return RxJs.Observable.of({
|
||||
alerts: [{ type: 'success', text: ''}]
|
||||
alerts: [{ type: 'success', text: '' }]
|
||||
});
|
||||
},
|
||||
changePassword: (newPass) => {
|
||||
return RxJs.Observable.of({
|
||||
alerts: [{ type: 'success', text: ''}]
|
||||
alerts: [{ type: 'success', text: '' }]
|
||||
});
|
||||
},
|
||||
changeEmail: (newEmail) => {
|
||||
return RxJs.Observable.of({
|
||||
alerts: [{ type: 'success', text: ''}]
|
||||
alerts: [{ type: 'success', text: '' }]
|
||||
});
|
||||
}
|
||||
};
|
||||
|
2
test/app/settings/settings.component.spec.js
Normal file
2
test/app/settings/settings.component.spec.js
Normal file
@ -0,0 +1,2 @@
|
||||
/* global expect */
|
||||
|
@ -16,11 +16,45 @@ describe('UserAdminService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('notifies subscribers when users are updated', (done) => {
|
||||
settingsService.usersChanged.subscribe((users) => {
|
||||
expect(users).to.be.an('array');
|
||||
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) => {
|
||||
var first = true;
|
||||
|
||||
settingsService.usersChanged.subscribe((users) => {
|
||||
expect(users).to.be.an('array');
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
return;
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
settingsService.updateUsers([]);
|
||||
});
|
||||
|
||||
it('allows updating boards and notifies subscribers', (done) => {
|
||||
var first = true;
|
||||
|
||||
settingsService.boardsChanged.subscribe((boards) => {
|
||||
expect(boards).to.be.an('array');
|
||||
|
||||
if (first) {
|
||||
first = false;
|
||||
return;
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
settingsService.updateBoards([]);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -51,6 +51,8 @@ describe('UserAdmin', () => {
|
||||
});
|
||||
|
||||
it('has a function to validate a user', () => {
|
||||
userAdmin.modalProps.title = 'Add';
|
||||
|
||||
userAdmin.modalProps.user = { username: '' };
|
||||
expect(userAdmin.validateModalUser()).to.equal(false);
|
||||
|
||||
|
@ -35,6 +35,15 @@ describe('UserSettings', () => {
|
||||
expect(userSettings.userOptions.show_assignee).to.equal(true);
|
||||
});
|
||||
|
||||
it('has a function to update default board', (done) => {
|
||||
notifications.noteAdded.subscribe(note => {
|
||||
expect(note.type).to.equal('success');
|
||||
done();
|
||||
});
|
||||
|
||||
userSettings.updateDefaultBoard('1');
|
||||
});
|
||||
|
||||
it('has a function to update password', (done) => {
|
||||
userSettings.changePassword = {
|
||||
current: ''
|
||||
|
@ -11,6 +11,13 @@ describe('UserSettingsService', () => {
|
||||
HttpMock);
|
||||
});
|
||||
|
||||
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) => {
|
||||
userSettingsService.changePassword('old', 'new').subscribe(data => {
|
||||
expect(data.endpoint).to.equal('api/users/1');
|
||||
|
@ -9,8 +9,11 @@ describe('AuthGuard', () => {
|
||||
authGuard = new AuthGuard(AuthServiceMock);
|
||||
});
|
||||
|
||||
it('checks a route can activate via the auth service', () => {
|
||||
expect(authGuard.canActivate()).to.equal(false);
|
||||
it('checks a route can activate via the auth service', (done) => {
|
||||
authGuard.canActivate().subscribe((isAuth) => {
|
||||
expect(isAuth).to.equal(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
42
test/app/shared/inline-edit/inline-edit.component.spec.js
Normal file
42
test/app/shared/inline-edit/inline-edit.component.spec.js
Normal file
@ -0,0 +1,42 @@
|
||||
/* global expect */
|
||||
var path = '../../../../build/shared/inline-edit/',
|
||||
InlineEdit = require(path + 'inline-edit.component.js').InlineEdit;
|
||||
|
||||
describe('InlineEdit', () => {
|
||||
var inlineEdit;
|
||||
|
||||
beforeEach(() => {
|
||||
inlineEdit = new InlineEdit();
|
||||
});
|
||||
|
||||
it('has a beginEdit method', (done) => {
|
||||
expect(inlineEdit.beginEdit).to.be.a('function');
|
||||
|
||||
var called = false,
|
||||
el = {
|
||||
focus: () => {
|
||||
called = true;
|
||||
}
|
||||
};
|
||||
|
||||
inlineEdit.beginEdit(el);
|
||||
expect(inlineEdit.isDisplay).to.equal(false);
|
||||
|
||||
setTimeout(() => {
|
||||
expect(called).to.equal(true);
|
||||
done();
|
||||
}, 110);
|
||||
});
|
||||
|
||||
it('has an editDone function', (done) => {
|
||||
expect(inlineEdit.editDone).to.be.a('function');
|
||||
|
||||
inlineEdit.edit.subscribe((text) => {
|
||||
expect(text).to.equal('test');
|
||||
done();
|
||||
});
|
||||
|
||||
inlineEdit.editDone('test');
|
||||
});
|
||||
});
|
||||
|
@ -50,5 +50,23 @@ describe('Modal', () => {
|
||||
});
|
||||
modal.keyup({ keyCode: 27 });
|
||||
});
|
||||
|
||||
it('filters clicks on the modal to prevent closing', () => {
|
||||
var stopCalled = false,
|
||||
eventStop = {
|
||||
stopPropagation: () => {
|
||||
stopCalled = true;
|
||||
}
|
||||
},
|
||||
eventCancel = {
|
||||
cancelBubble: false
|
||||
};
|
||||
|
||||
modal.filterClick(eventStop);
|
||||
expect(stopCalled).to.equal(true);
|
||||
|
||||
modal.filterClick(eventCancel);
|
||||
expect(eventCancel.cancelBubble).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -10,7 +10,12 @@ describe('ModalService', () => {
|
||||
modalService = new ModalService(AuthServiceMock);
|
||||
modal = {
|
||||
modalId: 'testModal',
|
||||
isOpen: false
|
||||
isOpen: false,
|
||||
focusElement: {
|
||||
nativeElement: {
|
||||
focus: () => {}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
75
test/app/shared/models/board.model.spec.js
Normal file
75
test/app/shared/models/board.model.spec.js
Normal file
@ -0,0 +1,75 @@
|
||||
/* globals expect */
|
||||
var path = '../../../../build/shared/models/',
|
||||
Board = require(path + 'board.model.js').Board;
|
||||
|
||||
describe('Board', () => {
|
||||
var board;
|
||||
|
||||
beforeEach(() => {
|
||||
board = new Board();
|
||||
});
|
||||
|
||||
it('has id', () => {
|
||||
expect(board.id).to.be.a('number');
|
||||
expect(board.id).to.equal(0);
|
||||
});
|
||||
|
||||
it('has name', () => {
|
||||
expect(board.name).to.be.a('string');
|
||||
expect(board.name).to.equal('');
|
||||
});
|
||||
|
||||
it('has is_active', () => {
|
||||
expect(board.is_active).to.be.a('boolean');
|
||||
expect(board.is_active).to.equal(true);
|
||||
});
|
||||
|
||||
it('has columns', () => {
|
||||
expect(board.columns).to.be.an('array');
|
||||
expect(board.columns.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('has categories', () => {
|
||||
expect(board.categories).to.be.an('array');
|
||||
expect(board.categories.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('has auto_actions', () => {
|
||||
expect(board.auto_actions).to.be.an('array');
|
||||
expect(board.auto_actions.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('has issue_trackers', () => {
|
||||
expect(board.issue_trackers).to.be.an('array');
|
||||
expect(board.issue_trackers.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('has users', () => {
|
||||
expect(board.users).to.be.an('array');
|
||||
expect(board.users.length).to.equal(0);
|
||||
});
|
||||
|
||||
it('has a method to add a column', () => {
|
||||
expect(board.addColumn).to.be.a('function');
|
||||
|
||||
board.addColumn('test');
|
||||
expect(board.columns[0].name).to.equal('test');
|
||||
});
|
||||
|
||||
it('has a method to add a category', () => {
|
||||
expect(board.addCategory).to.be.a('function');
|
||||
|
||||
board.addCategory('test', 'color');
|
||||
expect(board.categories[0].name).to.equal('test');
|
||||
expect(board.categories[0].default_task_color).to.equal('color');
|
||||
});
|
||||
|
||||
it('has a method to add an issue tracker', () => {
|
||||
expect(board.addIssueTracker).to.be.a('function');
|
||||
|
||||
board.addIssueTracker('testUrl', 'testRegex');
|
||||
expect(board.issue_trackers[0].url).to.equal('testUrl');
|
||||
expect(board.issue_trackers[0].regex).to.equal('testRegex');
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,7 @@ describe('User', () => {
|
||||
var user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = new User;
|
||||
user = new User();
|
||||
});
|
||||
|
||||
it('has default_board_id', () => {
|
||||
|
Reference in New Issue
Block a user