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
Closes #9390
This commit is contained in:
Kent C. Dodds
2014-10-02 09:40:45 -06:00
committed by Caitlin Potter
parent 391d8c04da
commit f7b2d85a2c

View File

@@ -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('<div nested><div nested></div></div>')($rootScope);
expect(log).toEqual('true; false');
});
});
it('should throw if required parent is not found', function() {
module(function() {
directive('nested', function() {