Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
renderjs
Commits
fa9b2fa9
Commit
fa9b2fa9
authored
Feb 13, 2013
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic testing for RouteGadget.
parent
a4bdbf28
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
2 deletions
+82
-2
test/renderjs_test.js
test/renderjs_test.js
+36
-0
test/require-renderjs_test.js
test/require-renderjs_test.js
+10
-2
test/route/gadget-one.html
test/route/gadget-one.html
+15
-0
test/route/index.html
test/route/index.html
+21
-0
No files found.
test/renderjs_test.js
View file @
fa9b2fa9
...
...
@@ -19,6 +19,8 @@ function cleanUp () {
counter
=
0
;
first_name
=
''
last_name
=
''
route_changed
=
0
function
parseJSONAndUpdateNameSpace
(
result
)
{
first_name
=
result
[
'
first_name
'
];
last_name
=
result
[
'
last_name
'
];
...
...
@@ -232,5 +234,39 @@ function setupRenderJSTest(){
});
module
(
"
RouteGadget
"
);
test
(
'
RouteGadget
'
,
function
()
{
cleanUp
();
RenderJs
.
addGadget
(
"
qunit-fixture
"
,
"
new_route_add
"
,
"
route/index.html
"
,
""
,
""
);
equal
(
0
,
route_changed
);
stop
();
// we need to wait for all gadgets loading ...
RenderJs
.
bindReady
(
function
()
{
start
();
// initialize route gadget as it's loaded asynchronously
RenderJs
.
RouteGadget
.
route
(
$
(
"
#main-router
"
));
// listen to event and do actual routing
$
.
url
.
onhashchange
(
function
()
{
var
body
=
$
(
"
body
"
);
body
.
route
(
"
go
"
,
$
.
url
.
getPath
())
.
fail
(
function
()
{
alert
(
"
no route
"
);
});
});
$
.
url
.
go
(
'
/gadget-one/
'
);
// give some time so .render finishes, most likely we need some event like .bindReady
// to indicate that respective .render method finishes in generic RenderJs ?
stop
();
setTimeout
(
function
()
{
start
();
// respective gadget .render method must be called and global var changed
equal
(
1
,
route_changed
);
},
1000
);
});
});
};
test/require-renderjs_test.js
View file @
fa9b2fa9
// JavaScript file that is used to load RenderJs depenencies
require
.
config
({
baseUrl
:
"
..
"
,
paths
:
{
route
:
"
lib/route/route
"
,
url
:
"
lib/route/url
"
,
jquery
:
"
lib/jquery/jquery
"
,
renderjs
:
"
renderjs
"
,
},
shim
:
{
"
test/renderjs_test
"
:
[
"
renderjs
"
]
"
test/renderjs_test
"
:
[
"
renderjs
"
],
"
url
"
:
[
"
renderjs
"
],
"
route
"
:
[
"
url
"
]
}
});
require
([
"
require-renderjs
"
,
"
test/renderjs_test
"
],
function
(
domReady
)
{
require
([
"
require-renderjs
"
,
"
test/renderjs_test
"
,
"
url
"
,
"
route
"
],
function
(
domReady
)
{
setupRenderJSTest
();
});
test/route/gadget-one.html
0 → 100644
View file @
fa9b2fa9
<html>
<head></head>
<body>
<script
type=
"text/javascript"
language=
"javascript"
>
//
<!
[
CDATA
[
$
(
document
).
ready
(
function
()
{
gadget
=
RenderJs
.
GadgetIndex
.
getGadgetById
(
"
gadget-one
"
);
gadget
.
render
=
function
(){
route_changed
=
1
;
// so we can test this method was actually called from qunit
};
});
//]]>
</script>
</body>
</html>
test/route/index.html
0 → 100644
View file @
fa9b2fa9
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta
name=
"viewport"
content=
"width=device-width, height=device-height, initial-scale=1"
/>
<meta
http-equiv=
"Content-Type"
content=
"text/html; charset=UTF-8"
/>
</head>
<body>
<div
data-gadget=
""
id=
"main-router"
data-gadget-route=
"[
{"source": "/gadget-one/", "destination": "gadget-one"}]"
>
</div>
<div
id=
"gadget-one"
data-gadget=
"route/gadget-one.html"
></div>
</body>
</html>
\ 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