Files
owl/tests/__snapshots__/reactivity.test.ts.snap
T

396 lines
13 KiB
Plaintext
Raw Normal View History

2021-11-02 13:53:44 +01:00
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Reactivity: useState concurrent renderings 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
let block1 = createBlock(\`<span><block-text-0/><block-text-1/></span>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['context'][ctx['props'].key].n;
let d2 = ctx['state'].x;
return block1([d1, d2]);
}
}"
`;
exports[`Reactivity: useState concurrent renderings 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
let block1 = createBlock(\`<p><block-child-0/></p>\`);
return function template(ctx, node, key = \\"\\") {
let b2 = component(\`ComponentC\`, {key: ctx['props'].key}, key + \`__1\`, node, ctx);
return block1([], [b2]);
}
}"
`;
exports[`Reactivity: useState concurrent renderings 3`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2 = component(\`ComponentB\`, {key: ctx['context'].key}, key + \`__1\`, node, ctx);
return block1([], [b2]);
}
}"
`;
2021-11-02 13:53:44 +01:00
exports[`Reactivity: useState destroyed component before being mounted is inactive 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2;
if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, this, null);
2021-11-02 13:53:44 +01:00
}
return block1([], [b2]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState destroyed component before being mounted is inactive 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].a;
return block1([txt1]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState destroyed component is inactive 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2;
if (ctx['state'].flag) {
b2 = comp1({}, key + \`__1\`, node, this, null);
2021-11-02 13:53:44 +01:00
}
return block1([], [b2]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState destroyed component is inactive 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-12-20 11:19:59 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].a;
return block1([txt1]);
2021-12-20 11:19:59 +01:00
}
}"
`;
2021-11-02 13:53:44 +01:00
exports[`Reactivity: useState one components can subscribe twice to same context 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-text-0/><block-text-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj1'].a;
let txt2 = ctx['contextObj2'].b;
return block1([txt1, txt2]);
2021-11-02 13:53:44 +01:00
}
}"
`;
exports[`Reactivity: useState parent and children subscribed to same context 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
2021-11-02 13:53:44 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-child-0/><block-text-0/></div>\`);
2021-11-02 13:53:44 +01:00
return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, this, null);
let txt1 = ctx['contextObj'].b;
return block1([txt1], [b2]);
2021-11-02 13:53:44 +01:00
}
}"
`;
exports[`Reactivity: useState parent and children subscribed to same context 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
2021-11-02 13:53:44 +01:00
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].a;
return block1([txt1]);
2021-11-02 13:53:44 +01:00
}
}"
`;
exports[`Reactivity: useState several nodes on different level use same context 1`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
2021-11-15 15:01:56 +01:00
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-text-0/> <block-text-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['contextObj'].a;
let d2 = ctx['contextObj'].b;
return block1([d1, d2]);
}
}"
`;
exports[`Reactivity: useState several nodes on different level use same context 2`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
2021-11-15 15:01:56 +01:00
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['contextObj'].b;
return block1([d1]);
}
}"
`;
exports[`Reactivity: useState several nodes on different level use same context 3`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
2021-11-15 15:01:56 +01:00
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-text-0/><block-child-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let d1 = ctx['contextObj'].a;
let b2 = component(\`L3A\`, {}, key + \`__1\`, node, ctx);
return block1([d1], [b2]);
}
}"
`;
exports[`Reactivity: useState several nodes on different level use same context 4`] = `
"function anonymous(bdom, helpers
) {
let { text, createBlock, list, multi, html, toggler, component } = bdom;
2021-11-15 15:01:56 +01:00
let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber, safeOutput } = helpers;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
let b2 = component(\`L2A\`, {}, key + \`__1\`, node, ctx);
let b3 = component(\`L2B\`, {}, key + \`__2\`, node, ctx);
return block1([], [b2, b3]);
}
}"
`;
exports[`Reactivity: useState two components are updated in parallel 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
const comp2 = app.createComponent(\`Child\`, true, false, false, true);
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, this, null);
2021-11-02 13:53:44 +01:00
return block1([], [b2, b3]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState two components are updated in parallel 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].value;
return block1([txt1]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState two components can subscribe to same context 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
const comp2 = app.createComponent(\`Child\`, true, false, false, true);
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, this, null);
2021-11-02 13:53:44 +01:00
return block1([], [b2, b3]);
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState two components can subscribe to same context 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].value;
return block1([txt1]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState two independent components on different levels are updated in parallel 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
const comp2 = app.createComponent(\`Parent\`, true, false, false, true);
2021-11-02 13:53:44 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-child-0/><block-child-1/></div>\`);
2021-11-02 13:53:44 +01:00
return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, this, null);
const b3 = comp2({}, key + \`__2\`, node, this, null);
2021-12-20 11:19:59 +01:00
return block1([], [b2, b3]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState two independent components on different levels are updated in parallel 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<span><block-text-0/></span>\`);
2021-11-02 13:53:44 +01:00
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].value;
return block1([txt1]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState two independent components on different levels are updated in parallel 3`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
const comp1 = app.createComponent(\`Child\`, true, false, false, true);
2021-11-02 13:53:44 +01:00
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-child-0/></div>\`);
2021-11-02 13:53:44 +01:00
return function template(ctx, node, key = \\"\\") {
const b2 = comp1({}, key + \`__1\`, node, this, null);
2021-12-20 11:19:59 +01:00
return block1([], [b2]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState useContext=useState hook is reactive, for one component 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].value;
return block1([txt1]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState useless atoms should be deleted 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
let { prepareList, withKey } = helpers;
const comp1 = app.createComponent(\`Quantity\`, true, false, false, false);
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-child-0/> Total: <block-text-0/> Count: <block-text-1/></div>\`);
return function template(ctx, node, key = \\"\\") {
ctx = Object.create(ctx);
const [k_block2, v_block2, l_block2, c_block2] = prepareList(Object.keys(ctx['state']));;
2021-11-02 13:53:44 +01:00
for (let i1 = 0; i1 < l_block2; i1++) {
ctx[\`id\`] = v_block2[i1];
const key1 = ctx['id'];
c_block2[i1] = withKey(comp1({id: ctx['id']}, key + \`__1__\${key1}\`, node, this, null), key1);
2021-11-02 13:53:44 +01:00
}
ctx = ctx.__proto__;
const b2 = list(c_block2);
let txt1 = ctx['total'];
let txt2 = Object.keys(ctx['state']).length;
return block1([txt1, txt2], [b2]);
2021-11-02 13:53:44 +01:00
}
}"
`;
2021-12-20 11:19:59 +01:00
exports[`Reactivity: useState useless atoms should be deleted 2`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-12-20 11:19:59 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-12-20 11:19:59 +01:00
let block1 = createBlock(\`<div><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['state'].quantity;
return block1([txt1]);
2021-12-20 11:19:59 +01:00
}
}"
`;
2021-11-02 13:53:44 +01:00
exports[`Reactivity: useState very simple use, with initial value 1`] = `
2022-05-26 15:09:09 +02:00
"function anonymous(app, bdom, helpers
2021-11-02 13:53:44 +01:00
) {
let { text, createBlock, list, multi, html, toggler, comment } = bdom;
2021-11-02 13:53:44 +01:00
let block1 = createBlock(\`<div><block-text-0/></div>\`);
return function template(ctx, node, key = \\"\\") {
let txt1 = ctx['contextObj'].value;
return block1([txt1]);
2021-11-02 13:53:44 +01:00
}
}"
`;