mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
159 lines
4.3 KiB
Plaintext
159 lines
4.3 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`refs basic use 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
|
|
let block1 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
const ref1 = (el) => refs[\`div\`] = el;
|
|
return block1([ref1]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`refs can use 2 refs with same name in a t-if/t-else situation 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { multiRefSetter } = helpers;
|
|
|
|
let block5 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
|
let block9 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
const ref1 = multiRefSetter(refs, \`coucou\`);
|
|
let b2,b3,b7;
|
|
b2 = text(\`
|
|
\`);
|
|
if (ctx['state'].value) {
|
|
const b4 = text(\`
|
|
\`);
|
|
const b5 = block5([ref1]);
|
|
const b6 = text(\`
|
|
\`);
|
|
b3 = multi([b4, b5, b6]);
|
|
} else {
|
|
const b8 = text(\`
|
|
\`);
|
|
const b9 = block9([ref1]);
|
|
const b10 = text(\`
|
|
\`);
|
|
b7 = multi([b8, b9, b10]);
|
|
}
|
|
return multi([b2, b3, b7]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`refs refs and recursive templates 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
const comp1 = app.createComponent(\`Test\`, true, false, false, false);
|
|
|
|
let block3 = createBlock(\`<p block-ref=\\"0\\">
|
|
<block-text-1/>
|
|
<block-child-0/>
|
|
</p>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
const ref1 = (el) => refs[\`root\`] = el;
|
|
const b2 = text(\`
|
|
\`);
|
|
let b4;
|
|
let txt1 = ctx['props'].tree.value;
|
|
if (ctx['props'].tree.child) {
|
|
b4 = comp1({tree: ctx['props'].tree.child}, key + \`__1\`, node, this, null);
|
|
}
|
|
const b3 = block3([ref1, txt1], [b4]);
|
|
return multi([b2, b3]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`refs refs are properly bound in slots 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { capture, markRaw } = helpers;
|
|
const comp1 = app.createComponent(\`Dialog\`, true, true, false, true);
|
|
|
|
let block3 = createBlock(\`<div>
|
|
<span class=\\"counter\\"><block-text-0/></span>
|
|
<block-child-0/>
|
|
</div>\`);
|
|
let block4 = createBlock(\`<button block-handler-0=\\"click\\" block-ref=\\"1\\">do something</button>\`);
|
|
|
|
function slot1(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
const ref1 = (el) => refs[\`myButton\`] = el;
|
|
let hdlr1 = [ctx['doSomething'], ctx];
|
|
return block4([hdlr1, ref1]);
|
|
}
|
|
|
|
function slot2(ctx, node, key = \\"\\") {
|
|
const b6 = text(\`
|
|
\`);
|
|
const b7 = text(\`
|
|
\`);
|
|
return multi([b6, b7]);
|
|
}
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = text(\`
|
|
\`);
|
|
let txt1 = ctx['state'].val;
|
|
const ctx1 = capture(ctx);
|
|
const b8 = comp1({slots: markRaw({'footer': {__render: slot1, __ctx: ctx1}, 'default': {__render: slot2, __ctx: ctx1}})}, key + \`__1\`, node, this, null);
|
|
const b3 = block3([txt1], [b8]);
|
|
const b9 = text(\`
|
|
\`);
|
|
return multi([b2, b3, b9]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`refs refs are properly bound in slots 2`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { callSlot } = helpers;
|
|
|
|
let block1 = createBlock(\`<span><block-child-0/></span>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const b2 = callSlot(ctx, node, key, 'footer', false, {});
|
|
return block1([], [b2]);
|
|
}
|
|
}"
|
|
`;
|
|
|
|
exports[`refs throws if there are 2 same refs at the same time 1`] = `
|
|
"function anonymous(app, bdom, helpers
|
|
) {
|
|
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
|
|
let { multiRefSetter } = helpers;
|
|
|
|
let block3 = createBlock(\`<div block-ref=\\"0\\"/>\`);
|
|
let block5 = createBlock(\`<span block-ref=\\"0\\"/>\`);
|
|
|
|
return function template(ctx, node, key = \\"\\") {
|
|
const refs = ctx.__owl__.refs;
|
|
const ref1 = multiRefSetter(refs, \`coucou\`);
|
|
const b2 = text(\`
|
|
\`);
|
|
const b3 = block3([ref1]);
|
|
const b4 = text(\`
|
|
\`);
|
|
const b5 = block5([ref1]);
|
|
return multi([b2, b3, b4, b5]);
|
|
}
|
|
}"
|
|
`;
|