In some of my directives, I\'m adding functions to the scope to handle logic specific for the directive. For example:
link: function(scope, element, attrs) {
As stated in a comment reply to @sqlexception. You just really need to get a handle on the directive's scope, which is not hard to do. What you dont want to do is modify your code to satisfy your tests, as it should be the other way around.
To get the scope of the directive just compile like so:
var element = $compile(
where $scope
is declared with $scope = $rootScrope.$new()
. Now we can get the isolate scope by doing element.scope()
I just recently wrote a short blog post about this found here Testing a Linking Function with a plunker to help: