Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login error message unit tests #88

Merged
merged 2 commits into from
Feb 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/app/view/application.directive.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
expect(applicationCtrl.loggedIn).toBe(false);
});

it('should have properties `failedLogin` defined', function () {
expect(applicationCtrl.failedLogin).toBeDefined();
});

it('should have properties `failedLogin` defined as false by default', function () {
expect(applicationCtrl.failedLogin).toBe(false);
});

// method definitions

it('should have method `login` defined', function () {
Expand All @@ -67,6 +75,10 @@
expect(angular.isFunction(applicationCtrl.onLoggedIn)).toBe(true);
});

it('should have method `onLoginFailed` defined', function () {
expect(angular.isFunction(applicationCtrl.onLoginFailed)).toBe(true);
});

it('should have method `onLoggedOut` defined', function () {
expect(angular.isFunction(applicationCtrl.onLoggedOut)).toBe(true);
});
Expand All @@ -80,6 +92,7 @@
applicationCtrl.login('dev', 'dev');
$httpBackend.flush();
expect(applicationCtrl.loggedIn).toBe(true);
expect(applicationCtrl.failedLogin).toBe(false);
});

it('invoke `login` method - failure', function () {
Expand All @@ -89,6 +102,7 @@
applicationCtrl.login('dev', 'dev');
$httpBackend.flush();
expect(applicationCtrl.loggedIn).toBe(false);
expect(applicationCtrl.failedLogin).toBe(true);
});

it('invoke `logout` method - success', function () {
Expand All @@ -98,6 +112,7 @@
applicationCtrl.logout();
$httpBackend.flush();
expect(applicationCtrl.loggedIn).toBe(false);
expect(applicationCtrl.failedLogin).toBe(false);
});

it('invoke `logout` method - failure', function () {
Expand All @@ -107,6 +122,7 @@
applicationCtrl.logout();
$httpBackend.flush();
expect(applicationCtrl.loggedIn).toBe(true);
expect(applicationCtrl.failedLogin).toBe(false);
});

});
Expand Down
10 changes: 10 additions & 0 deletions src/app/view/login-page/login-form/login-form.directive.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@
expect($controller).toBeDefined();
});

it('should have properties `eventService` defined', function () {
expect($controller.eventService).toBeDefined();
});

it('should not show password in plain text by default', function () {
expect($controller.showPassword).toBe(false);
});

it('`clearPassword` should called when events.LOGIN_FAILED triggered', function () {
spyOn($controller, 'clearPassword');
$controller.eventService.$emit($controller.eventService.events.LOGIN_FAILED);
expect($controller.clearPassword).toHaveBeenCalled();
});

it('should allow toggling of password in plain text', function () {
$controller.showHidePassword();
expect($controller.showPassword).toBe(true);
Expand Down