aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorIgor Minar2012-03-21 15:16:41 -0700
committerIgor Minar2012-03-22 16:39:36 -0700
commit5fdab52dd7c269f99839f4fa6b5854d9548269fa (patch)
tree755a94326f85edffeef87425a04f0bb20e2f18e7 /test
parent541bedd1a9692208deae0cd2a93171e87fb7d1ba (diff)
downloadangular.js-5fdab52dd7c269f99839f4fa6b5854d9548269fa.tar.bz2
feat(jqLite): make injector() and scope() work with the document object
For typical app that has ng-app directive on the html element, we now can do: angular.element(document).injector() or .injector() angular.element(document).scope() or .scope() instead of: angular.element(document.getElementsByTagName('html')[0]).injector() ...
Diffstat (limited to 'test')
-rw-r--r--test/jqLiteSpec.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index fbe6edcb..afbb6836 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -107,6 +107,20 @@ describe('jqLite', function() {
expect(deepChild.inheritedData('myData')).toBeFalsy();
dealoc(element);
});
+
+
+ it('should work with the child html element instead if the current element is the document obj',
+ function() {
+ var item = {},
+ doc = jqLite(document),
+ html = doc.find('html');
+
+ html.data('item', item);
+ expect(doc.inheritedData('item')).toBe(item);
+ expect(html.inheritedData('item')).toBe(item);
+ dealoc(doc);
+ }
+ );
});
@@ -118,6 +132,18 @@ describe('jqLite', function() {
dealoc(element);
});
+ it('should retrieve scope attached to the html element if its requested on the document',
+ function() {
+ var doc = jqLite(document),
+ html = doc.find('html'),
+ scope = {};
+
+ html.data('$scope', scope);
+
+ expect(doc.scope()).toBe(scope);
+ expect(html.scope()).toBe(scope);
+ dealoc(doc);
+ });
it('should walk up the dom to find scope', function() {
var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>');
@@ -147,6 +173,27 @@ describe('jqLite', function() {
expect(span.injector()).toBe(injector);
dealoc(template);
});
+
+
+ it('should retrieve injector attached to the html element if its requested on document',
+ function() {
+ var doc = jqLite(document),
+ html = doc.find('html'),
+ injector = {};
+
+ html.data('$injector', injector);
+
+ expect(doc.injector()).toBe(injector);
+ expect(html.injector()).toBe(injector);
+ dealoc(doc);
+ });
+
+
+ it('should do nothing with a noncompiled template', function() {
+ var template = jqLite('<div><span></span></div>');
+ expect(template.injector()).toBeUndefined();
+ dealoc(template);
+ });
});