diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/jqLiteSpec.js | 20 | ||||
| -rw-r--r-- | test/service/compilerSpec.js | 9 |
2 files changed, 29 insertions, 0 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 358b8c4a..5b2e35b0 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -802,6 +802,26 @@ describe('jqLite', function() { }); }); + + describe('wrap', function() { + it('should wrap text node', function() { + var root = jqLite('<div>A<a>B</a>C</div>'); + var text = root.contents(); + expect(text.wrap("<span>")[0]).toBe(text[0]); + expect(root.find('span').text()).toEqual('A<a>B</a>C'); + }); + it('should wrap free text node', function() { + var root = jqLite('<div>A<a>B</a>C</div>'); + var text = root.contents(); + text.remove(); + expect(root.text()).toBe(''); + + text.wrap("<span>"); + expect(text.parent().text()).toEqual('A<a>B</a>C'); + }); + }); + + describe('prepend', function() { it('should prepend to empty', function() { var root = jqLite('<div>'); diff --git a/test/service/compilerSpec.js b/test/service/compilerSpec.js index 8d91ed5d..02cdcefe 100644 --- a/test/service/compilerSpec.js +++ b/test/service/compilerSpec.js @@ -96,6 +96,15 @@ describe('$compile', function() { describe('compile phase', function() { + it('should wrap root text nodes in spans', inject(function($compile, $rootScope) { + element = jqLite('<div>A<a>B</a>C</div>'); + var text = element.contents(); + expect(text[0].nodeName).toEqual('#text'); + text = $compile(text)($rootScope); + expect(lowercase(text[0].nodeName)).toEqual('span'); + expect(element.find('span').text()).toEqual('A<a>B</a>C'); + })); + describe('multiple directives per element', function() { it('should allow multiple directives per element', inject(function($compile, $rootScope, log){ element = $compile( |
