mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
committed by
Géry Debongnie
parent
e4a0277f68
commit
ba32772a92
@@ -0,0 +1,24 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`memory t-foreach does not leak stuff in global scope 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
||||
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<p><block-child-0/></p>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
const [k_block2, v_block2, l_block2, c_block2] = prepareList([3,2,1]);
|
||||
for (let i1 = 0; i1 < l_block2; i1++) {
|
||||
ctx[\`item\`] = v_block2[i1];
|
||||
ctx[\`item_index\`] = i1;
|
||||
let key1 = ctx['item_index'];
|
||||
c_block2[i1] = withKey(text(ctx['item']), key1);
|
||||
}
|
||||
let b2 = list(c_block2);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
@@ -0,0 +1,12 @@
|
||||
import { renderToString, snapshotEverything } from "../helpers";
|
||||
|
||||
snapshotEverything();
|
||||
|
||||
describe("memory", () => {
|
||||
test("t-foreach does not leak stuff in global scope", () => {
|
||||
const initialNumberOfGlobals = Object.keys(window).length;
|
||||
const template = `<p><t t-foreach="[3, 2, 1]" t-as="item" t-key="item_index"><t t-esc="item"/></t></p>`;
|
||||
expect(renderToString(template)).toBe("<p>321</p>");
|
||||
expect(Object.keys(window).length).toBe(initialNumberOfGlobals);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user