If I have a directive that takes a function from the scope, and that function is asynchronous how could I test that? For example
angular.module('myApp').factory('AsyncService',() => {
return {
async: // function that returns a promise
}
})
angular.module('myApp').directive('asyncDirective', () => ({
scope: { async: = },
link: scope => {
scope.async.then(//do something)
}
}));
angular.module('myApp').controller('ctrl', ($scope, AsyncService) => {
$scope.asyncService = AysncService;
});
<async-directive async="asyncService.async" />
The above code is an example of how the directive might be used, but I only want to test the directive alone. Since the directive expects a function and not an object that it can use to call a function, how would I test it? If I used a spy, what would I spy on?