Testing within a javascript closure

Viewed 3400

Is it possible to unit test javascript functions that exist within a closure, so for example, given the following:

(function() {
  var a = function() {
    //do something
  }
  window.b =  function() {
    // do something else
  }
})();

Is it possible to unit test function a without exposing it? If not, is there a good way to expose a, but only in test mode?

3 Answers
Related