[IMP] qweb: add t-debug and t-log directives

This commit is contained in:
Géry Debongnie
2019-04-29 13:33:46 +02:00
parent 8f388e712e
commit 4a748d2ea4
4 changed files with 121 additions and 10 deletions
+29
View File
@@ -1094,3 +1094,32 @@ describe("t-key", () => {
).toMatchSnapshot();
});
});
describe("debugging", () => {
test("t-debug", () => {
qweb.addTemplate(
"test",
`<div t-debug="1"><t t-if="true"><span t-debug="1">hey</span></t></div>`
);
qweb.render('test');
expect(qweb.templates.test.toString()).toMatchSnapshot();
});
test("t-log", () => {
const consoleLog = console.log;
console.log = jest.fn()
qweb.addTemplate(
"test",
`<div>
<t t-set="foo" t-value="42"/>
<t t-log="foo + 3"/>
</div>`
);
qweb.render('test');
expect(qweb.templates.test.toString()).toMatchSnapshot();
expect(console.log).toHaveBeenCalledWith(45);
console.log = consoleLog;
});
});