mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[REF] tests: improve test helpers
- remove snapshotApp - remove addTemplates - simplify helpers - make sure snapshotted templates are snapshotted with the app config
This commit is contained in:
committed by
Aaron Bohy
parent
ddc358f48a
commit
7eaecac0b5
@@ -1,14 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`error handling cannot add twice the same template 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();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
@@ -154,20 +154,6 @@ exports[`t-on handler is bound to proper owner, part 2 1`] = `
|
||||
|
||||
exports[`t-on handler is bound to proper owner, part 3 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = [ctx['add'], ctx];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on handler is bound to proper owner, part 3 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { getTemplate } = helpers;
|
||||
@@ -179,7 +165,7 @@ exports[`t-on handler is bound to proper owner, part 3 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on handler is bound to proper owner, part 4 1`] = `
|
||||
exports[`t-on handler is bound to proper owner, part 3 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -193,7 +179,7 @@ exports[`t-on handler is bound to proper owner, part 4 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on handler is bound to proper owner, part 4 2`] = `
|
||||
exports[`t-on handler is bound to proper owner, part 4 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -217,6 +203,20 @@ exports[`t-on handler is bound to proper owner, part 4 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on handler is bound to proper owner, part 4 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<button block-handler-0=\\"click\\">Click</button>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = [ctx['add'], ctx];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on receive event in first argument 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
@@ -470,6 +470,22 @@ exports[`t-on t-on with inline statement, part 3 1`] = `
|
||||
|
||||
exports[`t-on t-on with t-call 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`sub\`);
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on t-on with t-call 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
@@ -482,7 +498,7 @@ exports[`t-on t-on with t-call 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on t-on with t-call 2`] = `
|
||||
exports[`t-on t-on, with arguments and t-call 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -498,7 +514,7 @@ exports[`t-on t-on with t-call 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on t-on, with arguments and t-call 1`] = `
|
||||
exports[`t-on t-on, with arguments and t-call 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -512,19 +528,3 @@ exports[`t-on t-on, with arguments and t-call 1`] = `
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-on t-on, with arguments and t-call 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`sub\`);
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -80,53 +80,6 @@ exports[`misc complex template 1`] = `
|
||||
|
||||
exports[`misc global 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<año block-attribute-0=\\"falló\\"><block-child-0/></año>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = 'agüero';
|
||||
let b2 = ctx[zero];
|
||||
return block1([d1], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`misc global 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { withDefault } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = withDefault(ctx['foo'], \`foo default\`);
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`misc global 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { safeOutput, withDefault } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b3 = text(\`toto default\`);
|
||||
let b2 = withDefault(safeOutput(ctx['toto']), b3);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`misc global 4`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { prepareList, isBoundary, withDefault, setContextValue, getTemplate, zero, withKey } = helpers;
|
||||
@@ -177,6 +130,53 @@ exports[`misc global 4`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`misc global 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { withDefault } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = withDefault(ctx['foo'], \`foo default\`);
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`misc global 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<año block-attribute-0=\\"falló\\"><block-child-0/></año>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = 'agüero';
|
||||
let b2 = ctx[zero];
|
||||
return block1([d1], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`misc global 4`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { safeOutput, withDefault } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b3 = text(\`toto default\`);
|
||||
let b2 = withDefault(safeOutput(ctx['toto']), b3);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`misc other complex template 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
@@ -2,19 +2,6 @@
|
||||
|
||||
exports[`t-call (template calling) basic caller 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<span>ok</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) basic caller 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { getTemplate } = helpers;
|
||||
@@ -29,7 +16,7 @@ exports[`t-call (template calling) basic caller 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) basic caller, no parent node 1`] = `
|
||||
exports[`t-call (template calling) basic caller 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -42,7 +29,7 @@ exports[`t-call (template calling) basic caller, no parent node 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) basic caller, no parent node 2`] = `
|
||||
exports[`t-call (template calling) basic caller, no parent node 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -55,22 +42,20 @@ exports[`t-call (template calling) basic caller, no parent node 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) call with several sub nodes on same line 1`] = `
|
||||
exports[`t-call (template calling) basic caller, no parent node 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
let block1 = createBlock(\`<span>ok</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
return block1([], [b2]);
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) call with several sub nodes on same line 2`] = `
|
||||
exports[`t-call (template calling) call with several sub nodes on same line 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -95,13 +80,13 @@ exports[`t-call (template calling) call with several sub nodes on same line 2`]
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 1`] = `
|
||||
exports[`t-call (template calling) call with several sub nodes on same line 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><span>cascade 2</span><block-child-0/></div>\`);
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
@@ -110,30 +95,32 @@ exports[`t-call (template calling) cascading t-call t-out='0' 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 2`] = `
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`finalTemplate\`);
|
||||
const callTemplate_2 = getTemplate(\`subTemplate\`);
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
let block3 = createBlock(\`<span>cascade 1</span>\`);
|
||||
let block3 = createBlock(\`<span>hey</span>\`);
|
||||
let block5 = createBlock(\`<span>yay</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1;
|
||||
let b3 = block3();
|
||||
let b4 = ctx[zero];
|
||||
let b2 = multi([b3, b4]);
|
||||
let b4 = text(\` \`);
|
||||
let b5 = block5();
|
||||
let b2 = multi([b3, b4, b5]);
|
||||
ctx[zero] = b2;
|
||||
let b5 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b5]);
|
||||
let b6 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b6]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 3`] = `
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -156,90 +143,45 @@ exports[`t-call (template calling) cascading t-call t-out='0' 3`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 4`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`subTemplate\`);
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
let block3 = createBlock(\`<span>hey</span>\`);
|
||||
let block5 = createBlock(\`<span>yay</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1;
|
||||
let b3 = block3();
|
||||
let b4 = text(\` \`);
|
||||
let b5 = block5();
|
||||
let b2 = multi([b3, b4, b5]);
|
||||
ctx[zero] = b2;
|
||||
let b6 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b6]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block2 = createBlock(\`<span>cascade 2</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = block2();
|
||||
let b3 = ctx[zero];
|
||||
return multi([b2, b3]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 2`] = `
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`finalTemplate\`);
|
||||
|
||||
let block2 = createBlock(\`<span>cascade 1</span>\`);
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
let block3 = createBlock(\`<span>cascade 1</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1;
|
||||
let b2 = block2();
|
||||
let b3 = ctx[zero];
|
||||
let b1 = multi([b2, b3]);
|
||||
ctx[zero] = b1;
|
||||
return callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
let b3 = block3();
|
||||
let b4 = ctx[zero];
|
||||
let b2 = multi([b3, b4]);
|
||||
ctx[zero] = b2;
|
||||
let b5 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b5]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 3`] = `
|
||||
exports[`t-call (template calling) cascading t-call t-out='0' 4`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`subSubTemplate\`);
|
||||
let { zero } = helpers;
|
||||
|
||||
let block2 = createBlock(\`<span>cascade 0</span>\`);
|
||||
let block1 = createBlock(\`<div><span>cascade 2</span><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1;
|
||||
let b2 = block2();
|
||||
let b3 = ctx[zero];
|
||||
let b1 = multi([b2, b3]);
|
||||
ctx[zero] = b1;
|
||||
return callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
let b2 = ctx[zero];
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 4`] = `
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -262,36 +204,66 @@ exports[`t-call (template calling) cascading t-call t-out='0', without external
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`subSubTemplate\`);
|
||||
|
||||
let block2 = createBlock(\`<span>cascade 0</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1;
|
||||
let b2 = block2();
|
||||
let b3 = ctx[zero];
|
||||
let b1 = multi([b2, b3]);
|
||||
ctx[zero] = b1;
|
||||
return callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`finalTemplate\`);
|
||||
|
||||
let block2 = createBlock(\`<span>cascade 1</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1;
|
||||
let b2 = block2();
|
||||
let b3 = ctx[zero];
|
||||
let b1 = multi([b2, b3]);
|
||||
ctx[zero] = b1;
|
||||
return callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) cascading t-call t-out='0', without external divs 4`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block2 = createBlock(\`<span>cascade 2</span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = block2();
|
||||
let b3 = ctx[zero];
|
||||
return multi([b2, b3]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) dynamic t-call 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<foo><block-text-0/></foo>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx['val'];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) dynamic t-call 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<bar><block-text-0/></bar>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx['val'];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) dynamic t-call 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { call } = helpers;
|
||||
@@ -306,18 +278,35 @@ exports[`t-call (template calling) dynamic t-call 3`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) inherit context 1`] = `
|
||||
exports[`t-call (template calling) dynamic t-call 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<foo><block-text-0/></foo>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return text(ctx['foo']);
|
||||
let d1 = ctx['val'];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) inherit context 2`] = `
|
||||
exports[`t-call (template calling) dynamic t-call 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<bar><block-text-0/></bar>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx['val'];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) inherit context 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -336,6 +325,17 @@ exports[`t-call (template calling) inherit context 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) inherit context 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return text(ctx['foo']);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) recursive template, part 1 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
@@ -525,17 +525,6 @@ exports[`t-call (template calling) recursive template, part 4: with t-set recurs
|
||||
|
||||
exports[`t-call (template calling) scoped parameters 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return text(\`ok\`);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) scoped parameters 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
||||
@@ -557,18 +546,18 @@ exports[`t-call (template calling) scoped parameters 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) scoped parameters, part 2 1`] = `
|
||||
exports[`t-call (template calling) scoped parameters 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return text(ctx['foo']);
|
||||
return text(\`ok\`);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) scoped parameters, part 2 2`] = `
|
||||
exports[`t-call (template calling) scoped parameters, part 2 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -592,6 +581,17 @@ exports[`t-call (template calling) scoped parameters, part 2 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) scoped parameters, part 2 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return text(ctx['foo']);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call allowed on a non t node 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
@@ -623,21 +623,6 @@ exports[`t-call (template calling) t-call allowed on a non t node 2`] = `
|
||||
|
||||
exports[`t-call (template calling) t-call with body content as root of a template 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<foo><block-child-0/></foo>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call with body content as root of a template 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
@@ -655,6 +640,21 @@ exports[`t-call (template calling) t-call with body content as root of a templat
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call with body content as root of a template 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<foo><block-child-0/></foo>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call with t-if 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
@@ -772,6 +772,25 @@ exports[`t-call (template calling) t-call with t-set inside and outside 2`] = `
|
||||
|
||||
exports[`t-call (template calling) t-call with t-set inside and outside. 2 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`main\`);
|
||||
|
||||
let block1 = createBlock(\`<p><block-child-0/></p>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"w\\", 'fromwrapper');
|
||||
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call with t-set inside and outside. 2 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { prepareList, isBoundary, withDefault, setContextValue, getTemplate, withKey } = helpers;
|
||||
@@ -804,7 +823,7 @@ exports[`t-call (template calling) t-call with t-set inside and outside. 2 1`] =
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call with t-set inside and outside. 2 2`] = `
|
||||
exports[`t-call (template calling) t-call with t-set inside and outside. 2 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -820,54 +839,8 @@ exports[`t-call (template calling) t-call with t-set inside and outside. 2 2`] =
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call with t-set inside and outside. 2 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`main\`);
|
||||
|
||||
let block1 = createBlock(\`<p><block-child-0/></p>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"w\\", 'fromwrapper');
|
||||
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call, conditional and t-set in t-call body 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div>callee1</div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call, conditional and t-set in t-call body 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div>callee2 <block-text-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx['v'];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call, conditional and t-set in t-call body 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
||||
@@ -895,6 +868,33 @@ exports[`t-call (template calling) t-call, conditional and t-set in t-call body
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call, conditional and t-set in t-call body 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div>callee1</div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-call, conditional and t-set in t-call body 3`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div>callee2 <block-text-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx['v'];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) t-esc inside t-call, with t-set outside 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
@@ -930,19 +930,6 @@ exports[`t-call (template calling) t-esc inside t-call, with t-set outside 2`] =
|
||||
|
||||
exports[`t-call (template calling) with unused body 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<div>ok</div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with unused body 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
@@ -958,7 +945,7 @@ exports[`t-call (template calling) with unused body 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with unused setbody 1`] = `
|
||||
exports[`t-call (template calling) with unused body 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -971,7 +958,7 @@ exports[`t-call (template calling) with unused setbody 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with unused setbody 2`] = `
|
||||
exports[`t-call (template calling) with unused setbody 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -989,22 +976,20 @@ exports[`t-call (template calling) with unused setbody 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with used body 1`] = `
|
||||
exports[`t-call (template calling) with unused setbody 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<h1><block-text-0/></h1>\`);
|
||||
let block1 = createBlock(\`<div>ok</div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx[zero];
|
||||
return block1([d1]);
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with used body 2`] = `
|
||||
exports[`t-call (template calling) with used body 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -1021,18 +1006,22 @@ exports[`t-call (template calling) with used body 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with used setbody 1`] = `
|
||||
exports[`t-call (template calling) with used body 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<h1><block-text-0/></h1>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return text(ctx['foo']);
|
||||
let d1 = ctx[zero];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with used setbody 2`] = `
|
||||
exports[`t-call (template calling) with used setbody 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -1052,3 +1041,14 @@ exports[`t-call (template calling) with used setbody 2`] = `
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-call (template calling) with used setbody 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return text(ctx['foo']);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -146,21 +146,6 @@ exports[`t-esc t-esc work with spread operator 1`] = `
|
||||
|
||||
exports[`t-esc t-esc=0 is escaped 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx[zero];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-esc t-esc=0 is escaped 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
@@ -180,6 +165,21 @@ exports[`t-esc t-esc=0 is escaped 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-esc t-esc=0 is escaped 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<span><block-text-0/></span>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let d1 = ctx[zero];
|
||||
return block1([d1]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-esc variable 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
@@ -213,24 +213,6 @@ exports[`t-foreach simple iteration with two nodes inside 1`] = `
|
||||
|
||||
exports[`t-foreach t-call with body in t-foreach in t-foreach 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = text(\` [\`);
|
||||
let b3 = text(ctx['a']);
|
||||
let b4 = text(\`] [\`);
|
||||
let b5 = text(ctx['b']);
|
||||
let b6 = text(\`] [\`);
|
||||
let b7 = text(ctx['c']);
|
||||
let b8 = text(\`] \`);
|
||||
return multi([b2, b3, b4, b5, b6, b7, b8]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { prepareList, isBoundary, withDefault, setContextValue, getTemplate, withKey } = helpers;
|
||||
@@ -282,16 +264,12 @@ exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
|
||||
exports[`t-foreach t-call with body in t-foreach in t-foreach 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
||||
let b2 = text(\` [\`);
|
||||
let b3 = text(ctx['a']);
|
||||
let b4 = text(\`] [\`);
|
||||
@@ -304,7 +282,7 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
|
||||
exports[`t-foreach t-call without body in t-foreach in t-foreach 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -351,6 +329,28 @@ exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-foreach t-call without body in t-foreach in t-foreach 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
setContextValue(ctx, \\"c\\", 'x'+'_'+ctx['a']+'_'+ctx['b']);
|
||||
let b2 = text(\` [\`);
|
||||
let b3 = text(ctx['a']);
|
||||
let b4 = text(\`] [\`);
|
||||
let b5 = text(ctx['b']);
|
||||
let b6 = text(\`] [\`);
|
||||
let b7 = text(ctx['c']);
|
||||
let b8 = text(\`] \`);
|
||||
return multi([b2, b3, b4, b5, b6, b7, b8]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-foreach t-foreach in t-foreach 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
@@ -29,22 +29,6 @@ exports[`t-out literal, no outside html element 1`] = `
|
||||
|
||||
exports[`t-out multiple calls to t-out 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/><div>Greeter</div><block-child-1/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
let b3 = ctx[zero];
|
||||
return block1([], [b2, b3]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-out multiple calls to t-out 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
@@ -64,6 +48,22 @@ exports[`t-out multiple calls to t-out 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-out multiple calls to t-out 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/><div>Greeter</div><block-child-1/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
let b3 = ctx[zero];
|
||||
return block1([], [b2, b3]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-out not escaping 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
@@ -81,21 +81,6 @@ exports[`t-out not escaping 1`] = `
|
||||
|
||||
exports[`t-out t-out 0 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-out t-out 0 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, zero, getTemplate } = helpers;
|
||||
@@ -115,6 +100,21 @@ exports[`t-out t-out 0 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-out t-out 0 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { zero } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-child-0/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = ctx[zero];
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-out t-out and another sibling node 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
@@ -185,25 +185,6 @@ exports[`t-set t-set body is evaluated immediately 1`] = `
|
||||
|
||||
exports[`t-set t-set can't alter from within callee 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let d1 = ctx['iter'];
|
||||
setContextValue(ctx, \\"iter\\", 'called');
|
||||
let d2 = ctx['iter'];
|
||||
return block1([d1, d2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-set t-set can't alter from within callee 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue, getTemplate } = helpers;
|
||||
@@ -223,7 +204,7 @@ exports[`t-set t-set can't alter from within callee 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-set t-set can't alter in t-call body 1`] = `
|
||||
exports[`t-set t-set can't alter from within callee 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -242,7 +223,7 @@ exports[`t-set t-set can't alter in t-call body 1`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-set t-set can't alter in t-call body 2`] = `
|
||||
exports[`t-set t-set can't alter in t-call body 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
@@ -267,6 +248,25 @@ exports[`t-set t-set can't alter in t-call body 2`] = `
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-set t-set can't alter in t-call body 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { isBoundary, withDefault, setContextValue } = helpers;
|
||||
|
||||
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
ctx = Object.create(ctx);
|
||||
ctx[isBoundary] = 1
|
||||
let d1 = ctx['iter'];
|
||||
setContextValue(ctx, \\"iter\\", 'called');
|
||||
let d2 = ctx['iter'];
|
||||
return block1([d1, d2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`t-set t-set does not modify render context existing key values 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
|
||||
@@ -30,14 +30,14 @@ exports[`loading templates can load a few templates from a xml string 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`items\`);
|
||||
|
||||
let block2 = createBlock(\`<li>ok</li>\`);
|
||||
let block3 = createBlock(\`<li>foo</li>\`);
|
||||
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = block2();
|
||||
let b3 = block3();
|
||||
return multi([b2, b3]);
|
||||
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
@@ -47,16 +47,35 @@ exports[`loading templates can load a few templates from a xml string 2`] = `
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<ul/>\`);
|
||||
let block2 = createBlock(\`<li>ok</li>\`);
|
||||
let block3 = createBlock(\`<li>foo</li>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
let b2 = block2();
|
||||
let b3 = block3();
|
||||
return multi([b2, b3]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`loading templates can load a few templates from an XMLDocument 1`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
let { getTemplate } = helpers;
|
||||
const callTemplate_2 = getTemplate(\`items\`);
|
||||
|
||||
let block1 = createBlock(\`<ul><block-child-0/></ul>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
let b2 = callTemplate_2.call(this, ctx, node, key + \`__1\`);
|
||||
return block1([], [b2]);
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`loading templates can load a few templates from an XMLDocument 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
@@ -70,16 +89,3 @@ exports[`loading templates can load a few templates from an XMLDocument 1`] = `
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`loading templates can load a few templates from an XMLDocument 2`] = `
|
||||
"function anonymous(bdom, helpers
|
||||
) {
|
||||
let { text, createBlock, list, multi, html, toggler, component, comment } = bdom;
|
||||
|
||||
let block1 = createBlock(\`<ul/>\`);
|
||||
|
||||
return function template(ctx, node, key = \\"\\") {
|
||||
return block1();
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { xml } from "../../src";
|
||||
import { mount, patch } from "../../src/blockdom";
|
||||
import { makeTestFixture, renderToBdom, renderToString, snapshotEverything } from "../helpers";
|
||||
|
||||
@@ -348,9 +347,8 @@ describe("special cases for some specific html attributes/properties", () => {
|
||||
});
|
||||
|
||||
test("various boolean html attributes", () => {
|
||||
// the unique assertion here is the code snapshot automatically done by
|
||||
// renderToString
|
||||
xml`
|
||||
// will cause the template to be snapshotted
|
||||
renderToString(`
|
||||
<div>
|
||||
<input type="checkbox" checked="checked"/>
|
||||
<input checked="checked"/>
|
||||
@@ -360,7 +358,7 @@ describe("special cases for some specific html attributes/properties", () => {
|
||||
<input readonly="readonly"/>
|
||||
<button disabled="disabled"/>
|
||||
</div>
|
||||
`;
|
||||
`);
|
||||
});
|
||||
|
||||
test("input with t-att-value", () => {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { xml } from "../../src";
|
||||
import { renderToString, snapshotEverything, TestContext, trim } from "../helpers";
|
||||
import {
|
||||
renderToString,
|
||||
snapshotEverything,
|
||||
snapshotTemplate,
|
||||
TestContext,
|
||||
trim,
|
||||
} from "../helpers";
|
||||
|
||||
snapshotEverything();
|
||||
|
||||
@@ -116,7 +121,7 @@ describe("misc", () => {
|
||||
});
|
||||
|
||||
test("other complex template", () => {
|
||||
xml`
|
||||
snapshotTemplate(`
|
||||
<div>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-md navbar-light bg-light">
|
||||
@@ -257,6 +262,6 @@ describe("misc", () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
</div>`);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { renderToString, snapshotTemplateCode } from "../helpers";
|
||||
import { renderToString, snapshotTemplate } from "../helpers";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// debugging
|
||||
@@ -9,7 +9,7 @@ describe("debugging", () => {
|
||||
const consoleLog = console.log;
|
||||
console.log = jest.fn();
|
||||
const template = `<div t-debug=""><t t-if="true"><span t-debug="">hey</span></t></div>`;
|
||||
snapshotTemplateCode(template);
|
||||
snapshotTemplate(template);
|
||||
expect(console.log).toHaveBeenCalledTimes(1);
|
||||
console.log = consoleLog;
|
||||
});
|
||||
@@ -18,9 +18,9 @@ describe("debugging", () => {
|
||||
const consoleLog = console.log;
|
||||
console.log = jest.fn();
|
||||
let template = `<p t-debug="">coucou</p>`;
|
||||
snapshotTemplateCode(template);
|
||||
snapshotTemplate(template);
|
||||
template = `<div><t t-call="sub"/></div>`;
|
||||
snapshotTemplateCode(template);
|
||||
snapshotTemplate(template);
|
||||
expect(console.log).toHaveBeenCalledTimes(1);
|
||||
console.log = consoleLog;
|
||||
});
|
||||
@@ -33,7 +33,7 @@ describe("debugging", () => {
|
||||
<t t-set="foo" t-value="42"/>
|
||||
<t t-log="foo + 3"/>
|
||||
</div>`;
|
||||
snapshotTemplateCode(template);
|
||||
snapshotTemplate(template);
|
||||
renderToString(template);
|
||||
expect(console.log).toHaveBeenCalledWith(45);
|
||||
console.log = consoleLog;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { App, Component } from "../../src";
|
||||
import { makeTestFixture, snapshotApp } from "../helpers";
|
||||
import { Component, mount } from "../../src";
|
||||
import { makeTestFixture, snapshotEverything } from "../helpers";
|
||||
import { xml } from "../../src/tags";
|
||||
|
||||
let fixture: HTMLElement;
|
||||
|
||||
snapshotEverything();
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = makeTestFixture();
|
||||
});
|
||||
@@ -14,16 +16,10 @@ describe("translation support", () => {
|
||||
static template = xml`<div>word</div>`;
|
||||
}
|
||||
|
||||
const app = new App(SomeComponent);
|
||||
app.configure({
|
||||
await mount(SomeComponent, fixture, {
|
||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||
});
|
||||
const comp = await app.mount(fixture);
|
||||
|
||||
const el = comp.el as HTMLElement;
|
||||
|
||||
expect(el.outerHTML).toBe("<div>mot</div>");
|
||||
snapshotApp(app);
|
||||
expect(fixture.innerHTML).toBe("<div>mot</div>");
|
||||
});
|
||||
|
||||
test("does not translate node content if disabled", async () => {
|
||||
@@ -36,16 +32,11 @@ describe("translation support", () => {
|
||||
`;
|
||||
}
|
||||
|
||||
const app = new App(SomeComponent);
|
||||
app.configure({
|
||||
await mount(SomeComponent, fixture, {
|
||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||
});
|
||||
const comp = await app.mount(fixture);
|
||||
|
||||
const el = comp.el as HTMLElement;
|
||||
|
||||
expect(el.outerHTML).toBe("<div><span>mot</span><span>word</span></div>");
|
||||
snapshotApp(app);
|
||||
expect(fixture.innerHTML).toBe("<div><span>mot</span><span>word</span></div>");
|
||||
});
|
||||
|
||||
test("some attributes are translated", async () => {
|
||||
@@ -61,18 +52,12 @@ describe("translation support", () => {
|
||||
`;
|
||||
}
|
||||
|
||||
const app = new App(SomeComponent);
|
||||
app.configure({
|
||||
await mount(SomeComponent, fixture, {
|
||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||
});
|
||||
const comp = await app.mount(fixture);
|
||||
|
||||
const el = comp.el as HTMLElement;
|
||||
|
||||
expect(el.outerHTML).toBe(
|
||||
expect(fixture.innerHTML).toBe(
|
||||
'<div><p label="mot">mot</p><p title="mot">mot</p><p placeholder="mot">mot</p><p alt="mot">mot</p><p something="word">mot</p></div>'
|
||||
);
|
||||
snapshotApp(app);
|
||||
});
|
||||
|
||||
test("can set translatable attributes", async () => {
|
||||
@@ -82,16 +67,11 @@ describe("translation support", () => {
|
||||
`;
|
||||
}
|
||||
|
||||
const app = new App(SomeComponent);
|
||||
app.configure({
|
||||
await mount(SomeComponent, fixture, {
|
||||
translateFn: (expr: string) => (expr === "word" ? "mot" : expr),
|
||||
translatableAttributes: ["potato"],
|
||||
});
|
||||
const comp = await app.mount(fixture);
|
||||
|
||||
const el = comp.el as HTMLElement;
|
||||
expect(el.outerHTML).toBe('<div tomato="word" potato="mot" title="word">text</div>');
|
||||
snapshotApp(app);
|
||||
expect(fixture.innerHTML).toBe('<div tomato="word" potato="mot" title="word">text</div>');
|
||||
});
|
||||
|
||||
test("translation is done on the trimmed text, with extra spaces readded after", async () => {
|
||||
@@ -103,14 +83,8 @@ describe("translation support", () => {
|
||||
|
||||
const translateFn = jest.fn((expr: string) => (expr === "word" ? "mot" : expr));
|
||||
|
||||
const app = new App(SomeComponent);
|
||||
app.configure({ translateFn });
|
||||
const comp = await app.mount(fixture);
|
||||
|
||||
const el = comp.el as HTMLElement;
|
||||
|
||||
expect(el.outerHTML).toBe("<div> mot </div>");
|
||||
await mount(SomeComponent, fixture, { translateFn });
|
||||
expect(fixture.innerHTML).toBe("<div> mot </div>");
|
||||
expect(translateFn).toHaveBeenCalledWith("word");
|
||||
snapshotApp(app);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { TemplateSet } from "../../src/app/template_set";
|
||||
import { renderToString, TestContext, compile } from "../helpers";
|
||||
import { renderToString, snapshotTemplate, TestContext } from "../helpers";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// basic validation
|
||||
@@ -21,7 +21,7 @@ describe("basic validation", () => {
|
||||
|
||||
test("invalid xml", () => {
|
||||
const template = "<div>";
|
||||
expect(() => compile(template)).toThrow("Invalid XML in template");
|
||||
expect(() => snapshotTemplate(template)).toThrow("Invalid XML in template");
|
||||
});
|
||||
|
||||
test("missing template in template set", () => {
|
||||
|
||||
Reference in New Issue
Block a user