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
Klaus Wölfel
renderjs
Commits
99599cba
Commit
99599cba
authored
Feb 06, 2014
by
Thibaut Frain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added jslint tests and qunit tests
parent
403dada0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
192 additions
and
1 deletion
+192
-1
examples/officejs/presentation-editor/Gruntfile.js
examples/officejs/presentation-editor/Gruntfile.js
+36
-0
examples/officejs/presentation-editor/bower.json
examples/officejs/presentation-editor/bower.json
+3
-0
examples/officejs/presentation-editor/package.json
examples/officejs/presentation-editor/package.json
+6
-1
examples/officejs/presentation-editor/test/index.html
examples/officejs/presentation-editor/test/index.html
+28
-0
examples/officejs/presentation-editor/test/presentation-editor-test.js
...cejs/presentation-editor/test/presentation-editor-test.js
+34
-0
examples/officejs/presentation-editor/test/run-qunit.js
examples/officejs/presentation-editor/test/run-qunit.js
+85
-0
No files found.
examples/officejs/presentation-editor/Gruntfile.js
0 → 100644
View file @
99599cba
module
.
exports
=
function
(
grunt
)
{
"
use strict
"
;
// Project configuration.
grunt
.
initConfig
({
pkg
:
grunt
.
file
.
readJSON
(
'
package.json
'
),
jslint
:
{
client
:
{
src
:
[
'
lib/presentation-editor.js
'
],
directives
:
{
browser
:
true
,
maxlen
:
100
,
indent
:
2
,
maxerr
:
3
,
unparam
:
true
,
plusplus
:
true
,
predef
:
[
'
window
'
,
'
document
'
,
'
$
'
,
'
html_beautify
'
]
}
}
}
});
// Load the plugin that provides the "uglify" task.
grunt
.
loadNpmTasks
(
'
grunt-jslint
'
);
// Default task(s).
grunt
.
registerTask
(
'
default
'
,
[
'
jslint
'
]);
};
examples/officejs/presentation-editor/bower.json
View file @
99599cba
...
@@ -18,5 +18,8 @@
...
@@ -18,5 +18,8 @@
"jquery-mobile"
:
"1.4.0"
,
"jquery-mobile"
:
"1.4.0"
,
"jquery-ui"
:
"1.10.3"
,
"jquery-ui"
:
"1.10.3"
,
"js-beautify"
:
"1.4.2"
"js-beautify"
:
"1.4.2"
},
"devDependencies"
:
{
"qunit"
:
"1.14.0"
}
}
}
}
examples/officejs/presentation-editor/package.json
View file @
99599cba
...
@@ -7,5 +7,10 @@
...
@@ -7,5 +7,10 @@
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
},
"author"
:
""
,
"author"
:
""
,
"license"
:
"ISC"
"license"
:
"ISC"
,
"devDependencies"
:
{
"grunt"
:
"0.4.2"
,
"grunt-jslint"
:
"1.1.2"
,
"grunt-contrib-qunit"
:
"0.4.0"
}
}
}
examples/officejs/presentation-editor/test/index.html
0 → 100644
View file @
99599cba
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
Test Presentation Gadget
</title>
<link
rel=
"stylesheet"
href=
"../bower_components/qunit/qunit/qunit.css"
>
<!-- Jquery -->
<script
src=
"../lib/jquery.min.js"
></script>
<!-- Renderjs -->
<script
src=
"../lib/rsvp.min.js"
></script>
<script
src=
"../lib/jschannel.js"
></script>
<script
src=
"../lib/renderjs.js"
></script>
<!-- Qunit tests -->
<script
src=
"../bower_components/qunit/qunit/qunit.js"
></script>
<script
src=
"presentation-editor-test.js"
></script>
</head>
<body>
<div
id=
"qunit"
></div>
<div
id=
"qunit-fixture"
></div>
<div
id=
"test-jqs"
></div>
</body>
</html>
examples/officejs/presentation-editor/test/presentation-editor-test.js
0 → 100644
View file @
99599cba
/*global window, document, QUnit, jQuery, RenderJSGadget*/
(
function
(
$
,
QUnit
,
RenderJSGadget
)
{
"
use strict
"
;
QUnit
.
config
.
testTimeout
=
10000
;
var
asyncTest
=
QUnit
.
asyncTest
,
start
=
QUnit
.
start
,
equal
=
QUnit
.
equal
,
presentationEditorURL
=
'
../index.html
'
;
function
ifr$
(
selector
)
{
return
$
(
'
iframe
'
).
contents
().
find
(
selector
);
}
asyncTest
(
"
[Presentation editor] set title slide (iframed)
"
,
1
,
function
()
{
var
g
=
new
RenderJSGadget
(),
gadgetContext
=
document
.
getElementById
(
'
qunit-fixture
'
);
g
.
declareGadget
(
presentationEditorURL
,
{
sandbox
:
"
iframe
"
,
element
:
gadgetContext
})
.
then
(
function
(
gadget
){
var
content
=
"
<section><h1>TestTitle</h1></section>
"
;
return
gadget
.
setContent
(
content
);
})
.
then
(
function
(){
var
expected
=
ifr$
(
"
#slide-list section h1
"
)[
0
].
textContent
;
equal
(
expected
,
"
TestTitle
"
);
})
.
always
(
start
);
});
}(
jQuery
,
QUnit
,
RenderJSGadget
));
examples/officejs/presentation-editor/test/run-qunit.js
0 → 100644
View file @
99599cba
/*jslint indent: 2, maxlen: 80 */
/*global require, phantom, document, setInterval, clearInterval, console */
(
function
()
{
"
use strict
"
;
var
system
=
require
(
'
system
'
),
page
;
/**
* Wait until the test condition is true or a timeout occurs. Useful for
* waiting on a server response or for a ui change (fadeIn, etc.) to occur.
*
* @method waitFor
* @param {Function} testFx Condition that evaluates to a boolean
* @param {Function} onReady What to do when testFx condition is fulfilled
* @param {Number} time_out_millis The max amount of time to wait.
* If not specified, 10 sec is used.
*/
function
waitFor
(
testFx
,
onReady
,
time_out_millis
)
{
var
maxtime_out_millis
,
start
,
condition
,
interval
;
maxtime_out_millis
=
time_out_millis
||
300000
;
start
=
new
Date
().
getTime
();
condition
=
false
;
interval
=
setInterval
(
function
()
{
if
((
new
Date
().
getTime
()
-
start
<
maxtime_out_millis
)
&&
!
condition
)
{
// If not time-out yet and condition not yet fulfilled
condition
=
testFx
();
}
else
{
if
(
!
condition
)
{
// If condition still not fulfilled (timeout but condition is 'false')
console
.
log
(
"
'waitFor()' timeout
"
);
phantom
.
exit
(
1
);
}
else
{
// Condition fulfilled (timeout and/or condition is 'true')
console
.
log
(
"
'waitFor()' finished in
"
+
(
new
Date
().
getTime
()
-
start
)
+
"
ms.
"
);
onReady
();
clearInterval
(
interval
);
//< Stop this interval
}
}
},
100
);
//< repeat check every 100ms
}
if
(
system
.
args
.
length
!==
2
)
{
console
.
log
(
'
Usage: run-qunit.js URL
'
);
phantom
.
exit
(
1
);
}
page
=
require
(
'
webpage
'
).
create
();
// Route "console.log()" calls from within the Page context to the main
// Phantom context (i.e. current "this")
page
.
onConsoleMessage
=
function
(
msg
)
{
console
.
log
(
msg
);
};
page
.
open
(
system
.
args
[
1
],
function
(
status
)
{
if
(
status
!==
"
success
"
)
{
console
.
log
(
"
Unable to access network
"
);
phantom
.
exit
(
1
);
}
waitFor
(
function
()
{
return
page
.
evaluate
(
function
()
{
var
el
=
document
.
getElementById
(
'
qunit-testresult
'
);
if
(
el
&&
el
.
innerText
.
match
(
'
completed
'
))
{
return
true
;
}
return
false
;
});
},
function
()
{
var
failedNum
=
page
.
evaluate
(
function
()
{
console
.
log
(
"
========================================================
"
);
console
.
log
(
document
.
documentElement
.
innerHTML
);
console
.
log
(
"
========================================================
"
);
var
el
=
document
.
getElementById
(
'
qunit-testresult
'
);
console
.
log
(
el
.
innerText
);
try
{
return
el
.
getElementsByClassName
(
'
failed
'
)[
0
].
innerHTML
;
}
catch
(
ignore
)
{
}
return
10000
;
});
phantom
.
exit
((
parseInt
(
failedNum
,
10
)
>
0
)
?
1
:
0
);
});
});
}());
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