<!doctype html>
<html>
<head>
- <script src="http://code.jquery.com/jquery-1.5.2.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 src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
+ <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.15.0.css" type="text/css" media="screen"/>
+ <script type="text/javascript" src="http://code.jquery.com/qunit/qunit-1.15.0.js"></script>
<script type="text/javascript" src="qweb2.js"></script>
return trim(QWeb.render(template, context)).toLowerCase();
}
$(document).ready(function() {
- module("Basic output tests", {
+ QUnit.module("Basic output tests", {
setup: function () {
- QWeb.add_template('qweb-test-output.xml');
+ QUnit.stop();
+ QWeb.add_template('qweb-test-output.xml', function () {
+ QUnit.start();
+ });
},
teardown: function () {
QWeb.templates = [];
}
});
- 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>'}), "<ok>", "Render a string with data to escape");
+ QUnit.test("Basic escaped output", function (assert) {
+ assert.equal(render('esc-literal', {}), "ok", "Render a literal string");
+ assert.equal(render('esc-variable', {ok: 'ok'}), "ok", "Render a string variable");
+ assert.equal(render('esc-toescape', {ok: '<ok>'}), "<ok>", "Render a 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");
+ QUnit.test("Basic unescaped output", function (assert) {
+ assert.equal(render('raw-literal', {}), "ok", "Render a literal string");
+ assert.equal(render('raw-variable', {ok: 'ok'}), "ok", "Render a string variable");
+ assert.equal(render('raw-notescaped', {ok: '<ok>'}), "<ok>", "Render a string with data not escaped");
});
- module("Context-setting tests", {
+ QUnit.module("Context-setting tests", {
setup: function () {
- QWeb.add_template('qweb-test-set.xml');
+ QUnit.stop();
+ QWeb.add_template('qweb-test-set.xml', function () {
+ QUnit.start();
+ });
},
teardown: function () {
QWeb.templates = [];
QWeb.att = {};
}
});
- test("Set literal value", function () {
- equals(render('set-from-attribute-literal', {}), "ok",
+ QUnit.test("Set literal value", function (assert) {
+ assert.equal(render('set-from-attribute-literal', {}), "ok",
"Set a literal value via @t-value");
- equals(render('set-from-body-literal', {}), "ok",
+ assert.equal(render('set-from-body-literal', {}), "ok",
"Set a literal value via @t-set body");
});
- test("Set value looked up from context", function () {
- equals(render('set-from-attribute-lookup', {value: 'ok'}), "ok",
+ QUnit.test("Set value looked up from context", function (assert) {
+ assert.equal(render('set-from-attribute-lookup', {value: 'ok'}), "ok",
"Set a value looked up in context via @t-value");
- equals(render('set-from-body-lookup', {value: 'ok'}), 'ok',
+ assert.equal(render('set-from-body-lookup', {value: 'ok'}), 'ok',
"Set a value looked up in context via @t-set body and @t-esc");
});
- module("Conditionals", {
+ QUnit.module("Conditionals", {
setup: function () {
- QWeb.add_template('qweb-test-conditionals.xml');
+ QUnit.stop();
+ QWeb.add_template('qweb-test-conditionals.xml', function () {
+ QUnit.start();
+ });
},
teardown: function () {
QWeb.templates = [];
QWeb.att = {};
}
});
- test('Basic (single boolean) conditionals', function () {
- equals(render('literal-conditional', {}), 'ok',
+ QUnit.test('Basic (single boolean) conditionals', function (assert) {
+ assert.equal(render('literal-conditional', {}), 'ok',
"Test on a literal value");
- equals(render('boolean-value-conditional', {value: true}), 'ok',
+ assert.equal(render('boolean-value-conditional', {value: true}), 'ok',
"Test on a truthy variable value");
- equals(render('boolean-value-conditional-false', {value: false}), '',
+ assert.equal(render('boolean-value-conditional-false', {value: false}), '',
"Test on a falsy variable value");
});
- test('Boolean expressions in conditionals', function () {
- equals(render('negify', {}), 'ok',
+ QUnit.test('Boolean expressions in conditionals', function (assert) {
+ assert.equal(render('negify', {}), 'ok',
"Negative");
- equals(render('equality', {}), 'ok',
+ assert.equal(render('equality', {}), 'ok',
"Equality");
- equals(render('difference', {}), 'ok',
+ assert.equal(render('difference', {}), 'ok',
"Difference");
- equals(render('and', {}), 'ok',
+ assert.equal(render('and', {}), 'ok',
"Boolean and");
- equals(render('and-js', {}), 'ok',
+ assert.equal(render('and-js', {}), 'ok',
"Boolean and via manually escaped JS operator");
- equals(render('or', {}), 'ok',
+ assert.equal(render('or', {}), 'ok',
"Boolean or");
- equals(render('or-js', {}), 'ok',
+ assert.equal(render('or-js', {}), 'ok',
"Boolean or using JS operator");
});
- test('Comparison boolean tests in conditionals', function () {
- equals(render('greater', {}), 'ok',
+ QUnit.test('Comparison boolean tests in conditionals', function (assert) {
+ assert.equal(render('greater', {}), 'ok',
"Greater");
- equals(render('greater-js', {}), 'ok',
+ assert.equal(render('greater-js', {}), 'ok',
"Greater, JS operator");
- equals(render('lower', {}), 'ok',
+ assert.equal(render('lower', {}), 'ok',
"Lower");
- equals(render('lower-js', {}), 'ok',
+ assert.equal(render('lower-js', {}), 'ok',
"Lower, JS operator");
- equals(render('greater-or-equal', {}), 'ok',
+ assert.equal(render('greater-or-equal', {}), 'ok',
"Greater or Equal");
- equals(render('greater-or-equal-js', {}), 'ok',
+ assert.equal(render('greater-or-equal-js', {}), 'ok',
"Greater or Equal, JS operator");
- equals(render('lower-or-equal', {}), 'ok',
+ assert.equal(render('lower-or-equal', {}), 'ok',
"Lower or Equal");
- equals(render('lower-or-equal-js', {}), 'ok',
+ assert.equal(render('lower-or-equal-js', {}), 'ok',
"Lower or Equal, JS operator");
});
- module("Attributes manipulation", {
+ QUnit.module("Attributes manipulation", {
setup: function () {
- QWeb.add_template('qweb-test-attributes.xml');
+ QUnit.stop();
+ QWeb.add_template('qweb-test-attributes.xml', function () {
+ QUnit.start();
+ });
},
teardown: function () {
QWeb.templates = [];
QWeb.att = {};
}
});
- test('Fixed-name attributes', function () {
- equals(render('fixed-literal', {}), '<div foo="bar"/>',
+ QUnit.test('Fixed-name attributes', function (assert) {
+ assert.equal(render('fixed-literal', {}), '<div foo="bar"></div>',
"Fixed name and literal attribute value");
- equals(render('fixed-variable', {value: 'ok'}), '<div foo="ok"/>',
+ assert.equal(render('fixed-variable', {value: 'ok'}), '<div foo="ok"></div>',
"Fixed name and variable attribute value");
});
- test('Tuple-based attributes', function () {
- equals(render('tuple-literal', {}), '<div foo="bar"/>',
+ QUnit.test('Tuple-based attributes', function (assert) {
+ assert.equal(render('tuple-literal', {}), '<div foo="bar"></div>',
"Tuple-based literal attributes");
- equals(render('tuple-variable', {att: ['foo', 'bar']}), '<div foo="bar"/>',
+ assert.equal(render('tuple-variable', {att: ['foo', 'bar']}), '<div foo="bar"></div>',
"Tuple-based variable attributes");
});
- test('Fixed name, formatted value attributes', function () {
- equals(render('format-literal', {}), '<div foo="bar"/>',
+ QUnit.test('Fixed name, formatted value attributes', function (assert) {
+ assert.equal(render('format-literal', {}), '<div foo="bar"></div>',
"Literal format");
- equals(render('format-value', {value:'a'}), '<div foo="bar"/>',
+ assert.equal(render('format-value', {value:'a'}), '<div foo="bar"></div>',
"Valued format");
+ assert.equal(
+ render('format-expression', {value: 5}),
+ '<div foo="42"></div>',
+ "Format strings are evaluated expressions");
+ assert.equal(render('format-multiple', {
+ value1: 0,
+ value2: 1,
+ value3: 2,
+ }),
+ '<div foo="a 0 is 1 of 2 ]"></div>',
+ "each format string should be evaluated independently");
});
- module("Template calling (including)", {
+ QUnit.module("Template calling (including)", {
setup: function () {
- QWeb.add_template('qweb-test-call.xml');
+ QUnit.stop();
+ QWeb.add_template('qweb-test-call.xml', function () {
+ QUnit.start();
+ });
},
teardown: function () {
QWeb.templates = [];
QWeb.att = {};
}
});
- test('Trivial call invocation', function () {
- equals(render('basic-caller', {}), 'ok',
+ QUnit.test('Trivial call invocation', function (assert) {
+ assert.equal(render('basic-caller', {}), 'ok',
"Direct call of a second template");
});
- test('Call invocation with body', function () {
- equals(render('with-unused-body', {}), 'ok',
+ QUnit.test('Call invocation with body', function (assert) {
+ assert.equal(render('with-unused-body', {}), 'ok',
"Call of a second template with body unused");
- equals(render('with-unused-setbody', {}), 'ok',
+ assert.equal(render('with-unused-setbody', {}), 'ok',
"Call of a second template with body directives unused");
});
- test('Call invocation with body (used by callee)', function () {
- equals(render('with-used-body', {}), 'ok',
+ QUnit.test('Call invocation with body (used by callee)', function (assert) {
+ assert.equal(render('with-used-body', {}), 'ok',
"Call of a second template with body used");
});
- test('Call invocation with parameters set (in body)', function () {
- equals(render('with-used-setbody', {}), 'ok',
+ QUnit.test('Call invocation with parameters set (in body)', function (assert) {
+ assert.equal(render('with-used-setbody', {}), 'ok',
"Call of a second template with parameters");
});
- test('Call invocation in-context (via import)', function () {
- equals(render('in-context-import', {}), 'ok',
+ QUnit.test('Call invocation in-context (via import)', function (assert) {
+ assert.equal(render('in-context-import', {}), 'ok',
"Call with t-import (calls in current context)");
});
- module("Foreach", {
+ QUnit.module("Foreach", {
setup: function () {
- QWeb.add_template('qweb-test-foreach.xml');
+ QUnit.stop();
+ QWeb.add_template('qweb-test-foreach.xml', function () {
+ QUnit.start();
+ });
},
teardown: function () {
QWeb.templates = [];
}
});
var seq = [4,3,2,1,0];
- test('Basic foreach repetition', function () {
- equals(QWeb.render('repetition-text-content', {seq:seq}), '*****',
+ QUnit.test('Basic foreach repetition', function (assert) {
+ assert.equal(QWeb.render('repetition-text-content', {seq:seq}), '*****',
"Repetition of text content via foreach");
- equals(QWeb.render('repetition-dom-content', {seq:seq}).toLowerCase(), '<b/><b/><b/><b/><b/>',
+ assert.equal(QWeb.render('repetition-dom-content', {seq:seq}).toLowerCase(), '<b></b><b></b><b></b><b></b><b></b>',
"Repetition of node content via foreach");
- equals(QWeb.render('repetition-self', {seq:seq}).toLowerCase(), '<b/><b/><b/><b/><b/>',
+ assert.equal(QWeb.render('repetition-self', {seq:seq}).toLowerCase(), '<b></b><b></b><b></b><b></b><b></b>',
"A node with a foreach repeats itself");
});
- test("Foreach scope content", function () {
- equals(QWeb.render('scope-self', {seq:seq}), '43210',
+ QUnit.test("Foreach scope content", function (assert) {
+ assert.equal(QWeb.render('scope-self', {seq:seq}), '43210',
"each value of the sequence is available via the sequence name");
- equals(QWeb.render('scope-value', {seq:seq}), '43210',
+ assert.equal(QWeb.render('scope-value', {seq:seq}), '43210',
"each value of the sequence is also via the _value");
- equals(QWeb.render('scope-index', {seq:seq}), '01234',
+ assert.equal(QWeb.render('scope-index', {seq:seq}), '01234',
"the current 0-based index is available via _index");
- equals(QWeb.render('scope-first', {seq:seq}), 'true false false false false ',
+ assert.equal(QWeb.render('scope-first', {seq:seq}), 'true false false false false ',
"_first says whether the current item is the first of the sequence");
- equals(QWeb.render('scope-last', {seq:seq}), 'false false false false true ',
+ assert.equal(QWeb.render('scope-last', {seq:seq}), 'false false false false true ',
"_last says whether the current item is the last of the sequence");
- equals(QWeb.render('scope-parity', {seq:seq}), 'even odd even odd even ',
+ assert.equal(QWeb.render('scope-parity', {seq:seq}), 'even odd even odd even ',
"the parity (odd/even) of the current row is available via _parity");
- equals(QWeb.render('scope-size', {seq:seq}), '5 5 5 5 5 ',
+ assert.equal(QWeb.render('scope-size', {seq:seq}), '5 5 5 5 5 ',
"the total length of the sequence is available through _size");
});
- test('Name aliasing via t-as', function () {
- equals(QWeb.render('aliasing', {seq:seq}), '43210',
+ QUnit.test('Name aliasing via t-as', function (assert) {
+ assert.equal(QWeb.render('aliasing', {seq:seq}), '43210',
"the inner value can be re-bound via t-as");
- equals(QWeb.render('loopvars-aliasing', {seq:seq}), 'even odd even odd even ',
+ assert.equal(QWeb.render('loopvars-aliasing', {seq:seq}), 'even odd even odd even ',
"inner loop variables should be rebound as well");
});
- module("Template inheritance tests", {
+ QUnit.module("Template inheritance tests", {
setup: function () {
- QWeb.add_template('qweb-test-extend.xml');
+ QUnit.stop();
+ QWeb.add_template('qweb-test-extend.xml', function () {
+ QUnit.start();
+ });
},
teardown: function () {
QWeb.templates = [];
}
});
- test("jQuery extend", function () {
- equals(render('jquery-extend', {}), '<hr/><ul class="main"><li>1</li><li>2</li><li>3</li></ul><footer><b>[[end]]</b></footer>',
+ QUnit.test("jQuery extend", function (assert) {
+ assert.equal(render('jquery-extend', {}), '<hr/><ul class="main"><li>1</li><li>2</li><li>3</li></ul><footer><b>[[end]]</b></footer>',
"Extend template with jQuery");
- equals(render('jquery-extend-clone', {}), '<ul><li>one</li><li>[[cloned template]]</li></ul>',
+ assert.equal(render('jquery-extend-clone', {}), '<ul><li>one</li><li>[[cloned template]]</li></ul>',
"Clone template");
});
});
</head>
<body>
-<h1 id="qunit-header">QWeb test suite</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>
+ <div id="qunit"></div>
+ <div id="qunit-fixture"></div>
</body>
</html>