title: How to unit test subfunctions in QUnit?
body: <p>I have the following code in my SAPUI5 app.</p>
  
  <p>This function is trigger when a button is clicked.</p>
  
  <pre><code>onClear(oEvent){
     var source = oEvent.getSource().getText(); //get the text on the button
     ....
   }
  </code></pre>
  
  <p>In my Unit test I have </p>
  
  <pre><code>QUnit.module('onClear functio test);
    Qunit.test('onClear press test', function(assert){
       var getSource = sinon.spy();
        var getText = sinon.spy();
  
       var oEvent = {getSsource: getSource};
       var source = "Clear"; //this is what should be return for this test
  
     //call the function
      mainController.onClear(oEvent, source); 
   }
  </code></pre>
  
  <p>The error I get is <code>"Unable to get property 'getText' of undefined or null reference"</code></p>
  
  <p>From SAP API, <code>oEvent.getSource()</code> simply returns a reference to the object triggering the event, in this case a button. During the testing <code>.getSource()</code> doesn't return anything I believe.
  So how can make this work? I know I can break down my code into 2 different lines and spy/stub those 2 functions separately but I don't want to do that as the code I have is valid JavaScript code.</p>