odoo/addons/base/static/qweb/qweb-test.js.html

72 lines
3.1 KiB
HTML
Raw Normal View History

<!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() {
module("Basic output tests", {
setup: function () {
QWeb.add_template('qweb-test-output.xml');
},
teardown: function () {
QWeb.templates = [];
QWeb.tag = {};
QWeb.att = {};
}
});
test("Basic escaped output", function () {
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>'}), "&lt;ok&gt;", "Render a string with data to escape");
});
test("Formatted escaped output", function () {
equals(render('escf-noformat-literal', {}), "ok", "Render a literal string");
equals(render('escf-simpleformat-variable', {value: 'ok'}), "ok",
"Only render an interpolated variable");
equals(render('escf-format-variable', {value: 'ok'}), "[ok]",
"Actually formatted variable");
equals(render('escf-format-variable-with-escapes', {value: '<ok>'}), '[&lt;ok&gt;]',
"Render a formatted string with data to escape");
});
test("Basic unescaped output", function () {
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");
});
test("Formatted unescaped output", function () {
equals(render('rawf-noformat-literal', {}), "ok", "Render a literal string");
equals(render('rawf-simpleformat-variable', {value: 'ok'}), "ok",
"Only render an interpolated variable");
equals(render('rawf-format-variable', {value: 'ok'}), "[ok]",
"Actually formatted variable");
equals(render('rawf-format-variable-notescaped', {value: '<ok>'}), '[<ok>]',
"Render a formatted string with data not escaped");
});
});
</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>