title: Recommended way to unit test an AngularJS factory utilising private variables
body: <p>This basic AngularJS factory has get / set methods that interact with a private <code>globals</code> object. I'm looking for advice on how best to unit test this.</p>
  
  <p>Changing <code>globals</code> to a public property feels like an anti-pattern to me.</p>
  
  <pre class="lang-javascript prettyprint-override"><code>angular.module('Shared')
      .factory('SoundGlobals', [
  
          function () {
              var globals = {};
  
              return {
                  getGlobal: function (name) {
                      return globals[name];
                  },
  
                  setGlobal: function (name, value) {
                      globals[name] = value;
                  }
              };
          }
      ]);
  </code></pre>