| OLD | NEW |
| (Empty) | |
| 1 library ng_template_spec; |
| 2 |
| 3 import '../_specs.dart'; |
| 4 |
| 5 main() { |
| 6 describe('NgTemplateDirective', () { |
| 7 TestBed _; |
| 8 var element; |
| 9 |
| 10 they(should, htmlForElements, callback) { |
| 11 htmlForElements.forEach((html) { |
| 12 var tagName = html.contains('<template') ? 'template' : 'script'; |
| 13 describe('$tagName[type="text/ng-template"]', () { |
| 14 beforeEach(inject((TestBed tb) => _ = tb)); |
| 15 it(should, () { |
| 16 element = $(html); |
| 17 inject(callback); |
| 18 }); |
| 19 }); |
| 20 }); |
| 21 } |
| 22 |
| 23 they('should populate TemplateCache with contents of a ng-template template
element', |
| 24 [ // <template> |
| 25 '<div>foo' + |
| 26 '<template id="/ignore">ignore me</template>' + |
| 27 '<template type="text/ng-template" id="/myTemplate.html"><x>{{y}}</x><
/template>' + |
| 28 '</div>', |
| 29 // <script> |
| 30 '<div>foo' + |
| 31 '<script id="/ignore">ignore me</script>' + |
| 32 '<script type="text/ng-template" id="/myTemplate.html"><x>{{y}}</x></s
cript>' + |
| 33 '</div>'], |
| 34 (Injector injector, Compiler compiler, TemplateCache templateCache) { |
| 35 compiler(element)(injector, element); |
| 36 expect(templateCache.get('/ignore')).toBeNull(); |
| 37 expect(templateCache.get('/myTemplate.html').responseText).toEqual('<x>{
{y}}</x>'); |
| 38 } |
| 39 ); |
| 40 |
| 41 they('should not compile template elements', |
| 42 [ // <template> |
| 43 '<div>foo' + |
| 44 '<template type="text/javascript">some {{binding}} <div></div></templa
te>' + |
| 45 '<template type="text/ng-template" id="/some">other {{binding}} <div><
/div></template>' + |
| 46 '</div>', |
| 47 // <script> |
| 48 '<div>foo' + |
| 49 '<script type="text/javascript">some {{binding}} <div></div></script>'
+ |
| 50 '<script type="text/ng-template" id="/some">other {{binding}} <div></d
iv></script>' + |
| 51 '</div>'], |
| 52 (Injector injector, Compiler compiler, TemplateCache templateCache, Scope
scope) { |
| 53 var templates = element.contents(); |
| 54 compiler(element)(injector, element); |
| 55 |
| 56 microLeap(); |
| 57 // This binding should have been left alone (i.e. not interpolated). |
| 58 expect(templates[2].innerHtml).toEqual('other {{binding}} <div></div>'); |
| 59 } |
| 60 ); |
| 61 }); |
| 62 } |
| OLD | NEW |