title: angularJS : how to mock localStorgaeService with spyOn?
body: <p>I have a simple service implemented like this </p>
  
  <pre><code> sameRoof
    .factory('dbService', function (localStorageService, backendUpdate) {
      return {
        checkProfileAndFlat: function () {
          return (localStorageService.get('profile') &amp;&amp; localStorageService.get('flatshare'));
        }
      };
    });
  </code></pre>
  
  <p>LocalStorage are ngModules installed with bower.</p>
  
  <p>I am writint unit test </p>
  
  <pre><code>'use strict';
  describe('Service: service taking care of asking the local database', function () {
  
    var localStorageService;
    var fakeDB = {'profile' : 'testProfile', 'flatshare' : 'flatshare'};
  
    // load the service's module
    beforeEach(module('frontApp'));
  
    // instantiate service
    var dbService;
    beforeEach(inject(function (_dbService_, _localStorageService_) {
      dbService = _dbService_;
      localStorageService = _localStorageService_;
  
      //mock localStorageService get/add
      spyOn(localStorageService,'get').andCallFake(function(key){
        return fakeDB[key];
      });
    }));
  
    it('should check profile and flatshare', function () {
      console.log(localStorageService.get('profile'));
      expect( dbService.checkProfileAndFlat() ).toBe(false);
    });
  
  });
  </code></pre>
  
  <p>but i am having problems here, </p>
  
  <p>TypeError: 'undefined' is not a function (evaluating 'spyOn ...)</p>
  
  <p>seems like i am implementing in wrong way the spyOn</p>