Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
166375d4
Commit
166375d4
authored
May 12, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
login test base descriptions
parent
b1b4db20
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
10 deletions
+72
-10
login.js
app/login/login.js
+13
-9
login_service.js
app/login/login_service.js
+3
-0
login_test.js
app/login/login_test.js
+56
-1
No files found.
app/login/login.js
View file @
166375d4
'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"
);
...
...
app/login/login_service.js
0 → 100644
View file @
166375d4
/**
* Created by evren kutar on 12/05/15.
*/
app/login/login_test.js
View file @
166375d4
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment