Unit testing 简单茉莉花试验失败

Unit testing 简单茉莉花试验失败,unit-testing,jasmine,Unit Testing,Jasmine,下面是angularJS工厂 angular.module('employer').factory('emp', function($rootScope, $ionicPopup, $state, $window){ var pop = {}; pop.integrate = function(){ return 123; }; }); 以下是我试过的茉莉花测试 (一) 这给了我一个错误-预期未定义为等于123。 (二) 这给了我一个错误-pop.integrate

下面是angularJS工厂

angular.module('employer').factory('emp', function($rootScope, $ionicPopup, $state, $window){

var pop = {}; 

pop.integrate = function(){
       return 123;
    };
});
以下是我试过的茉莉花测试

(一)

这给了我一个错误-
预期未定义为等于123。

(二)

这给了我一个错误-
pop.integrate()
不是函数

it('integration', function(){
              expect(pop.integrate).toEqual(123);
              });
it('integration', function(){
              spyOn(pop, 'integrate');
              pop.integrate();
              expect(pop.integrate).toHaveBeenCalled();
              expect(pop.integrate).toEqual(123);
              });