siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
80 lines (60 loc) • 2.7 kB
JavaScript
StartTest(function(t) {
var finder = new Ariadne.ExtJSComponentQueryFinder()
finder.setExt(Ext)
t.it('Should find basic xtype query', function (t) {
var store = new Ext.data.Store({
fields : [ 'id', 'name' ],
data : [
{ "id" : "id1", "name" : "name1" },
{ "id" : "id2", "name" : "name2" },
{ "id" : "id3", "name" : "name3" }
]
});
var panel = new Ext.panel.Panel({
width : 300,
height : 200,
renderTo : document.body,
items : [
{
xtype : 'combo',
store : store,
displayField : 'name',
valueField : 'id',
queryMode : 'local',
isCombo1 : true
},
{
xtype : 'combo',
store : store,
displayField : 'name',
valueField : 'id',
queryMode : 'local',
isCombo2 : true
}
]
})
var picker1 = Ext.ComponentQuery.query('[isCombo1]')[ 0 ].getPicker()
var queries = finder.findQueries(picker1)
// at this point, there's only one `boundlist` on the page, so just "boundlist" should be enough
// to uniquely identify it, but, if user has clicked the another combobox, there would be 2 boundlists..
// we don't want to rely on the order the fields are clicked, so we want to always identify the
// combobox first, and then - the boundlist within it
t.isDeeply(queries, [ 'combobox:ariadne-nth-child(1) boundlist' ], "Should identify combobox, even that `boundlist` is specific enough")
panel.destroy()
})
t.it('Should find query for button menu item', function (t) {
var button = new Ext.button.Button({
text : 'Button with menu',
itemId : 'button',
renderTo : document.body,
menu : [
{ text : 'Menu item 1' },
{ text : 'Menu item 2' }
]
})
var queries = finder.findQueries(button.menu.items.getAt(1))
// menu is not part of "items" collection of the button, but its still considered a "child"
t.isDeeply(queries, [ '#button menuitem[text=Menu item 2]' ], "Menu item should be counted as child of button component")
button.destroy()
})
})