title: Testing callback passing in nodejs function
body: <p>With the following example of code, I'd like to know.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function testMe( input, callback ) {
    
      callback = callback || function () {};  /* 1 */
    
      // process input ...
      process( input, function (err, result ) { 
          if( err ) {
              return callback( new Error('fail processing input') ); /* 2 */
          }
  
          return callback( null, result ); /* 3 */
      });
  }</code></pre>
  </div>
  </div>
  </p>
  
  <ol>
  <li><p>How can I test above 3 positions of <code>callback</code> with SinonJS?</p></li>
  <li><p>Is it a good practice that I reset callback at position 1?</p></li>
  </ol>
  
  <p>Appreciate your comments.</p>