I am trying to figure out if an event has been received.
I know that the event is catched and runs MyApp.util.Barcode.onBarcodeScanned.
Here is my code:
t.isCalled(
"onBarcodeScanned",
MyApp.util.Barcode,
"Checking if method 'onBarcodeScanned' has been called"
);
// this works
MyApp.util.Barcode.onBarcodeScanned('T|123123123');
// this does not work
Ext.fireEvent('barcodeScanned', 'T|123123123');
// to allow for more time after the event fired
t.waitForMs(500, () => {
t.describe('init', function(t) {})
});
If I fire the event from the console, it works.
Any idea what to change?
Last edited by Kurt on Wed Oct 11, 2023 2:06 pm, edited 1 time in total.
You mentioned the SmartMobile.util.Barcode.onBarcodeScanned('T|123123123'); works, which means Siesta correctly intercepts the onBarcodeScanned method in the MyApp.util.Barcode object.
As regarding Ext.fireEvent('barcodeScanned', 'T|123123123'); - this is something specific to your application, sorry, can't say anything about this.
Right, this is the order of capturing the onBarcodeScanned method.
The only proper way would be to load your application code first (w/o launching it), install the override in the class'es prototype, then launch the app (so that the app captures the override).
But may be you can test some other side effect of the onBarcodeScanned method call?
You were right. I can test if the globalEvent has been set.
Instead of :
// I know that this is the only listener on barcodescanned
let l0 = Ext.globalEvents.events['barcodescanned'].listeners[0];
t.isCalled("fireFn", l0, "Checking if method 'onBarcodeScanned' has been called");
Ext.fireEvent('barcodeScanned', 'T|123123123');