0
如何使用jasmine在angularjs中编写以下代码的测试用例,我已经完成了工作正常,但无法模拟$ q数据的数据模拟,因为我的测试用例越来越失败
$q.all([_allMasterList, _allUserList]).then(function(arrData){
$scope.notificationLists = manageNotifications.getAllNotificationList(arrData, _fmno);
});
我试着从以下AngularJs
beforeEach(function() {
manageNotifications = jasmine.createSpyObj('manageNotifications', ['getNotificationMasterList', 'getNotificationUserList', 'getAllNotificationList' ]);
});
beforeEach(inject(function($controller, _manageNotifications_, $window, $location, $rootScope, _mckModal_, $timeout, System_Messages, $q, $httpBackend, _confirmationModalService_, _API_ENDPOINT_){
httpBackend = $httpBackend;
rootScope = $rootScope;
scope = $rootScope.$new();
API_ENDPOINT = _API_ENDPOINT_;
manageNotifications = _manageNotifications_;
confirmationModalService = _confirmationModalService_;
/* Mock Data */
manageNotifications.getNotificationMasterList = function(){
deferred_getNotificationMasterList = $q.defer();
deferred_getNotificationMasterList.resolve(_masterList);
return deferred_getNotificationMasterList.promise;
};
manageNotifications.getNotificationUserList = function(_data){
deferred_getNotificationUserList = $q.defer();
deferred_getNotificationUserList.resolve({
"status": "Success",
"dataValue": _data
});
return deferred_getNotificationUserList.promise;
};
}));
你已经有什么? –