| OLD | NEW |
| 1 library ng.tool.source_metadata_extractor_spec; | 1 library ng.tool.source_metadata_extractor_spec; |
| 2 | 2 |
| 3 import 'package:angular/tools/common.dart'; | 3 import 'package:angular/tools/common.dart'; |
| 4 import 'package:angular/tools/source_crawler_impl.dart'; | 4 import 'package:angular/tools/source_crawler_impl.dart'; |
| 5 import 'package:angular/tools/source_metadata_extractor.dart'; | 5 import 'package:angular/tools/source_metadata_extractor.dart'; |
| 6 import '../jasmine_syntax.dart'; | 6 import '../jasmine_syntax.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 | 8 |
| 9 main() => describe('source_metadata_extractor', () { | 9 void main() { |
| 10 it('should extract all attribute mappings including annotations', () { | 10 describe('source_metadata_extractor', () { |
| 11 var sourceCrawler = new SourceCrawlerImpl(['packages/']); | 11 it('should extract all attribute mappings including annotations', () { |
| 12 var sourceMetadataExtractor = new SourceMetadataExtractor(); | 12 var sourceCrawler = new SourceCrawlerImpl(['packages/']); |
| 13 List<DirectiveInfo> directives = | 13 var sourceMetadataExtractor = new SourceMetadataExtractor(); |
| 14 sourceMetadataExtractor | 14 List<DirectiveInfo> directives = sourceMetadataExtractor |
| 15 .gatherDirectiveInfo('test/io/test_files/main.dart', sourceCrawler); | 15 .gatherDirectiveInfo('test/io/test_files/main.dart', sourceCrawler); |
| 16 | 16 |
| 17 expect(directives, hasLength(2)); | 17 expect(directives.map((d) => d.selector), |
| 18 unorderedEquals(['[ng-if]', 'my-component'])); |
| 18 | 19 |
| 19 DirectiveInfo info = directives.elementAt(1); | 20 DirectiveInfo info = directives.elementAt(1); |
| 20 expect(info.expressionAttrs, unorderedEquals(['expr', 'another-expression', | 21 expect(info.expressionAttrs, unorderedEquals(['expr', 'another-expression'
, |
| 21 'callback', 'two-way-stuff', 'exported-attr'])); | 22 'callback', 'two-way-stuff', 'exported-attr'])); |
| 22 expect(info.expressions, unorderedEquals(['attr', 'expr', | 23 expect(info.expressions, unorderedEquals(['attr', 'expr', |
| 23 'anotherExpression', 'callback', 'twoWayStuff', | 24 'anotherExpression', 'callback', 'twoWayStuff', 'exported + expression
'])); |
| 24 'exported + expression'])); | 25 }); |
| 26 |
| 27 it('should extract ngRoute templates from ngRoute viewHtml', () { |
| 28 var sourceCrawler = new SourceCrawlerImpl(['packages/']); |
| 29 var sourceMetadataExtractor = new SourceMetadataExtractor(); |
| 30 List<DirectiveInfo> directives = sourceMetadataExtractor |
| 31 .gatherDirectiveInfo('test/io/test_files/routing.dart', sourceCrawler)
; |
| 32 |
| 33 var templates = directives |
| 34 .where((i) => i.selector == null) |
| 35 .map((i) => i.template); |
| 36 expect(templates, hasLength(2)); |
| 37 expect(templates, |
| 38 unorderedEquals(['<div ng-if="foo"></div>', '<div ng-if="bar"></div>']
)); |
| 39 }); |
| 25 }); | 40 }); |
| 26 }); | 41 } |
| OLD | NEW |