mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
277 lines
12 KiB
Plaintext
277 lines
12 KiB
Plaintext
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
|
|
exports[`class and style attributes with t-widget dynamic t-att-style is properly added and updated on widget root el 1`] = `
|
|
"function anonymous(context,extra
|
|
) {
|
|
let utils = this.utils;
|
|
let QWeb = this.constructor;
|
|
let owner = context;
|
|
var h = this.utils.h;
|
|
let c1 = [], p1 = {key:1};
|
|
var vn1 = h('div', p1, c1);
|
|
//WIDGET
|
|
let _2_index = c1.length;
|
|
c1.push(null);
|
|
let def3;
|
|
const _5 = context['state'].style;
|
|
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
|
|
let props4 = {};
|
|
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.vnode && props4 !== w4.__owl__.renderProps) {
|
|
w4.destroy();
|
|
w4 = false
|
|
}
|
|
if (!w4) {
|
|
let widgetKey4 = \`child\`;
|
|
let W4 = context.widgets && context.widgets[widgetKey4] || QWeb.widgets[widgetKey4];
|
|
if (!W4) {throw new Error('Cannot find the definition of widget \\"' + widgetKey4 + '\\"')}
|
|
w4 = new W4(owner, props4);
|
|
context.__owl__.cmap[4] = w4.__owl__.id;
|
|
def3 = w4._prepare();
|
|
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){vn.elm.style = _5}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
|
|
} else {
|
|
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
|
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};w4.el.style=_5;let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
|
|
}
|
|
extra.promises.push(def3);
|
|
return vn1;
|
|
}"
|
|
`;
|
|
|
|
exports[`class and style attributes with t-widget t-att-class is properly added/removed on widget root el 1`] = `
|
|
"function anonymous(context,extra
|
|
) {
|
|
let utils = this.utils;
|
|
let QWeb = this.constructor;
|
|
let owner = context;
|
|
var h = this.utils.h;
|
|
let c1 = [], p1 = {key:1};
|
|
var vn1 = h('div', p1, c1);
|
|
//WIDGET
|
|
let _2_index = c1.length;
|
|
c1.push(null);
|
|
let def3;
|
|
const _5 = {a: context['state'].a,b: context['state'].b};
|
|
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
|
|
let props4 = {};
|
|
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.vnode && props4 !== w4.__owl__.renderProps) {
|
|
w4.destroy();
|
|
w4 = false
|
|
}
|
|
if (!w4) {
|
|
let widgetKey4 = \`child\`;
|
|
let W4 = context.widgets && context.widgets[widgetKey4] || QWeb.widgets[widgetKey4];
|
|
if (!W4) {throw new Error('Cannot find the definition of widget \\"' + widgetKey4 + '\\"')}
|
|
w4 = new W4(owner, props4);
|
|
context.__owl__.cmap[4] = w4.__owl__.id;
|
|
def3 = w4._prepare();
|
|
def3 = def3.then(vnode=>{vnode.data.hook = {create(_, vn){for (let k in _5) {
|
|
if (_5[k]) {
|
|
vn.elm.classList.add(k);
|
|
}
|
|
}}};let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
|
|
} else {
|
|
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
|
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let cl=w4.el.classList;for (let k in _5) {if (_5[k]) {cl.add(k)} else {cl.remove(k)}}let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
|
|
}
|
|
extra.promises.push(def3);
|
|
return vn1;
|
|
}"
|
|
`;
|
|
|
|
exports[`composition sub widgets with some state rendered in a loop 1`] = `
|
|
"function anonymous(context,extra
|
|
) {
|
|
let utils = this.utils;
|
|
let QWeb = this.constructor;
|
|
let owner = context;
|
|
context = Object.create(context);
|
|
var h = this.utils.h;
|
|
let c1 = [], p1 = {key:1};
|
|
var vn1 = h('div', p1, c1);
|
|
var _2 = context['state'].numbers;
|
|
if (!_2) { throw new Error('QWeb error: Invalid loop expression')}
|
|
if (typeof _2 === 'number') { _2 = Array.from(Array(_2).keys())}
|
|
var _3 = _2 instanceof Array ? _2 : Object.keys(_2);
|
|
var _length3 = _3.length;
|
|
var _4 = _2 instanceof Array ? _2 : Object.values(_2);
|
|
for (let i = 0; i < _length3; i++) {
|
|
context.number_first = i === 0;
|
|
context.number_last = i === _length3 - 1;
|
|
context.number_parity = i % 2 === 0 ? 'even' : 'odd';
|
|
context.number_index = i;
|
|
context.number = _3[i];
|
|
context.number_value = _4[i];
|
|
//WIDGET
|
|
let key8 = context['number'];
|
|
let _5_index = c1.length;
|
|
c1.push(null);
|
|
let def6;
|
|
let w7 = key8 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[key8]] : false;
|
|
let props7 = {};
|
|
if (w7 && w7.__owl__.renderPromise && !w7.__owl__.vnode && props7 !== w7.__owl__.renderProps) {
|
|
w7.destroy();
|
|
w7 = false
|
|
}
|
|
if (!w7) {
|
|
let widgetKey7 = \`ChildWidget\`;
|
|
let W7 = context.widgets && context.widgets[widgetKey7] || QWeb.widgets[widgetKey7];
|
|
if (!W7) {throw new Error('Cannot find the definition of widget \\"' + widgetKey7 + '\\"')}
|
|
w7 = new W7(owner, props7);
|
|
context.__owl__.cmap[key8] = w7.__owl__.id;
|
|
def6 = w7._prepare();
|
|
def6 = def6.then(vnode=>{let pvnode=h(vnode.sel, {key: key8, hook: {insert(vn) {let nvn=w7._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w7.destroy();}}});c1[_5_index]=pvnode;w7.__owl__.pvnode = pvnode;});
|
|
} else {
|
|
def6 = w7._updateProps(props7, extra.forceUpdate, extra.patchQueue);
|
|
def6 = def6.then(()=>{if (w7.__owl__.isDestroyed) {return};let pvnode=w7.__owl__.pvnode;c1[_5_index]=pvnode;});
|
|
}
|
|
extra.promises.push(def6);
|
|
}
|
|
return vn1;
|
|
}"
|
|
`;
|
|
|
|
exports[`composition t-widget with dynamic value 1`] = `
|
|
"function anonymous(context,extra
|
|
) {
|
|
let utils = this.utils;
|
|
let QWeb = this.constructor;
|
|
let owner = context;
|
|
var h = this.utils.h;
|
|
let c1 = [], p1 = {key:1};
|
|
var vn1 = h('div', p1, c1);
|
|
//WIDGET
|
|
let _2_index = c1.length;
|
|
c1.push(null);
|
|
let def3;
|
|
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
|
|
let props4 = {};
|
|
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.vnode && props4 !== w4.__owl__.renderProps) {
|
|
w4.destroy();
|
|
w4 = false
|
|
}
|
|
if (!w4) {
|
|
let widgetKey4 = context['state'].widget;
|
|
let W4 = context.widgets && context.widgets[widgetKey4] || QWeb.widgets[widgetKey4];
|
|
if (!W4) {throw new Error('Cannot find the definition of widget \\"' + widgetKey4 + '\\"')}
|
|
w4 = new W4(owner, props4);
|
|
context.__owl__.cmap[4] = w4.__owl__.id;
|
|
def3 = w4._prepare();
|
|
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
|
|
} else {
|
|
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
|
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
|
|
}
|
|
extra.promises.push(def3);
|
|
return vn1;
|
|
}"
|
|
`;
|
|
|
|
exports[`composition t-widget with dynamic value 2 1`] = `
|
|
"function anonymous(context,extra
|
|
) {
|
|
let utils = this.utils;
|
|
let QWeb = this.constructor;
|
|
let owner = context;
|
|
var h = this.utils.h;
|
|
let c1 = [], p1 = {key:1};
|
|
var vn1 = h('div', p1, c1);
|
|
//WIDGET
|
|
let _2_index = c1.length;
|
|
c1.push(null);
|
|
let def3;
|
|
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
|
|
let props4 = {};
|
|
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.vnode && props4 !== w4.__owl__.renderProps) {
|
|
w4.destroy();
|
|
w4 = false
|
|
}
|
|
if (!w4) {
|
|
let widgetKey4 = \`Widget\${context['state'].widget}\`;
|
|
let W4 = context.widgets && context.widgets[widgetKey4] || QWeb.widgets[widgetKey4];
|
|
if (!W4) {throw new Error('Cannot find the definition of widget \\"' + widgetKey4 + '\\"')}
|
|
w4 = new W4(owner, props4);
|
|
context.__owl__.cmap[4] = w4.__owl__.id;
|
|
def3 = w4._prepare();
|
|
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
|
|
} else {
|
|
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
|
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
|
|
}
|
|
extra.promises.push(def3);
|
|
return vn1;
|
|
}"
|
|
`;
|
|
|
|
exports[`random stuff/miscellaneous snapshotting compiled code 1`] = `
|
|
"function anonymous(context,extra
|
|
) {
|
|
let utils = this.utils;
|
|
let QWeb = this.constructor;
|
|
let owner = context;
|
|
var h = this.utils.h;
|
|
let c1 = [], p1 = {key:1};
|
|
var vn1 = h('div', p1, c1);
|
|
//WIDGET
|
|
let key5 = 'somestring';
|
|
let _2_index = c1.length;
|
|
c1.push(null);
|
|
let def3;
|
|
let w4 = key5 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[key5]] : false;
|
|
let props4 = {flag: context['state'].flag};
|
|
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.vnode && props4 !== w4.__owl__.renderProps) {
|
|
w4.destroy();
|
|
w4 = false
|
|
}
|
|
if (!w4) {
|
|
let widgetKey4 = \`child\`;
|
|
let W4 = context.widgets && context.widgets[widgetKey4] || QWeb.widgets[widgetKey4];
|
|
if (!W4) {throw new Error('Cannot find the definition of widget \\"' + widgetKey4 + '\\"')}
|
|
w4 = new W4(owner, props4);
|
|
context.__owl__.cmap[key5] = w4.__owl__.id;
|
|
def3 = w4._prepare();
|
|
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: key5, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
|
|
} else {
|
|
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
|
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
|
|
}
|
|
extra.promises.push(def3);
|
|
return vn1;
|
|
}"
|
|
`;
|
|
|
|
exports[`random stuff/miscellaneous t-props should not be undefined (snapshotting) 1`] = `
|
|
"function anonymous(context,extra
|
|
) {
|
|
let utils = this.utils;
|
|
let QWeb = this.constructor;
|
|
let owner = context;
|
|
var h = this.utils.h;
|
|
let c1 = [], p1 = {key:1};
|
|
var vn1 = h('div', p1, c1);
|
|
//WIDGET
|
|
let _2_index = c1.length;
|
|
c1.push(null);
|
|
let def3;
|
|
let w4 = 4 in context.__owl__.cmap ? context.__owl__.children[context.__owl__.cmap[4]] : false;
|
|
let props4 = {};
|
|
if (w4 && w4.__owl__.renderPromise && !w4.__owl__.vnode && props4 !== w4.__owl__.renderProps) {
|
|
w4.destroy();
|
|
w4 = false
|
|
}
|
|
if (!w4) {
|
|
let widgetKey4 = \`child\`;
|
|
let W4 = context.widgets && context.widgets[widgetKey4] || QWeb.widgets[widgetKey4];
|
|
if (!W4) {throw new Error('Cannot find the definition of widget \\"' + widgetKey4 + '\\"')}
|
|
w4 = new W4(owner, props4);
|
|
context.__owl__.cmap[4] = w4.__owl__.id;
|
|
def3 = w4._prepare();
|
|
def3 = def3.then(vnode=>{let pvnode=h(vnode.sel, {key: 4, hook: {insert(vn) {let nvn=w4._mount(vnode, pvnode.elm);pvnode.elm=nvn.elm;},remove() {},destroy(vn) {w4.destroy();}}});c1[_2_index]=pvnode;w4.__owl__.pvnode = pvnode;});
|
|
} else {
|
|
def3 = w4._updateProps(props4, extra.forceUpdate, extra.patchQueue);
|
|
def3 = def3.then(()=>{if (w4.__owl__.isDestroyed) {return};let pvnode=w4.__owl__.pvnode;c1[_2_index]=pvnode;});
|
|
}
|
|
extra.promises.push(def3);
|
|
return vn1;
|
|
}"
|
|
`;
|