mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
34b781aeed
This means that unrelated ids (eg the id of a template, variable or key) not longer share the same incrementing counter, meaning that you no longer see a variable named "v2" unless another variable "v1" was generated previously, this is also true for block data.
290 lines
7.8 KiB
Plaintext
290 lines
7.8 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`hooks autofocus hook input in a t-if 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><block-child-0/></div>\`);
|
|
let block2 = createBlock(\`<input block-ref=\\"0\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
let b2;
|
|
let d1 = (el) => refs[\`input1\`] = el;
|
|
if (ctx['state'].flag) {
|
|
let d2 = (el) => refs[\`input2\`] = el;
|
|
b2 = block2([d2]);
|
|
}
|
|
return block1([d1], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks autofocus hook simple input 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><input block-ref=\\"0\\"/><input block-ref=\\"1\\"/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
let d1 = (el) => refs[\`input1\`] = el;
|
|
let d2 = (el) => refs[\`input2\`] = el;
|
|
return block1([d1, d2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks can use onWillStart, onWillUpdateProps 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return component(\`MyComponent\`, {value: ctx['state'].value}, key + \`__1\`, node, ctx);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks can use onWillStart, onWillUpdateProps 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['props'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks can use useComponent 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks can use useEnv 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['env'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks mounted callbacks should be called in reverse order from willUnmount callbacks 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div>hey<block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['state'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks parent and child env 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2 = text(ctx['env'].val);
|
|
let b3 = component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks parent and child env 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['env'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks two different call to willPatch/patched should work 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div>hey<block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['state'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks use sub env does not pollute user env 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['env'].val;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks use sub env supports arbitrary descriptor 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return component(\`Child\`, {}, key + \`__1\`, node, ctx);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks use sub env supports arbitrary descriptor 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/> <block-text-1/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['env'].someVal;
|
|
let txt2 = ctx['env'].someVal2;
|
|
return block1([txt1, txt2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks useEffect hook dependencies prevent effects from rerunning when unchanged 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks useEffect hook effect can depend on stuff in dom 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
let b2;
|
|
if (ctx['state'].value) {
|
|
let d1 = (el) => refs[\`div\`] = el;
|
|
b2 = block2([d1]);
|
|
}
|
|
return multi([b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks useEffect hook effect runs on mount, is reapplied on patch, and is cleaned up on unmount and before reapplying 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
return block1();
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks useEffect hook effect with empty dependency list never reruns 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><block-text-0/></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['state'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks useExternalListener 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let b2;
|
|
if (ctx['state'].flag) {
|
|
b2 = component(\`MyComponent\`, {}, key + \`__1\`, node, ctx);
|
|
}
|
|
return multi([b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks useExternalListener 2`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
let txt1 = ctx['props'].value;
|
|
return block1([txt1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`hooks useRef hook: basic use 1`] = `
|
|
"function anonymous(bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div><button block-ref=\\"0\\"><block-text-1/></button></div>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
let d1 = (el) => refs[\`button\`] = el;
|
|
let txt1 = ctx['value'];
|
|
return block1([d1, txt1]);
|
|
}
|
|
}"
|
|
`;
|