| OLD | NEW |
| (Empty) | |
| 1 library html_extractor_spec; |
| 2 |
| 3 import 'package:angular/tools/common.dart'; |
| 4 import 'package:angular/tools/html_extractor.dart'; |
| 5 import 'package:unittest/unittest.dart'; |
| 6 |
| 7 import '../jasmine_syntax.dart'; |
| 8 import 'mock_io_service.dart'; |
| 9 |
| 10 main() => describe('html_extractor', () { |
| 11 |
| 12 it('should extract text mustache expressions', () { |
| 13 var ioService = new MockIoService({ |
| 14 'foo.html': r''' |
| 15 <div>foo {{ctrl.bar}} baz {{aux}}</div> |
| 16 ''' |
| 17 }); |
| 18 |
| 19 var extractor = new HtmlExpressionExtractor([], ioService); |
| 20 extractor.crawl('/'); |
| 21 expect(extractor.expressions.toList()..sort(), |
| 22 equals(['aux', 'ctrl.bar'])); |
| 23 }); |
| 24 |
| 25 it('should extract attribute mustache expressions', () { |
| 26 var ioService = new MockIoService({ |
| 27 'foo.html': r''' |
| 28 <div foo="foo-{{ctrl.bar}}" baz="{{aux}}-baz"></div> |
| 29 ''' |
| 30 }); |
| 31 |
| 32 var extractor = new HtmlExpressionExtractor([], ioService); |
| 33 extractor.crawl('/'); |
| 34 expect(extractor.expressions.toList()..sort(), |
| 35 equals(['aux', 'ctrl.bar'])); |
| 36 }); |
| 37 |
| 38 it('should extract ng-repeat expressions', () { |
| 39 var ioService = new MockIoService({ |
| 40 'foo.html': r''' |
| 41 <div ng-repeat="foo in ctrl.bar"></div> |
| 42 ''' |
| 43 }); |
| 44 |
| 45 var extractor = new HtmlExpressionExtractor([], ioService); |
| 46 extractor.crawl('/'); |
| 47 expect(extractor.expressions.toList()..sort(), |
| 48 equals(['ctrl.bar'])); |
| 49 }); |
| 50 |
| 51 it('should extract expressions provided in the directive info', () { |
| 52 var ioService = new MockIoService({}); |
| 53 |
| 54 var extractor = new HtmlExpressionExtractor([ |
| 55 new DirectiveInfo('', [], ['foo', 'bar']) |
| 56 ], ioService); |
| 57 extractor.crawl('/'); |
| 58 expect(extractor.expressions.toList()..sort(), |
| 59 equals(['bar', 'foo'])); |
| 60 }); |
| 61 |
| 62 it('should extract expressions from expression attributes', () { |
| 63 var ioService = new MockIoService({ |
| 64 'foo.html': r''' |
| 65 <foo bar="ctrl.baz"></foo> |
| 66 ''' |
| 67 }); |
| 68 |
| 69 var extractor = new HtmlExpressionExtractor([ |
| 70 new DirectiveInfo('foo', ['bar']) |
| 71 ], ioService); |
| 72 extractor.crawl('/'); |
| 73 expect(extractor.expressions.toList()..sort(), |
| 74 equals(['ctrl.baz'])); |
| 75 }); |
| 76 |
| 77 it('should ignore ng-repeat while extracting attribute expressions', () { |
| 78 var ioService = new MockIoService({ |
| 79 'foo.html': r''' |
| 80 <div ng-repeat="foo in ctrl.bar"></div> |
| 81 ''' |
| 82 }); |
| 83 |
| 84 var extractor = new HtmlExpressionExtractor([ |
| 85 new DirectiveInfo('[ng-repeat]', ['ng-repeat']) |
| 86 ], ioService); |
| 87 extractor.crawl('/'); |
| 88 // Basically we don't want to extract "foo in ctrl.bar". |
| 89 expect(extractor.expressions.toList()..sort(), |
| 90 equals(['ctrl.bar'])); |
| 91 }); |
| 92 }); |
| OLD | NEW |