Index: third_party/pkg/angular/test/tools/source_metadata_extractor_spec.dart |
diff --git a/third_party/pkg/angular/test/tools/source_metadata_extractor_spec.dart b/third_party/pkg/angular/test/tools/source_metadata_extractor_spec.dart |
index 238c6a7477dfe9a197108a1598b1efb878db645b..4a4c6c5e8fed5979b2dc7ce26ea65ca1b59cfaeb 100644 |
--- a/third_party/pkg/angular/test/tools/source_metadata_extractor_spec.dart |
+++ b/third_party/pkg/angular/test/tools/source_metadata_extractor_spec.dart |
@@ -8,110 +8,112 @@ import 'package:unittest/unittest.dart'; |
import '../jasmine_syntax.dart'; |
-main() => describe('SourceMetadataExtractor', () { |
- |
- it('should extract expressions and attribute names with expressions', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('FooComponent', COMPONENT, 'foo-component', { |
- 'barVal': '@bar', |
- 'baz-expr1': '<=>baz1', |
- 'baz-expr2': '=>baz2', |
- 'baz-expr3': '=>!baz3', |
- 'baz-callback': '&aux', |
- }) |
- ]); |
- |
- expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
- equals(['baz-expr1', |
- 'baz-expr2', |
- 'baz-expr3', |
- 'baz-callback'])); |
- expect(flattenList(info, (DirectiveInfo i) => i.expressions), |
- equals(['bar', |
- 'baz1', |
- 'baz2', |
- 'baz3', |
- 'aux'])); |
- }); |
- |
- it('should build a component selector if one is not explicitly specified', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('MyFooComponent', COMPONENT, 'my-foo', { |
- 'foo-expr': '=>fooExpr' |
- }) |
- ]); |
- |
- expect(info, hasLength(1)); |
- expect(info[0].selector, equals('my-foo')); |
- }); |
- |
- it('should build an element directive selector if one is not explicitly specified', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('MyFooDirective', DIRECTIVE, 'my-foo', { |
- 'foo-expr': '=>fooExpr' |
- }) |
- ]); |
- |
- expect(info, hasLength(1)); |
- expect(info[0].selector, equals('my-foo')); |
- }); |
- |
- it('should build an attr directive selector if one is not explicitly specified', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('MyFooAttrDirective', '[my-foo]', '[my-foo]', { |
- 'foo-expr': '=>fooExpr' |
- }) |
- ]); |
- |
- expect(info, hasLength(1)); |
- expect(info[0].selector, equals('[my-foo]')); |
- }); |
- |
- it('should figure out attribute name if dot(.) is used', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[my-foo]', { |
- '.': '=>fooExpr' |
- }) |
- ]); |
+void main() { |
+ describe('SourceMetadataExtractor', () { |
+ |
+ it('should extract expressions and attribute names with expressions', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('FooComponent', COMPONENT, 'foo-component', { |
+ 'barVal': '@bar', |
+ 'baz-expr1': '<=>baz1', |
+ 'baz-expr2': '=>baz2', |
+ 'baz-expr3': '=>!baz3', |
+ 'baz-callback': '&aux', |
+ }) |
+ ]); |
+ |
+ expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
+ equals(['baz-expr1', |
+ 'baz-expr2', |
+ 'baz-expr3', |
+ 'baz-callback'])); |
+ expect(flattenList(info, (DirectiveInfo i) => i.expressions), |
+ equals(['bar', |
+ 'baz1', |
+ 'baz2', |
+ 'baz3', |
+ 'aux'])); |
+ }); |
+ |
+ it('should build a component selector if one is not explicitly specified', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('MyFooComponent', COMPONENT, 'my-foo', { |
+ 'foo-expr': '=>fooExpr' |
+ }) |
+ ]); |
+ |
+ expect(info, hasLength(1)); |
+ expect(info[0].selector, equals('my-foo')); |
+ }); |
+ |
+ it('should build an element directive selector if one is not explicitly specified', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('MyFooDirective', DIRECTIVE, 'my-foo', { |
+ 'foo-expr': '=>fooExpr' |
+ }) |
+ ]); |
+ |
+ expect(info, hasLength(1)); |
+ expect(info[0].selector, equals('my-foo')); |
+ }); |
+ |
+ it('should build an attr directive selector if one is not explicitly specified', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('MyFooAttrDirective', '[my-foo]', '[my-foo]', { |
+ 'foo-expr': '=>fooExpr' |
+ }) |
+ ]); |
+ |
+ expect(info, hasLength(1)); |
+ expect(info[0].selector, equals('[my-foo]')); |
+ }); |
+ |
+ it('should figure out attribute name if dot(.) is used', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[my-foo]', { |
+ '.': '=>fooExpr' |
+ }) |
+ ]); |
+ |
+ expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
+ equals(['my-foo'])); |
+ }); |
+ |
+ it('should figure out attribute name from selector if dot(.) is used', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[blah][foo]', { |
+ '.': '=>fooExpr' |
+ }) |
+ ]); |
+ |
+ expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
+ equals(['foo'])); |
+ }); |
+ |
+ it('should include exported expression attributes', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[blah][foo]', { |
+ '.': '=>fooExpr' |
+ }, ['baz']) |
+ ]); |
+ |
+ expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
+ equals(['foo', 'baz'])); |
+ }); |
+ |
+ it('should include exported expressions', () { |
+ var info = extractDirectiveInfo([ |
+ new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[blah][foo]', { |
+ '.': '=>fooExpr' |
+ }, null, ['ctrl.baz']) |
+ ]); |
+ |
+ expect(flattenList(info, (DirectiveInfo i) => i.expressions), |
+ equals(['fooExpr', 'ctrl.baz'])); |
+ }); |
- expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
- equals(['my-foo'])); |
}); |
- |
- it('should figure out attribute name from selector if dot(.) is used', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[blah][foo]', { |
- '.': '=>fooExpr' |
- }) |
- ]); |
- |
- expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
- equals(['foo'])); |
- }); |
- |
- it('should include exported expression attributes', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[blah][foo]', { |
- '.': '=>fooExpr' |
- }, ['baz']) |
- ]); |
- |
- expect(flattenList(info, (DirectiveInfo i) => i.expressionAttrs), |
- equals(['foo', 'baz'])); |
- }); |
- |
- it('should include exported expressions', () { |
- var info = extractDirectiveInfo([ |
- new DirectiveMetadata('MyFooAttrDirective', DIRECTIVE, '[blah][foo]', { |
- '.': '=>fooExpr' |
- }, null, ['ctrl.baz']) |
- ]); |
- |
- expect(flattenList(info, (DirectiveInfo i) => i.expressions), |
- equals(['fooExpr', 'ctrl.baz'])); |
- }); |
- |
-}); |
+} |
flattenList(list, map) => list.map(map).fold([], (prev, exprs) => |
new List.from(prev)..addAll(exprs)); |
@@ -126,6 +128,7 @@ List<DirectiveInfo> extractDirectiveInfo(List<DirectiveMetadata> metadata) { |
class MockDirectiveMetadataCollectingVisitor |
implements DirectiveMetadataCollectingVisitor { |
List<DirectiveMetadata> metadata; |
+ List<String> templates = <String>[]; |
MockDirectiveMetadataCollectingVisitor(List<DirectiveMetadata> this.metadata); |