Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cto
g1
Commits
b367f751
Commit
b367f751
authored
Nov 28, 2019
by
Bharat R
👀
Browse files
test cases for formhandler namespace
parent
1e0d73e2
Changes
1
Show whitespace changes
Inline
Side-by-side
test/test-formhandler-namespace.html
0 → 100644
View file @
b367f751
<!DOCTYPE html>
<html>
<head>
<title>
formhandler tests
</title>
<link
rel=
"stylesheet"
href=
"../node_modules/bootstrap/dist/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
href=
"../node_modules/font-awesome/css/font-awesome.min.css"
>
<style>
.position-relative
{
position
:
relative
;
}
.pos-cc
{
position
:
absolute
;
top
:
45%
;
left
:
45%
;
}
.d-none
{
display
:
none
!important
;
}
</style>
<script
src=
"../node_modules/jquery/dist/jquery.min.js"
></script>
<script
src=
"../node_modules/popper.js/dist/umd/popper.min.js"
></script>
<script
src=
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
></script>
<script
src=
"../node_modules/lodash/lodash.min.js"
></script>
<script
src=
"../node_modules/moment/min/moment.min.js"
></script>
<script
src=
"../node_modules/numeral/min/numeral.min.js"
></script>
<script
src=
"../dist/formhandler.min.js"
></script>
<script
src=
"../dist/scale.min.js"
></script>
<script
src=
"../node_modules/d3/build/d3.js"
></script>
<script
src=
"../node_modules/d3-scale-chromatic/dist/d3-scale-chromatic.js"
></script>
<script
src=
"tape.js"
></script>
<script
src=
"tape-stream.js"
></script>
</head>
<body>
<div
class=
"fh-table"
data-src=
"/formhandler-data"
></div>
<div
class=
"fh13i"
data-src=
"/formhandler-data"
></div>
</body>
<script>
$
(
'
.fh-table
'
).
formhandler
({
pageSize
:
5
,
columns
:
[
{
name
:
'
Continent
'
}
]
})
// WIP: Test for - if namespace is specified, URL should append with namespace
tape
(
'
$().formhandler() if namespace is specified, URL should append with namespace
'
,
function
(
t
)
{
window
.
history
.
pushState
({},
''
,
'
#
'
)
$
(
'
.fh13i
'
).
formhandler
({
namespace
:
'
fhname13i
'
,
pageSize
:
10
,
columns
:
[
{
name
:
'
Continent
'
}
]
}).
one
(
'
load
'
,
function
()
{
$
(
'
body > div.fh13i > div.position-relative > div.formhandler > div.table > table > tbody > tr:nth-child(1) > td > [href="?fhname13i:Continent=Europe&_offset="]
'
).
click
()
})
setTimeout
(
function
()
{
let
tr_list
=
$
(
'
body > div.fh13i > div.position-relative > div.formhandler > div.table > table > tbody > tr > td > [href="?fhname13i:Continent=Europe&_offset="]
'
).
text
().
split
(
"
"
)
// Check all values has only 'Europe' for this table
t
.
ok
(
tr_list
.
every
(
v
=>
v
.
trim
()
===
'
Europe
'
))
// Check filters badges are created for this table
let
_filters
=
$
(
'
body > div.fh13i > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge-dark
'
)
t
.
ok
(
_filters
.
length
>
0
)
t
.
equal
(
_filters
.
text
().
trim
(),
'
Continent = Europe
'
)
t
.
equal
(
g1
.
url
.
parse
(
location
.
href
).
hash
,
'
?fhname13i%3AContinent=Europe
'
)
// Test if the filters are not effected to the other table
t
.
equal
(
$
(
'
body > div.fh-table > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge-dark
'
).
length
,
0
)
t
.
ok
(
$
(
'
body > div.fh13i > div.position-relative > div.formhandler > div.table > table > tbody > tr > td > [href="?fhname13i:Continent=Europe&_offset="]
'
).
text
().
split
(
"
"
).
every
(
v
=>
v
.
trim
()
===
'
Europe
'
))
// Test filter for other functionalities - 'sort'
$
(
'
body > div.fh13i > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge.badge-danger
'
).
click
()
$
(
'
body > div.fh13i > div.position-relative > div.formhandler > div.table > table > thead > tr > th > div.dropdown > div.dropdown-menu > a:nth-child(1)
'
).
click
()
setTimeout
(
function
(){
t
.
equal
(
g1
.
url
.
parse
(
location
.
href
).
hash
,
'
?fhname13i%3A_sort=Continent
'
)
t
.
equal
(
$
(
'
body > div.fh13i > div.position-relative > div.formhandler > div.formhandler-table-header.d-flex.justify-content-between.mb-2 > div:nth-child(2) > div.filters > div > a.badge-dark
'
).
text
().
trim
(),
'
_sort = Continent
'
)
t
.
end
()
},
500
)
},
500
)
})
// End
</script>
</html>
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