aboutsummaryrefslogtreecommitdiffstats
path: root/test/ngRoute/directive/ngViewSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/ngRoute/directive/ngViewSpec.js')
-rw-r--r--test/ngRoute/directive/ngViewSpec.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/ngRoute/directive/ngViewSpec.js b/test/ngRoute/directive/ngViewSpec.js
index f4b28058..a8d1f459 100644
--- a/test/ngRoute/directive/ngViewSpec.js
+++ b/test/ngRoute/directive/ngViewSpec.js
@@ -582,6 +582,46 @@ describe('ngView and transcludes', function() {
});
});
+
+ it('should link directives on the same element after the content has been loaded', function() {
+ var contentOnLink;
+ module(function($compileProvider, $routeProvider) {
+ $routeProvider.when('/view', {template: 'someContent'});
+ $compileProvider.directive('test', function() {
+ return {
+ link: function(scope, element) {
+ contentOnLink = element.text();
+ }
+ };
+ });
+ });
+ inject(function($compile, $rootScope, $location) {
+ element = $compile('<div><div ng-view test></div>')($rootScope);
+ $location.url('/view');
+ $rootScope.$apply();
+ expect(contentOnLink).toBe('someContent');
+ });
+ });
+
+ it('should add the content to the element before compiling it', function() {
+ var root;
+ module(function($compileProvider, $routeProvider) {
+ $routeProvider.when('/view', {template: '<span test></span>'});
+ $compileProvider.directive('test', function() {
+ return {
+ link: function(scope, element) {
+ root = element.parent().parent();
+ }
+ };
+ });
+ });
+ inject(function($compile, $rootScope, $location) {
+ element = $compile('<div><div ng-view></div>')($rootScope);
+ $location.url('/view');
+ $rootScope.$apply();
+ expect(root[0]).toBe(element[0]);
+ });
+ });
});
describe('ngView animations', function() {