| OLD | NEW |
| 1 library _specs_spec; | 1 library _specs_spec; |
| 2 | 2 |
| 3 import '_specs.dart'; | 3 import '_specs.dart'; |
| 4 | 4 |
| 5 main() { | 5 main() { |
| 6 describe('expect', () { | 6 describe('renderedText', () { |
| 7 describe('toHaveHtml', () { | 7 it('should work on regular DOM nodes', () { |
| 8 it('should return html', (){ | 8 expect(renderedText($('<span>A<span>C</span></span><span>B</span>'))).toEq
ual('ACB'); |
| 9 var div = es('<div>'); | 9 }); |
| 10 expect(es('<div>')).toHaveHtml(''); | 10 |
| 11 it('should work with shadow DOM', () { |
| 12 var elt = $('<div>DOM content</div>'); |
| 13 var shadow = elt[0].createShadowRoot(); |
| 14 shadow.setInnerHtml( |
| 15 '<div>Shadow content</div><content>SHADOW-CONTENT</content>', |
| 16 treeSanitizer: new NullTreeSanitizer()); |
| 17 expect(renderedText(elt)).toEqual('Shadow contentDOM content'); |
| 18 }); |
| 19 |
| 20 it('should ignore comments', () { |
| 21 expect(renderedText($('<!--e--><span>A<span>C</span></span><span>B</span>'
))).toEqual('ACB'); |
| 22 }); |
| 23 }); |
| 24 |
| 25 |
| 26 describe('jquery', () { |
| 27 describe('html', () { |
| 28 it('get', (){ |
| 29 var div = $('<div>'); |
| 30 expect(div.html()).toEqual(''); |
| 11 }); | 31 }); |
| 12 | 32 |
| 13 it('should strip ng-binding', () { | 33 it('set', (){ |
| 14 var div = es('<div><span class="ng-binding"></span></div>'); | 34 var div = $('<div>'); |
| 15 expect(div).toHaveHtml('<span></span>'); | 35 expect(div.html('text')).toBe(div); |
| 16 }); | 36 expect(div.html()).toEqual('text'); |
| 17 }); | |
| 18 | |
| 19 describe('toHaveText', () { | |
| 20 it('should work on regular DOM nodes', () { | |
| 21 expect(es('<span>A<span>C</span></span><span>B</span>')) | |
| 22 .toHaveText('ACB'); | |
| 23 }); | |
| 24 | |
| 25 it('should work with shadow DOM', () { | |
| 26 var elt = e('<div>DOM content</div>'); | |
| 27 var shadow = elt.createShadowRoot(); | |
| 28 shadow.setInnerHtml( | |
| 29 '<div>Shadow content</div><content></content>', | |
| 30 treeSanitizer: new NullTreeSanitizer()); | |
| 31 expect(elt).toHaveText('Shadow contentDOM content'); | |
| 32 }); | |
| 33 | |
| 34 it('should work with shadow DOM even if content is not a direct child of s
hadow root', () { | |
| 35 var elt = e('<div>DOM content</div>'); | |
| 36 var shadow = elt.createShadowRoot(); | |
| 37 shadow.setInnerHtml( | |
| 38 '<div>Shadow content</div><span>:[<content></content>]</span>', | |
| 39 treeSanitizer: new NullTreeSanitizer()); | |
| 40 expect(elt).toHaveText('Shadow content:[DOM content]'); | |
| 41 }); | |
| 42 | |
| 43 it('should ignore comments', () { | |
| 44 expect(es('<!--e--><span>A<span>C</span></span><span>B</span>')) | |
| 45 .toHaveText('ACB'); | |
| 46 }); | 37 }); |
| 47 }); | 38 }); |
| 48 }); | 39 }); |
| 49 } | 40 } |
| OLD | NEW |