title: AngularJS Unit Testing with PouchDB Service Promises
body: <p>I have a factory, which I am attempting to unit test, with an injected PouchDB wrapper.  The issue I am running into is that I have the mock PouchDB service returning a promise and while the promise resolves (I can console.log out the successCb and it looks correct), the karma expect statements within the successCb function where the correct console.log output is, are not running.  </p>
  
  <p>I am not sure why the console.log output works fine but the expect statements do not execute, any help on this matter would be greatly appreciated!</p>
  
  <p>The following are the relevant snippets of code:</p>
  
  <p>[ Unit Testing Setup ]</p>
  
  <pre><code>var mockCalendarsResource, mockPouchDB;
  var mockPouchDB = function(name) {
      this.name = name;
      this.post = function(newCalendar, successCb, errorCb) {
          var promise = new Promise(function(successCb, errorCb) {
              newCalendar._id = 2;
              successCb(newCalendar);
          });
          return promise;
      };
  }
  
  beforeEach(function() {
      module(function($provide) {
          $provide.value('Pouch', mockPouchDB);
      });
      angular.mock.inject(function($injector) {
          mockCalendarsResource = $injector.get('Calendar');
      });
  });
  </code></pre>
  
  <p>[ Karma Unit Test Code ]</p>
  
  <pre><code>describe('The calendar resource function create', function() {
      it('should create a new calendar', inject(function(Calendar) {
          var result = mockCalendarsResource.create({
              name: "Testing"
          },
          function(response) {
              //console.log here works correctly //
              //These are the expect statements not functioning //
              expect(response._id).toBe(2);
              expect(response.name).toBe('Testing');
              // Could put any expectation here and it will pass or not be checked //
          }, function(err) {
  
          });
      }));
  });
  </code></pre>