[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:
Géry Debongnie
2021-12-20 11:19:59 +01:00
committed by Aaron Bohy
parent ddc358f48a
commit 7eaecac0b5
48 changed files with 4157 additions and 3279 deletions
+222 -222
View File
@@ -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']);
}
}"
`;