I'm attempting to write unit tests for an AngularJS directive that uses a separate controller from the one on the page. However, I can't find any way to access that controller from within my tests.
Here's my directive:
'use strict';
angular.module('myapp.directives')
.directive('searchButton', function () {
function SearchButtonCtrl ($scope, $location) {
$scope.search = function () {
$location.path('/search');
$location.search(q, $scope.query.w);
};
}
return {
template: '<input type="text" ng-model="query.q">',
controller: SearchButtonCtrl,
restrict: 'E'
};
});
Is it possible to access SearchButtonCtrl? Or is there a better way to structure my code such that it can be accessed?