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;
};
}));
你已經有什麼? –