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

Unified Diff: third_party/pkg/angular/lib/mock/log.dart

Issue 124053002: Adding Angular and dependent packages for testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 12 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/lib/mock/log.dart
diff --git a/third_party/pkg/angular/lib/mock/log.dart b/third_party/pkg/angular/lib/mock/log.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c0133b6331e73927dd07d9c65a3dcdfcf3c6da7e
--- /dev/null
+++ b/third_party/pkg/angular/lib/mock/log.dart
@@ -0,0 +1,59 @@
+part of angular.mock;
+
+/**
+ * A convenient way to assert the order in which the DOM elements are processed.
+ *
+ * In your test create:
+ *
+ * <div log="foo">...</div>
+ *
+ * And then assert:
+ *
+ * expect(logger).toEqual(['foo']);
+ */
+@NgDirective(
+ selector: '[log]',
+ map: const {
+ 'log': '@logMessage'
+ }
+)
+class LogAttrDirective implements NgAttachAware {
+ final Logger log;
+ String logMessage;
+ LogAttrDirective(this.log);
+ attach() => log(logMessage == '' ? 'LOG' : logMessage);
+}
+
+/**
+ * A convenient way to verify that a set of operations executed in a specific
+ * order. Simply inject the Logger into each operation and call:
+ *
+ * operation1(Logger logger) => logger('foo');
+ * operation2(Logger logger) => logger('bar');
+ *
+ * Then in the test:
+ *
+ * expect(logger).toEqual(['foo', 'bar']);
+ */
+class Logger extends ListBase {
+ final List tokens = [];
+
+ /**
+ * Add string token to the list.
+ */
+ call(dynamic text) => tokens.add(text);
+
+ /**
+ * Return a `;` separated list of recorded tokens.
+ */
+ String result() => tokens.join('; ');
+
+
+ int get length => tokens.length;
+
+ operator [](int index) => tokens[index];
+
+ void operator []=(int index, value) { tokens[index] = value; }
+
+ void set length(int newLength) { tokens.length = newLength; }
+}

Powered by Google App Engine
This is Rietveld 408576698