From 0b160aff91379e822cd07697b4a3769df41857cb Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Thu, 2 Oct 2014 09:40:45 -0600 Subject: [PATCH] test($compile): add test for alternative syntax to get controllers from ancestors Because the regex that tests the `require` value will match more than just `^^?`, it is important to test other common ways to specify a controller requirement to ensure that a breaking change isn't introduced inadvertently. This adds a test for `?^^`. Closes #9389 --- test/ng/compileSpec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 816aa4a7b503..6b425cca4c1e 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -3720,6 +3720,25 @@ describe('$compile', function() { }); + it('should get required parent controller when the question mark precedes the ^^', function() { + module(function() { + directive('nested', function(log) { + return { + require: '?^^nested', + controller: function($scope) {}, + link: function(scope, element, attrs, controller) { + log(!!controller); + } + }; + }); + }); + inject(function(log, $compile, $rootScope) { + element = $compile('
')($rootScope); + expect(log).toEqual('true; false'); + }); + }); + + it('should throw if required parent is not found', function() { module(function() { directive('nested', function() {