Commit 166375d4 authored by Evren Kutar's avatar Evren Kutar

login test base descriptions

parent b1b4db20
'use strict';
// TODO: clean console log items
angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
......@@ -9,7 +10,7 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
controller: 'LoginCtrl'
});
}])
.controller('LoginCtrl', function ($scope, $http) {
.controller('LoginCtrl', function ($scope, $http, $location, $rootScope) {
$scope.schema =
{
title: "Login",
......@@ -57,15 +58,18 @@ angular.module('zaerp.login', ['ngRoute', 'schemaForm'])
}
];
$scope.onSubmit = function(form){
$scope.$broadcast('schemaFormValidate');
//$scope.$broadcast('schemaFormValidate');
console.log(form);
if (form.$valid){
$http.post('http://127.0.0.1:8000/login', form).
success(function(data, status, headers, config){
console.log(data);
}).
error(function(data, status, headers, config){
console.log("form submit failed: "+status);
});
$rootScope.loggedInUser = true;
$location.path("/view2");
//$http.post('http://127.0.0.1:8003/#/login', form.email).
// success(function(data, status, headers, config){
// console.log(data);
// }).
// error(function(data, status, headers, config){
// console.log("form submit failed: "+status);
// });
}
else {
console.log("not valid");
......
/**
* Created by evren kutar on 12/05/15.
*/
......@@ -6,11 +6,66 @@ describe('zaerp.login module', function () {
describe('login controller', function () {
it('should ....', inject(function ($controller) {
it('should have a login controller', inject(function ($controller) {
//spec body
var loginCtrl = $controller('LoginCtrl');
expect(loginCtrl).toBeDefined();
}));
it('should have a working LoginService service', inject(['LoginService',
function (LoginService) {
expect(LoginService.isValidEmail).not.to.equal(null);
// test cases - testing for success
var validEmails = [
'test@test.com',
'test@test.co.uk',
'test734ltylytkliytkryety9ef@jb-fe.com'
];
// test cases - testing for failure
var invalidEmails = [
'test@testcom',
'test@ test.co.uk',
'ghgf@fe.com.co.',
'tes@t@test.com',
''
];
// you can loop through arrays of test cases like this
for (var i in validEmails) {
var valid = LoginService.isValidEmail(validEmails[i]);
expect(valid).toBeTruthy();
}
for (var i in invalidEmails) {
var valid = LoginService.isValidEmail(invalidEmails[i]);
expect(valid).toBeFalsy();
}
}])
);
it('ensures user can log in', function() {
// expect current scope to contain username
});
it('ensures path has changed', function() {
// expect path to equal '/dashboard'
});
it('should get login success',
inject(function(LoginService, $httpBackend) {
$httpBackend.expect('POST', 'https://127.0.0.1:8000/login')
.respond(200, "[{ success : 'true', id : 123 }]");
LoginService.login('test@test.com', 'password')
.then(function(data) {
expect(data.success).toBeTruthy();
});
$httpBackend.flush();
})
);
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment