2011-03-09 22:12:05 +00:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<script src="http://code.jquery.com/jquery-1.5.1.js"></script>
|
|
|
|
<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css" type="text/css" media="screen"/>
|
|
|
|
<script type="text/javascript" src="http://code.jquery.com/qunit/git/qunit.js"></script>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="qweb.js"></script>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
function trim(s) {
|
|
|
|
return s.replace(/(^\s+|\s+$)/g, '');
|
|
|
|
}
|
|
|
|
function render(template, context) {
|
|
|
|
return trim(QWeb.render(template, context));
|
|
|
|
}
|
|
|
|
$(document).ready(function() {
|
2011-03-10 09:18:56 +00:00
|
|
|
module("Basic output tests", {
|
2011-03-09 22:12:05 +00:00
|
|
|
setup: function () {
|
2011-03-10 09:18:56 +00:00
|
|
|
QWeb.add_template('qweb-test-output.xml');
|
2011-03-09 22:12:05 +00:00
|
|
|
},
|
|
|
|
teardown: function () {
|
|
|
|
QWeb.templates = [];
|
|
|
|
QWeb.tag = {};
|
|
|
|
QWeb.att = {};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-03-10 09:18:56 +00:00
|
|
|
test("Basic escaped output", function () {
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('esc-literal', {}), "ok", "Render a literal string");
|
|
|
|
equals(render('esc-variable', {ok: 'ok'}), "ok", "Render a string variable");
|
|
|
|
equals(render('esc-toescape', {ok: '<ok>'}), "<ok>", "Render a string with data to escape");
|
2011-03-09 22:12:05 +00:00
|
|
|
});
|
2011-03-10 09:18:56 +00:00
|
|
|
test("Formatted escaped output", function () {
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('escf-noformat-literal', {}), "ok", "Render a literal string");
|
|
|
|
equals(render('escf-simpleformat-variable', {value: 'ok'}), "ok",
|
2011-03-10 08:58:36 +00:00
|
|
|
"Only render an interpolated variable");
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('escf-format-variable', {value: 'ok'}), "[ok]",
|
2011-03-10 08:58:36 +00:00
|
|
|
"Actually formatted variable");
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('escf-format-variable-with-escapes', {value: '<ok>'}), '[<ok>]',
|
2011-03-10 08:58:36 +00:00
|
|
|
"Render a formatted string with data to escape");
|
2011-03-10 08:51:38 +00:00
|
|
|
});
|
2011-03-10 09:23:56 +00:00
|
|
|
test("Basic unescaped output", function () {
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('raw-literal', {}), "ok", "Render a literal string");
|
|
|
|
equals(render('raw-variable', {ok: 'ok'}), "ok", "Render a string variable");
|
|
|
|
equals(render('raw-notescaped', {ok: '<ok>'}), "<ok>", "Render a string with data not escaped");
|
2011-03-10 09:23:56 +00:00
|
|
|
});
|
|
|
|
test("Formatted unescaped output", function () {
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('rawf-noformat-literal', {}), "ok", "Render a literal string");
|
|
|
|
equals(render('rawf-simpleformat-variable', {value: 'ok'}), "ok",
|
2011-03-10 09:23:56 +00:00
|
|
|
"Only render an interpolated variable");
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('rawf-format-variable', {value: 'ok'}), "[ok]",
|
2011-03-10 09:23:56 +00:00
|
|
|
"Actually formatted variable");
|
2011-03-10 09:28:28 +00:00
|
|
|
equals(render('rawf-format-variable-notescaped', {value: '<ok>'}), '[<ok>]',
|
2011-03-10 09:23:56 +00:00
|
|
|
"Render a formatted string with data not escaped");
|
|
|
|
});
|
2011-03-09 22:12:05 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h1 id="qunit-header">QUnit example</h1>
|
|
|
|
|
|
|
|
<h2 id="qunit-banner"></h2>
|
|
|
|
|
|
|
|
<div id="qunit-testrunner-toolbar"></div>
|
|
|
|
<h2 id="qunit-userAgent"></h2>
|
|
|
|
<ol id="qunit-tests"></ol>
|
|
|
|
<div id="qunit-fixture">test markup, will be hidden</div>
|
|
|
|
</body>
|
|
|
|
</html>
|