Last active
July 6, 2017 14:52
-
-
Save joelwatson/aa8e7a19dea4d489cfd8e250c3c2b5c7 to your computer and use it in GitHub Desktop.
Asserting displayValue of ComboBox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define('Sandbox.view.test.combobox.Base', { | |
extend: 'Ext.form.field.ComboBox', | |
id: 'futureCmp', | |
displayField: 'text', | |
valueField: 'id', | |
store: { | |
fields: ['id', 'text'], | |
data: [ | |
[1, 'Apples'], | |
[2, 'Oranges'] | |
] | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PO = { | |
combo: function () { | |
return ST.comboBox('@futureCmp'); | |
}, | |
displayValue: function (value) { | |
return this.combo() | |
.execute(function (cmp) { | |
var record = cmp.findRecordByDisplay(value); | |
return record ? record.get('id') : false; | |
}).and(function () { | |
var future = this.future, | |
id = future.data.executeResult; | |
future.setValue(id); | |
// assert that the value has been correctly selected | |
future.value(id); | |
}); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should select correct value from displayField', function () { | |
// We have a single method on our page object that encapsulates some complex logic | |
PO.displayValue('Oranges'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment