Files
owl/tests/components/__snapshots__/refs.test.ts.snap
T

99 lines
3.0 KiB
Plaintext
Raw Normal View History

2020-11-26 16:45:25 +01:00
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`refs basic use 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, 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(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { multiRefSetter } = helpers;
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`);
let block3 = createBlock(\`<span block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs;
const ref1 = multiRefSetter(refs, \`coucou\`);
let b2,b3;
if (ctx['state'].value) {
b2 = block2([ref1]);
} else {
b3 = block3([ref1]);
}
return multi([b2, b3]);
}
}"
`;
2020-11-26 16:45:25 +01:00
exports[`refs refs are properly bound in slots 1`] = `
"function anonymous(bdom, helpers
) {
2021-11-29 13:22:04 +01:00
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { capture } = helpers;
2020-11-26 16:45:25 +01:00
let block1 = createBlock(\`<div><span class=\\"counter\\"><block-text-0/></span><block-child-0/></div>\`);
let block2 = 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 block2([hdlr1, ref1]);
2020-11-26 16:45:25 +01:00
}
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['state'].val;
2021-11-19 13:43:21 +01:00
const ctx1 = capture(ctx);
let b3 = component(\`Dialog\`, {slots: {'footer': {__render: slot1, __ctx: ctx1}}}, key + \`__1\`, node, ctx);
return block1([txt1], [b3]);
2020-11-26 16:45:25 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`refs refs are properly bound in slots 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { callSlot } = helpers;
let block1 = createBlock(\`<span><block-child-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let 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(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
let { multiRefSetter } = helpers;
let block2 = createBlock(\`<div block-ref=\\"0\\"/>\`);
let block3 = createBlock(\`<span block-ref=\\"0\\"/>\`);
return function template(ctx, node, key = \\"\\") {
const refs = ctx.__owl__.refs;
const ref1 = multiRefSetter(refs, \`coucou\`);
let b2 = block2([ref1]);
let b3 = block3([ref1]);
return multi([b2, b3]);
}
}"
`;