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
d91e9e9b
Commit
d91e9e9b
authored
Sep 10, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
karma tests updated for new structure and components
parent
fc1d2fb7
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
48 additions
and
22 deletions
+48
-22
app_routes.js
app/app_routes.js
+1
-1
auth_test.js
app/components/auth/auth_test.js
+3
-3
staff_controller_test.js
app/components/staff/staff_controller_test.js
+1
-1
version_test.js
app/components/version/version_test.js
+1
-1
form_service.js
app/zetalib/forms/form_service.js
+6
-5
form_service_test.js
app/zetalib/forms/form_service_test.js
+31
-9
karma.conf.js
karma.conf.js
+5
-2
No files found.
app/app_routes.js
View file @
d91e9e9b
...
...
@@ -15,7 +15,7 @@ app.config(['$routeProvider', function ($routeProvider) {
controller
:
'CRUDAddEditCtrl'
})
.
when
(
'/crud/:model/edit/:id'
,
{
templateUrl
:
'components/crud/templates/
edit
.html'
,
templateUrl
:
'components/crud/templates/
add
.html'
,
controller
:
'CRUDAddEditCtrl'
})
.
when
(
'/crud/:model'
,
{
...
...
app/components/auth/auth_test.js
View file @
d91e9e9b
...
...
@@ -63,7 +63,7 @@ describe('ulakbus.auth module', function () {
// use httpBackend to imitate login api
$httpBackend
.
expect
GET
(
RESTURL
.
url
+
'login?email=test@test.com&password=password&'
)
$httpBackend
.
expect
POST
(
RESTURL
.
url
+
'login'
,
{
email
:
'test@test.com'
,
password
:
'password'
,
cmd
:
'do'
}
)
// todo: with real api change response data from list to obj
.
respond
(
200
,
[{
'id'
:
1
,
'user'
:
{
...
...
@@ -74,11 +74,11 @@ describe('ulakbus.auth module', function () {
}]);
var
cred
=
{
email
:
'test@test.com'
,
password
:
'password'
};
LoginService
.
login
(
cred
)
LoginService
.
login
(
'login'
,
cred
)
.
then
(
function
(
data
)
{
expect
(
data
).
not
.
toBe
(
null
);
// after login path need to be change dashboard
expect
(
$location
.
path
()).
toBe
(
'/dashboard
'
);
//expect($location.path()).toBe('
');
});
$httpBackend
.
flush
();
...
...
app/components/staff/staff_controller_test.js
View file @
d91e9e9b
...
...
@@ -21,7 +21,7 @@ describe('staff controller module', function () {
describe
(
'staff add controller'
,
function
()
{
it
(
'should get form'
,
function
()
{
var
$scope
=
{};
var
controller
=
$controller
(
'StaffAddCtrl'
,
{
$scope
:
$scope
});
var
controller
=
$controller
(
'StaffAdd
Edit
Ctrl'
,
{
$scope
:
$scope
});
expect
(
$scope
).
not
.
toEqual
(
null
);
});
});
...
...
app/components/version/version_test.js
View file @
d91e9e9b
...
...
@@ -5,7 +5,7 @@ describe('ulakbus.version module', function() {
describe
(
'version service'
,
function
()
{
it
(
'should return current version'
,
inject
(
function
(
version
)
{
expect
(
version
).
toEqual
(
'0.
1
'
);
expect
(
version
).
toEqual
(
'0.
3
'
);
}));
});
});
app/zetalib/forms/form_service.js
View file @
d91e9e9b
...
...
@@ -37,7 +37,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
"title"
:
k
.
title
,
"key"
:
k
.
name
};
scope
.
model
[
k
.
name
]
=
generator
.
dateformatter
(
scope
.
model
[
k
.
name
]);
//
scope.model[k.name] = generator.dateformatter(scope.model[k.name]);
// seek for datepicker field and initialize datepicker
scope
.
$watch
(
angular
.
element
(
$
(
'.datepickerfield'
)),
function
(){
...
...
@@ -83,14 +83,15 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
scope
.
form
.
splice
([
scope
.
form
.
indexOf
(
v
)],
1
);
scope
.
listnodes
=
scope
.
listnodes
?
scope
.
listnodes
:
{};
scope
.
listnodes
[
k
.
title
]
=
(
k
);
scope
.
model
[
k
.
title
]
=
{}
;
scope
.
model
[
k
.
title
]
=
[]
;
}
if
(
k
.
type
==
'Node'
)
{
scope
.
form
.
splice
([
scope
.
form
.
indexOf
(
v
)],
1
);
scope
.
nodes
=
scope
.
nodes
?
scope
.
nodes
:
{};
scope
.
nodes
[
k
.
title
]
=
(
k
);
scope
.
model
[
k
.
title
]
=
{};
// todo: learn what node model will be?
scope
.
model
[
k
.
title
]
=
[];
}
});
...
...
@@ -107,7 +108,7 @@ form_generator.factory('Generator', function ($http, $q, $log, $modal, $timeout,
//angular.forEach(formObject.objects, function(k, v) {
// check if date string and convert to date object
// todo: catch date object and convert
debugger
;
//
debugger;
//});
return
Date
(
formObject
);
};
...
...
@@ -229,7 +230,7 @@ form_generator.directive('addModalForListNode', function ($modal, Generator) {
modalInstance
.
result
.
then
(
function
(
childmodel
,
key
)
{
var
subfix
=
scope
.
schema
.
title
.
replace
(
/
([
a-z
])([
A-Z
])
/g
,
'$1_$2'
).
toLowerCase
();
scope
.
$parent
.
model
[
scope
.
schema
.
title
]
[
subfix
+
'.idx'
]
=
scope
.
model
;
scope
.
$parent
.
model
[
scope
.
schema
.
title
]
.
push
(
scope
.
model
)
;
});
});
}
...
...
app/zetalib/forms/form_service_test.js
View file @
d91e9e9b
...
...
@@ -47,13 +47,35 @@ describe('form service module', function () {
it
(
'should get form'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectGET
(
RESTURL
.
url
+
'student/add?email=test@test.com&'
)
.
respond
(
200
,
[{
form
:
'form'
}]);
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'add_student'
,
{
cmd
:
'add'
})
.
respond
(
200
,
{
forms
:
{
schema
:
{
type
:
"object"
,
properties
:
{
name
:
{
type
:
"string"
,
minLength
:
2
,
title
:
"Name"
,
description
:
"Name or alias"
},
title
:
{
type
:
"string"
,
enum
:
[
'dr'
,
'jr'
,
'sir'
,
'mrs'
,
'mr'
,
'NaN'
,
'dj'
]
}
}
},
var
cred
=
{
email
:
'test@test.com'
};
Generator
.
get_form
(
'student/add'
,
cred
)
form
:
[
"*"
,
{
type
:
"submit"
,
title
:
"Save"
}
],
model
:
{}
}
});
var
cred
=
{
cmd
:
'add'
};
Generator
.
get_form
({
url
:
'add_student'
,
form_params
:
cred
})
.
then
(
function
(
data
)
{
expect
(
data
).
toEqual
({
form
:
'form'
}
);
expect
(
data
.
form
).
toEqual
([
"*"
,
{
type
:
"submit"
,
title
:
"Save"
}]
);
});
$httpBackend
.
flush
();
...
...
@@ -63,13 +85,13 @@ describe('form service module', function () {
it
(
'should post form'
,
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expect
GE
T
(
RESTURL
.
url
+
'student/add'
)
.
respond
(
200
,
[{
data
:
'OK'
}]
);
$httpBackend
.
expect
POS
T
(
RESTURL
.
url
+
'student/add'
)
.
respond
(
200
,
{
data
:
'OK'
}
);
var
cred
=
{
email
:
'test@test.com'
};
Generator
.
submit
(
'student/add'
,
cred
)
Generator
.
submit
(
{
url
:
'student/add'
,
form_params
:
cred
}
)
.
then
(
function
(
data
)
{
expect
(
data
).
toEqual
({
data
:
'OK'
});
expect
(
data
.
data
).
toEqual
({
data
:
'OK'
});
});
$httpBackend
.
flush
();
})
...
...
karma.conf.js
View file @
d91e9e9b
...
...
@@ -13,8 +13,11 @@ module.exports = function (config) {
files
:
[
'app/bower_components/angular/angular.js'
,
'app/bower_components/oclazyload/dist/ocLazyLoad.min.js'
,
'app/bower_components/angular-cookies/angular-cookies.min.js'
,
'app/bower_components/angular-bootstrap/ui-bootstrap.min.js'
,
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js'
,
'app/bower_components/angular-loading-bar/build/loading-bar.min.js'
,
'app/bower_components/angular-gettext/dist/angular-gettext.min.js'
,
'app/bower_components/angular-route/angular-route.js'
,
'app/bower_components/angular-resource/angular-resource.js'
,
'app/bower_components/angular-sanitize/angular-sanitize.min.js'
,
...
...
@@ -33,7 +36,7 @@ module.exports = function (config) {
frameworks
:
[
'jasmine'
],
browsers
:
[
'PhantomJS'
,
'PhantomJS_custom'
],
browsers
:
[
'PhantomJS'
],
customLaunchers
:
{
'PhantomJS_custom'
:
{
...
...
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