diff options
| author | Misko Hevery | 2011-02-07 13:28:42 -0800 |
|---|---|---|
| committer | Misko Hevery | 2011-02-16 00:48:22 -0500 |
| commit | 0a5c00abf8664fdbdc5d16b13adb1989b4531cdf (patch) | |
| tree | 42d9426de8aa7917ba2dc127ee35dbc5890d7877 /test/jqLiteSpec.js | |
| parent | a004d487c4bb48b2bec19b60bc5ddc5244029be5 (diff) | |
| download | angular.js-0a5c00abf8664fdbdc5d16b13adb1989b4531cdf.tar.bz2 | |
Add public API to retrieve scope from element.
Diffstat (limited to 'test/jqLiteSpec.js')
| -rw-r--r-- | test/jqLiteSpec.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js new file mode 100644 index 00000000..da8ab206 --- /dev/null +++ b/test/jqLiteSpec.js @@ -0,0 +1,31 @@ +describe('jqLite', function(){ + var scope; + + beforeEach(function(){ + scope = angular.scope(); + }); + + describe('scope', function() { + it('should retrieve scope attached to the current element', function() { + var element = jqLite('<i>foo</i>'); + element.data('$scope', scope); + expect(element.scope()).toBe(scope); + dealoc(element); + }); + + it('should walk up the dom to find scope', function() { + var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>'); + var deepChild = jqLite(element[0].getElementsByTagName('b')[0]); + element.data('$scope', scope); + expect(deepChild.scope()).toBe(scope); + dealoc(element); + }); + + it('should return undefined when no scope was found', function() { + var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>'); + var deepChild = jqLite(element[0].getElementsByTagName('b')[0]); + expect(deepChild.scope()).toBeNull(); + dealoc(element); + }); + }); +}); |
