0

Here is a simplified version of my code. My callback is not getting called in my tests.

You can play with the code here to test it...

https://jsfiddle.net/ax3svk78/

function(){ return fillIn(myArg);

   function fillIn() {
    return true;
   }

   var stubAutoComplete = {
           addListener: function(event={}, callback={}) {
             callback;
           }
       }

   stubAutoComplete.addListener('place_changed',
                                             function(){ return fillIn(myArg); }
                                            );

I need the anonymous function, per this posting: Unhandled Promise Rejection: TypeError:

My non-stubbed code works, but my stub does not.

How do I modify my stubbed AddListner function to call the function?

user2012677
  • 5,465
  • 6
  • 51
  • 113

1 Answers1

1

It's unclear what you really want but your code works with these changes:

  • Define myArg variable
  • Write callback() instead of callback

https://jsfiddle.net/va51Luqp/

Michael
  • 2,528
  • 3
  • 21
  • 54