我对Jasmine很新。
我曾尝试为以下代码方案编写测试用例,但测试失败。
为服务调用编写的间谍工作正常,但我无法使用$q.all()
编写测试用例。
function getUserDetails() {
var deferred = $q.defer();
var promises = [];
vm.method = 'GetUserDetailsEx';
var data = {
sessionVal: "sdadfad8787", Username:"test",UserId:1,AdditionalInput: null
};
vm.fetchUsers();
var fetchUserDs = vm.fetchUsers();
promises.push(fetchUserDs );
$q.all(promises).then(function () {
if (getUserDetailsResponse.ResultCode == 0) {});
}
}
it('should fetch User Details to be defined', function () {
myTestController.getUserDetails();
scope.$digest();
expect(myTestController.getUserDetails).toBeDefined();
it('should resolve promise', function () {
myTestController.$q.all(myTestController.fetchUserDetails).then(function () {
});
scope.apply();
}