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
f2347c37
Commit
f2347c37
authored
Dec 10, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test coverage todos
parent
673c9fb0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
17 deletions
+71
-17
crud_controller_test.js
app/components/crud/crud_controller_test.js
+42
-8
form_service_test.js
app/zetalib/form_service_test.js
+29
-9
No files found.
app/components/crud/crud_controller_test.js
View file @
f2347c37
...
...
@@ -10,6 +10,7 @@ describe('crud controller module', function () {
beforeEach
(
module
(
'ulakbus'
));
beforeEach
(
module
(
'ulakbus.crud'
));
beforeEach
(
module
(
'formService'
));
beforeEach
(
inject
(
function
(
$injector
)
{
$httpBackend
=
$injector
.
get
(
'$httpBackend'
);
...
...
@@ -37,11 +38,17 @@ describe('crud controller module', function () {
}));
it
(
'should generate params'
,
inject
([
'CrudUtility'
,
function
(
CrudUtility
)
{
var
scope
=
{
'objects'
:
[
[
'test1'
,
'test2'
],
{
'actions'
:
[
{
'show_as'
:
'link'
,
'fields'
:
[
'test1'
]},
{
'show_as'
:
'link'
,
'fields'
:
[
'test2'
]}
]}
]
}
CrudUtility
.
generateParam
({},
{
'test_id'
:
'test'
},
'form'
);
CrudUtility
.
listPageItems
({
'objects'
:
[[],
{
'actions'
:
[{
'show_as'
:
'link'
,
'fields'
:
[
0
,
1
]}]
}]},
{
'test_id'
:
'test'
});
CrudUtility
.
listPageItems
(
scope
,
{
'test_id'
:
'test'
});
expect
(
$controller
).
toBeDefined
();
}]));
...
...
@@ -51,7 +58,7 @@ describe('crud controller module', function () {
var
$scope
=
$rootScope
.
$new
();
var
$routeParams
=
{
cmd
:
'form'
};
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
}));
...
...
@@ -60,8 +67,35 @@ describe('crud controller module', function () {
.
respond
(
200
,
{});
var
$scope
=
$rootScope
.
$new
();
$scope
.
meta
=
{
'allow_filters'
:
true
};
var
$routeParams
=
{
cmd
:
'list'
};
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
$scope
.
$broadcast
(
'reload_cmd'
,
'list'
);
$scope
.
$broadcast
(
'updateObjects'
,
[
'test'
,
'headers'
]);
$scope
.
ListNode
=
{
test
:
{
model
:
[
'test'
,
'data'
],
items
:
[
'test'
,
'data'
]}};
$scope
.
remove
({
title
:
'test'
},
'ListNode'
,
0
);
$scope
.
getNumber
(
3
);
$scope
.
token
=
'1j2j3'
;
$scope
.
resetCmd
();
}));
it
(
'should execute CRUDListFormCtrl with show cmd'
,
inject
(
function
(
$rootScope
,
Generator
)
{
var
$scope
=
$rootScope
.
$new
();
var
$routeParams
=
{
cmd
:
'show'
};
$scope
.
object
=
[];
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
$scope
.
object
=
{
test
:
{}};
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
$scope
.
pageData
=
true
;
Generator
.
setPageData
(
$scope
);
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
}));
...
...
@@ -73,11 +107,11 @@ describe('crud controller module', function () {
$scope
.
form_params
=
{};
$scope
.
reload_cmd
=
'list'
;
var
$routeParams
=
{
cmd
:
'reload'
};
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
var
controller
=
$controller
(
'CRUDListFormCtrl'
,
{
$scope
:
$scope
,
$routeParams
:
$routeParams
});
}));
it
(
'generates crud-filters directive'
,
inject
(
function
(
$rootScope
)
{
it
(
'generates crud-filters directive'
,
inject
(
function
(
$rootScope
)
{
// Compile a piece of HTML containing the directive
var
$scope
=
$rootScope
.
$new
();
$scope
.
form_params
=
{
filters
:
[]};
...
...
app/zetalib/form_service_test.js
View file @
f2347c37
...
...
@@ -76,24 +76,32 @@ describe('form service module', function () {
}])
);
it
(
'should generate function returns when no forms'
,
inject
[
'Generator'
,
function
(
Generator
)
{
var
responseData
=
Generator
.
generate
({
testkey
:
'testvalue'
},
{
form
:{}});
expect
(
responseData
=
{
testkey
:
'testvalue'
});
}]
);
it
(
'should prepare form items'
,
inject
([
'Generator'
,
function
(
Generator
)
{
expect
(
Generator
.
prepareFormItems
).
not
.
toBe
(
null
);
var
scope
=
{
form
:
[
'email'
,
'id'
,
'name'
,
'save'
,
'select'
,
'date'
],
form
:
[
'email'
,
'id'
,
'name'
,
'save'
,
'select'
,
'date'
,
'date2'
,
'text_general'
,
'model'
,
'node'
,
'listnode'
],
schema
:
{
properties
:
{
email
:
{
title
:
'email'
,
type
:
'email'
},
id
:
{
title
:
'id'
,
type
:
'int'
},
name
:
{
title
:
'name'
,
type
:
'string'
},
save
:
{
title
:
'save'
,
type
:
'submit'
},
select
:
{
title
:
'select'
,
type
:
'select'
},
select
:
{
title
:
'select'
,
type
:
'select'
,
key
:
'select'
},
date
:
{
title
:
'date'
,
type
:
'date'
},
date2
:
{
title
:
'date'
,
type
:
'date'
},
text_general
:
{
title
:
'text_general'
,
type
:
'text_general'
},
model
:
{
title
:
'model'
,
type
:
'model'
},
node
:
{
title
:
'Node'
,
type
:
'Node'
},
listnode
:
{
title
:
'ListNode'
,
type
:
'ListNode'
}
listnode
:
{
title
:
'ListNode'
,
type
:
'ListNode'
,
widget
:
'filter_interface'
,
schema
:
[{
'name'
:
'testname'
}]
}
},
required
:
[],
type
:
'object'
,
title
:
'servicetest'
},
model
:
{
...
...
@@ -101,12 +109,13 @@ describe('form service module', function () {
save
:
{
title
:
'save'
,
type
:
'submit'
},
select
:
2
,
date
:
'12.12.2012'
,
date2
:
'abc'
,
text_general
:
'test'
,
model
:
'32gy1ukf3qiryv'
,
node
:
''
,
listnode
:
''
},
form_params
:
{}
form_params
:
{
param
:
'id'
,
param_id
:
'123'
}
};
var
form_json
=
{
...
...
@@ -223,20 +232,23 @@ describe('form service module', function () {
inject
(
function
(
Generator
,
$httpBackend
,
RESTURL
)
{
$httpBackend
.
expectPOST
(
RESTURL
.
url
+
'student/add'
)
.
respond
(
200
,
{
data
:
'OK'
});
.
respond
(
200
,
{
data
:
{
'client_cmd'
:
'list'
,
msgbox
:
'test message'
}
});
var
scope
=
{
ListNode
:
{
key1
:
'val1'
},
Node
:
{
key2
:
'val2'
},
model
:
{
email
:
'test@test.com'
},
form_params
:
{
cmd
:
'add'
,
model
:
'testmodel'
},
token
:
'123456'
,
url
:
'student/add'
url
:
'student/add'
,
wf
:
'test'
};
Generator
.
submit
(
scope
)
Generator
.
submit
(
scope
,
true
)
.
success
(
function
()
{
})
.
then
(
function
(
data
)
{
expect
(
data
.
data
).
toEqual
({
data
:
'OK'
});
.
then
(
function
(
res
)
{
expect
(
res
.
data
).
toEqual
({
'data'
:
{
'client_cmd'
:
'list'
,
msgbox
:
'test message'
}
});
});
$httpBackend
.
flush
();
})
...
...
@@ -351,6 +363,7 @@ describe('form service module', function () {
],
model
:
{}
},
"msgbox"
:
"test message"
,
"token"
:
"da73993f439549e7855fd82deafbbc99"
,
"is_login"
:
true
});
...
...
@@ -417,6 +430,13 @@ describe('form service module', function () {
})
);
it
(
'should return diff array'
,
inject
(
function
(
Generator
)
{
var
diff
=
Generator
.
get_diff_array
([
1
,
2
,
3
],
[
2
]);
expect
(
diff
).
toEqual
([
1
,
3
]);
})
)
});
describe
(
'form service'
,
function
()
{
...
...
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