I'm trying to create a spy on Jquery that's making a call like:
$('#AccountNumber').val();
How would I set up the spy to return a value based on the #AccountNumber selector?
I'm trying to create a spy on Jquery that's making a call like:
$('#AccountNumber').val();
How would I set up the spy to return a value based on the #AccountNumber selector?
You could try this:
var spy = ('#AccountNumber', 'ValueChanged');
$('#AccountNumber').trigger('ValueChanged');
expect(spy).toHaveBeenTriggered();
var val = $(spy.selector).val();
Update after edit: You could add this - Watch for object properties changes in JavaScript then inside handler trigger event 'ValueChanged', and on spy add listener to that event.