title: Node.js how should I unit test a function calling other functions
body: <p>I want to unit test a module I've built.
  To give an impression of what it looks like pretty much..
  MyModule:</p>
  
  <pre><code>function MyModule(...) {
      var self = this;
      MyModule.init.call(self, ...);
  }
  
  util.inherits(MyModule, MySuperModule);
  
  MyModule.init = function(...) {
  ...
  };
  
  MyModule.prototype.logic = function(..., done) {
     calls fnA, fnB, fnC, fnD conditionally
     done(...)
  };
  
  MyModule.prototype.fnA = function(...) {
  ...
  };
  
  MyModule.prototype.fnB = function(...) {
  ...
  };
  
  MyModule.prototype.fnC = function(...) {
  ...
  };
  
  MyModule.prototype.fnD = function(...) {
  ...
  };
  </code></pre>
  
  <p>MySuperModule:</p>
  
  <pre><code>function MySuperModule(...) {
      ...
      }
  
      MySuperModule.prototype,fn = function(..., done) {
          var self = this;
          ...
          self.logic(..., function done(...) {
              ...
              done(...)
          });
      }
  </code></pre>
  
  <p>Now MyModule.logic() is never called explicitly by a user, it is only invoked MySuperModule.fn().
  Same goes for all other MyModule functions which are called conditionally based on the given parameters being passed through the delegating chain.</p>
  
  <p>My questions are as follow:</p>
  
  <ul>
  <li>Do I need to test all MyModule functions separately or just test MySuperModule.fn() with different parameters covering all possible scenarios</li>
  <li>I know I need to test function in isolation (which if I do my previous question is wrong to ask because than I won't really have tested MyModule functions at all), how would I do that with the MySuperModule.fn(), because its done() callback is being called with arguments dependent on what the MyModule.logic() done() callback was called with, which is again, dependent on the arguments supplied to MySuperModule.fn() arguments.</li>
  </ul>