单元测试$ scope.使用Jasmine 2.0的$ evalAsync函数

kso*_*ngz 9 javascript unit-testing jasmine angularjs karma-jasmine

我正在尝试对$ scope.$ evalAsync函数进行单元测试.这是我的代码:

$scope.$evalAsync(function(done) {
    //enable the popover plugin
    done();
    jQuery('[data-toggle="popover"]').popover();
    $scope.isKioskIdLoaded.state = true;
});
Run Code Online (Sandbox Code Playgroud)

我很难理解如何在我的Jasmine测试中运行evalAsync.我正在尝试使用Jasmine 2.0中的done()函数.

Jam*_*son 0

您需要添加$scope.$digest()到您的 Jasmine 测试中。将 evalasync 函数添加到 Angular 的 asyncQueue 后,您需要触发摘要。