diff --git a/addons/web/static/lib/qweb/qweb-test-attributes.xml b/addons/web/static/lib/qweb/qweb-test-attributes.xml
index 91317d5194b..d0d22b179dc 100644
--- a/addons/web/static/lib/qweb/qweb-test-attributes.xml
+++ b/addons/web/static/lib/qweb/qweb-test-attributes.xml
@@ -19,4 +19,10 @@
+
+
+
+
+
+
diff --git a/addons/web/static/lib/qweb/qweb-test.js.html b/addons/web/static/lib/qweb/qweb-test.js.html
index 469641a1796..510702e82e5 100644
--- a/addons/web/static/lib/qweb/qweb-test.js.html
+++ b/addons/web/static/lib/qweb/qweb-test.js.html
@@ -1,9 +1,9 @@
-
-
-
+
+
+
@@ -16,9 +16,12 @@
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 = [];
@@ -27,20 +30,23 @@
}
});
- 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>", "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>", "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: ''}), "", "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: ''}), "", "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 = [];
@@ -48,22 +54,25 @@
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 = [];
@@ -71,52 +80,55 @@
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 = [];
@@ -124,28 +136,42 @@
QWeb.att = {};
}
});
- test('Fixed-name attributes', function () {
- equals(render('fixed-literal', {}), '',
+ QUnit.test('Fixed-name attributes', function (assert) {
+ assert.equal(render('fixed-literal', {}), '',
"Fixed name and literal attribute value");
- equals(render('fixed-variable', {value: 'ok'}), '',
+ assert.equal(render('fixed-variable', {value: 'ok'}), '',
"Fixed name and variable attribute value");
});
- test('Tuple-based attributes', function () {
- equals(render('tuple-literal', {}), '',
+ QUnit.test('Tuple-based attributes', function (assert) {
+ assert.equal(render('tuple-literal', {}), '',
"Tuple-based literal attributes");
- equals(render('tuple-variable', {att: ['foo', 'bar']}), '',
+ assert.equal(render('tuple-variable', {att: ['foo', 'bar']}), '',
"Tuple-based variable attributes");
});
- test('Fixed name, formatted value attributes', function () {
- equals(render('format-literal', {}), '',
+ QUnit.test('Fixed name, formatted value attributes', function (assert) {
+ assert.equal(render('format-literal', {}), '',
"Literal format");
- equals(render('format-value', {value:'a'}), '',
+ assert.equal(render('format-value', {value:'a'}), '',
"Valued format");
+ assert.equal(
+ render('format-expression', {value: 5}),
+ '',
+ "Format strings are evaluated expressions");
+ assert.equal(render('format-multiple', {
+ value1: 0,
+ value2: 1,
+ value3: 2,
+ }),
+ '',
+ "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 = [];
@@ -153,32 +179,35 @@
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 = [];
@@ -187,40 +216,43 @@
}
});
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(), '',
+ assert.equal(QWeb.render('repetition-dom-content', {seq:seq}).toLowerCase(), '',
"Repetition of node content via foreach");
- equals(QWeb.render('repetition-self', {seq:seq}).toLowerCase(), '',
+ assert.equal(QWeb.render('repetition-self', {seq:seq}).toLowerCase(), '',
"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 = [];
@@ -229,10 +261,10 @@
}
});
- test("jQuery extend", function () {
- equals(render('jquery-extend', {}), '
',
+ QUnit.test("jQuery extend", function (assert) {
+ assert.equal(render('jquery-extend', {}), '
',
"Extend template with jQuery");
- equals(render('jquery-extend-clone', {}), '',
+ assert.equal(render('jquery-extend-clone', {}), '',
"Clone template");
});
});
@@ -240,13 +272,7 @@
-
-
-
-
-
-
-
-test markup, will be hidden
+
+
diff --git a/addons/web/static/lib/qweb/qweb2.js b/addons/web/static/lib/qweb/qweb2.js
index 78e4fd8b544..c7fa24b8e22 100644
--- a/addons/web/static/lib/qweb/qweb2.js
+++ b/addons/web/static/lib/qweb/qweb2.js
@@ -248,7 +248,6 @@ QWeb2.Engine = (function() {
}
self.add_template(xDoc, callback);
});
- template = this.load_xml(template, callback);
}
var ec = (template.documentElement && template.documentElement.childNodes) || template.childNodes || [];
for (var i = 0; i < ec.length; i++) {