mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
387 lines
12 KiB
Plaintext
387 lines
12 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`t-set evaluate value expression 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`value\`] = 1+2;
|
|
let d1 = ctx['value'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set evaluate value expression, part 2 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`value\`] = ctx['somevariable']+2;
|
|
let d1 = ctx['value'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set set from attribute literal (no outside div) 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`value\`] = 'ok';
|
|
return text(ctx['value']);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set set from attribute literal 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`value\`] = 'ok';
|
|
let d1 = ctx['value'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set set from attribute lookup 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`stuff\`] = ctx['value'];
|
|
let d1 = ctx['stuff'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set set from body literal 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`value\`] = \`ok\`;
|
|
return text(ctx['value']);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set set from body lookup 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
let b2 = text(ctx['value']);
|
|
ctx[\`stuff\`] = b2;
|
|
let d1 = ctx['stuff'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set set from empty body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`stuff\`] = null;
|
|
let d1 = ctx['stuff'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set and t-if 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
let b2;
|
|
ctx[\`v\`] = ctx['value'];
|
|
if (ctx['v']==='ok') {
|
|
b2 = text(\`grimbergen\`);
|
|
}
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set body is evaluated immediately 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`v1\`] = 'before';
|
|
let d1 = ctx['v1'];
|
|
let b2 = block2([d1]);
|
|
ctx[\`v2\`] = b2;
|
|
ctx[\`v1\`] = 'after';
|
|
let b3 = html(ctx['v2']);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set evaluates an expression only once 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`v\`] = ctx['value']+' artois';
|
|
let d1 = ctx['v'];
|
|
let d2 = ctx['v'];
|
|
return block1([d1, d2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set should reuse variable if possible 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block3 = createBlock(\`<div><span>v<block-text-0/></span></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`v\`] = 1;
|
|
ctx = Object.create(ctx);
|
|
const [k2, v2, l2, c2] = prepareList(ctx['list']);
|
|
for (let i1 = 0; i1 < l2; i1++) {
|
|
ctx[\`elem\`] = v2[i1];
|
|
ctx[\`elem_index\`] = i1;
|
|
let key1 = ctx['elem_index'];
|
|
let d1 = ctx['v'];
|
|
ctx[\`v\`] = ctx['elem'];
|
|
c2[i1] = withKey(block3([d1]), key1);
|
|
}
|
|
let b2 = list(c2);
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set with content and sub t-esc 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
let b3 = text(ctx['beep']);
|
|
let b4 = text(\` boop\`);
|
|
let b2 = multi([b3, b4]);
|
|
ctx[\`setvar\`] = b2;
|
|
let d1 = ctx['setvar'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set with t-value (falsy) and body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`v3\`] = false;
|
|
ctx[\`v1\`] = 'before';
|
|
let d1 = ctx['v1'];
|
|
let b2 = block2([d1]);
|
|
ctx[\`v2\`] = withDefault(ctx['v3'], b2);
|
|
ctx[\`v1\`] = 'after';
|
|
ctx[\`v3\`] = true;
|
|
let b3 = html(ctx['v2']);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set with t-value (truthy) and body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`v3\`] = 'Truthy';
|
|
ctx[\`v1\`] = 'before';
|
|
let d1 = ctx['v1'];
|
|
let b2 = block2([d1]);
|
|
ctx[\`v2\`] = withDefault(ctx['v3'], b2);
|
|
ctx[\`v1\`] = 'after';
|
|
ctx[\`v3\`] = false;
|
|
let b3 = html(ctx['v2']);
|
|
return block1([], [b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 1 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
if (ctx['flag']) {
|
|
ctx[\`ourvar\`] = \`1\`;
|
|
} else {
|
|
ctx[\`ourvar\`] = 0;
|
|
}
|
|
let d1 = ctx['ourvar'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 2 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-child-0/><block-child-0/><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
if (ctx['flag']) {
|
|
ctx[\`ourvar\`] = 1;
|
|
} else {
|
|
ctx[\`ourvar\`] = \`0\`;
|
|
}
|
|
let d1 = ctx['ourvar'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set t-set, t-if, and mix of expression/body lookup, 3 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
let b2;
|
|
if (ctx['flag']) {
|
|
ctx[\`ourvar\`] = 1;
|
|
} else {
|
|
ctx[\`ourvar\`] = \`0\`;
|
|
}
|
|
b2 = text(ctx['ourvar']);
|
|
return multi([b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set value priority (with non text body 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
let block2 = createBlock(\`<span>2</span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
let b2 = block2();
|
|
ctx[\`value\`] = withDefault(1, b2);
|
|
let d1 = ctx['value'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`t-set value priority 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component } = bdom;
|
|
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, shallowEqual } = helpers;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
ctx = Object.create(ctx);
|
|
ctx[\`value\`] = withDefault(1, \`2\`);
|
|
let d1 = ctx['value'];
|
|
return block1([d1]);
|
|
}
|
|
}"
|
|
`;
|