aboutsummaryrefslogtreecommitdiffstats
path: root/test/jqLiteSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2012-03-15 13:40:00 -0700
committerMisko Hevery2012-03-19 11:35:09 -0700
commit6c5a05ad49a1e083570c3dfe331403398f899dbe (patch)
tree2eff786177ee4c76c02c86f0136ae6ae29001ad3 /test/jqLiteSpec.js
parent192ff61f5d61899e667c6dbce4d3e6e399429d8b (diff)
downloadangular.js-6c5a05ad49a1e083570c3dfe331403398f899dbe.tar.bz2
feat(jqLite): add .controller() method
extend JQuery with .controller() method which retrieves the closest controller for a given element
Diffstat (limited to 'test/jqLiteSpec.js')
-rw-r--r--test/jqLiteSpec.js25
1 files changed, 23 insertions, 2 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index 5b2e35b0..5cad8c24 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -140,8 +140,8 @@ describe('jqLite', function() {
describe('injector', function() {
it('should retrieve injector attached to the current element or its parent', function() {
var template = jqLite('<div><span></span></div>'),
- span = template.children().eq(0),
- injector = angular.bootstrap(template);
+ span = template.children().eq(0),
+ injector = angular.bootstrap(template);
expect(span.injector()).toBe(injector);
@@ -150,6 +150,27 @@ describe('jqLite', function() {
});
+ describe('controller', function() {
+ it('should retrieve controller attached to the current element or its parent', function() {
+ var div = jqLite('<div><span></span></div>'),
+ span = div.find('span');
+
+ div.data('$ngControllerController', 'ngController');
+ span.data('$otherController', 'other');
+
+ expect(span.controller()).toBe('ngController');
+ expect(span.controller('ngController')).toBe('ngController');
+ expect(span.controller('other')).toBe('other');
+
+ expect(div.controller()).toBe('ngController');
+ expect(div.controller('ngController')).toBe('ngController');
+ expect(div.controller('other')).toBe(undefined);
+
+ dealoc(div);
+ });
+ });
+
+
describe('data', function() {
it('should set and get and remove data', function() {
var selected = jqLite([a, b, c]);