UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

95 lines (77 loc) 2.48 kB
StartTest(function (t) { t.it('Move mouse to select field', function (t) { if (!Ext.Viewport) Ext.viewport.Viewport.setup() Ext.Viewport.removeAll(); var selectField = Ext.create({ xtype: 'selectfield', label: 'Choose one', options: [{ text: 'First Option', value: 'first' }, { text: 'Second Option', value: 'second' }, { text: 'Third Option', value: 'third' }] }) Ext.Viewport.add({ xtype : 'container', items : selectField }); t.firesOnce(selectField, 'change') t.chain( { click : '>>selectfield' }, { click : '.x-listitem:contains(Second Option)' }, { waitFor : 1000 } ); }) t.it('Sample', function (t) { if (!Ext.Viewport) Ext.viewport.Viewport.setup() Ext.Viewport.removeAll(); var panel = Ext.create('Ext.Panel', { title: 'Title', items: [ { xtype: 'textfield' } ] }); Ext.Viewport.add(panel); t.chain( { waitForCQVisible: 'panel[title=Title]' }, { click: '>>textfield' } ); }); t.it('Checkbox field', function (t) { if (!Ext.Viewport) Ext.viewport.Viewport.setup() Ext.Viewport.removeAll(); Ext.Viewport.add({ xtype: 'formpanel', items: [ { xtype: 'checkboxfield', name: 'tomato', label: 'Tomato', value: 'tomato', checked: true }, { xtype: 'togglefield', label: 'Toggle' } ] }); t.is(t.cq1('checkboxfield').isChecked(), true, "Checkbox is checked") t.is(t.cq1('togglefield').getValue(), false, "Togglefield is unchecked") t.chain( { click: '>> togglefield' }, { click: '>> field[label=Tomato]' }, function () { t.is(t.cq1('checkboxfield').isChecked(), false, "Checkbox has been unchecked") t.is(t.cq1('togglefield').getValue(), true, "Togglefield has been checked") } ); }); })