草庐IT

removeAndGetNext

全部标签

javascript - Angularjs 中基于 promise 的单元测试代码

我很难尝试在Angularjs中测试基于promise的代码。我的Controller中有以下代码:$scope.markAsDone=function(taskId){tasksService.removeAndGetNext(taskId).then(function(nextTask){goTo(nextTask);})};functiongoTo(nextTask){$location.path(...);}我想对以下情况进行单元测试:当markAsDone被调用时,它应该调用tasksService.removeAndGetNext当tasksService.removeAn

javascript - Angularjs 中基于 promise 的单元测试代码

我很难尝试在Angularjs中测试基于promise的代码。我的Controller中有以下代码:$scope.markAsDone=function(taskId){tasksService.removeAndGetNext(taskId).then(function(nextTask){goTo(nextTask);})};functiongoTo(nextTask){$location.path(...);}我想对以下情况进行单元测试:当markAsDone被调用时,它应该调用tasksService.removeAndGetNext当tasksService.removeAn