Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Unified Diff: third_party/pkg/angular/test/core/annotation_src_spec.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/angular/test/core/annotation_src_spec.dart
diff --git a/third_party/pkg/angular/test/core/annotation_src_spec.dart b/third_party/pkg/angular/test/core/annotation_src_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c3d7f8e44b0cc3dd7594deb4eeb6f7833014f941
--- /dev/null
+++ b/third_party/pkg/angular/test/core/annotation_src_spec.dart
@@ -0,0 +1,100 @@
+library annotation_src_spec;
+
+import 'package:angular/core/annotation_src.dart';
+import 'dart:mirrors';
+import '../_specs.dart';
+
+var _SYMBOL_NAME = new RegExp('"([^@]*).*"');
+_getName(VariableMirror v) => _SYMBOL_NAME.firstMatch(v.simpleName.toString()).group(1);
+
+Map<String, dynamic> variables(x) {
+ Map variables = {};
+ InstanceMirror mirror = reflect(x) as InstanceMirror;
+ ClassMirror type = mirror.type;
+ do {
+ type.declarations.forEach((k,v) {
+ if (v is VariableMirror && !v.isStatic) {
+ variables[_getName(v)] = mirror.getField(v.simpleName).reflectee;
+ }
+ });
+ } while ((type = type.superclass) != null);
+
+ return variables;
+}
+
+List<String> nullFields(x) {
+ var ret = [];
+ variables(x).forEach((k, v) {
+ if (v == null) ret.add(k);
+ });
+ return ret;
+}
+
+void main() => describe('annotations', () {
+ describe('component', () {
+ it('should set all fields on clone when all the fields are set', () {
+ var component = new Component(
+ template: '',
+ templateUrl: '',
+ cssUrl: [''],
+ applyAuthorStyles: true,
+ resetStyleInheritance: true,
+ publishAs: '',
+ module: (){},
+ map: {},
+ selector: '',
+ visibility: Directive.LOCAL_VISIBILITY,
+ exportExpressions: [],
+ exportExpressionAttrs: [],
+ useShadowDom: true
+ );
+
+ // Check that no fields are null
+ expect(nullFields(component)).toEqual([]);
+
+ // Check that the clone is the same as the original.
+ expect(variables(cloneWithNewMap(component, {}))).toEqual(variables(component));
+ });
+ });
+
+ describe('decorator', () {
+ it('should set all fields on clone when all the fields are set', () {
+ var decorator = new Decorator(
+ children: 'xxx',
+ map: {},
+ selector: '',
+ module: (){},
+ visibility: Directive.LOCAL_VISIBILITY,
+ exportExpressions: [],
+ exportExpressionAttrs: []
+ );
+
+ // Check that no fields are null
+ expect(nullFields(decorator)).toEqual([]);
+
+ // Check that the clone is the same as the original.
+ expect(variables(cloneWithNewMap(decorator, {}))).toEqual(variables(decorator));
+ });
+ });
+
+ describe('controller', () {
+ it('should set all fields on clone when all the fields are set', () {
+ var controller = new Controller(
+ publishAs: '',
+ children: 'xxx',
+ map: {},
+ selector: '',
+ module: (){},
+ visibility: Directive.LOCAL_VISIBILITY,
+ exportExpressions: [],
+ exportExpressionAttrs: []
+ );
+
+ // Check that no fields are null
+ expect(nullFields(controller)).toEqual([]);
+
+ // Check that the clone is the same as the original.
+ expect(variables(cloneWithNewMap(controller, {}))).toEqual(variables(controller));
+ });
+ });
+});
« no previous file with comments | « third_party/pkg/angular/test/change_detection/watch_group_spec.dart ('k') | third_party/pkg/angular/test/core/cache_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698