siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
65 lines (46 loc) • 1.78 kB
JavaScript
/*
Siesta 5.6.1
Copyright(c) 2009-2022 Bryntum AB
https://bryntum.com/contact
https://bryntum.com/products/siesta/license
*/
Role('Ariadne.ExtJSComponentQueryFinder.Role.ExtJSComponentHelper', {
does : Ariadne.DomQueryFinder.Role.DomHelper,
has : {
},
methods : {
getComponentXType : function (cmp) {
var xtype = this.getComponentOwnXType(cmp)
if (xtype) return xtype
xtype = cmp.getXTypes && cmp.getXTypes()
if (!xtype) return null
xtype = xtype.split('/')
return xtype[ xtype.length - 1 ]
},
// might be not available if component does not define the "alias" property in "widget" namespace
getComponentOwnXType : function (cmp) {
return (cmp.getXType && cmp.getXType()) || cmp.xtype || cmp.xtypes[ 0 ]
},
escapeCQSelector : function (selector) {
return this.escapeDomSelector(selector)
},
// Ext4 breaks when xtype contains dot, even if it is properly escaped
// however [xtype=value\.with\.dots] is supported
// this is why we need this method
getExt4ProofXtype : function (cmp, Ext) {
var xtype = this.getComponentXType(cmp)
var escaped = this.escapeCQSelector(xtype)
var extVersion = Ext.getVersion('ext')
if (extVersion && extVersion.major == 4 && xtype != escaped)
return {
query : '[xtype=' + escaped + ']',
leading : false
}
else
return {
query : escaped,
leading : true
}
}
}
});