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

Side by Side 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, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 part of angular.mock;
2
3 /**
4 * A convenient way to assert the order in which the DOM elements are processed.
5 *
6 * In your test create:
7 *
8 * <div log="foo">...</div>
9 *
10 * And then assert:
11 *
12 * expect(logger).toEqual(['foo']);
13 */
14 @NgDirective(
15 selector: '[log]',
16 map: const {
17 'log': '@logMessage'
18 }
19 )
20 class LogAttrDirective implements NgAttachAware {
21 final Logger log;
22 String logMessage;
23 LogAttrDirective(this.log);
24 attach() => log(logMessage == '' ? 'LOG' : logMessage);
25 }
26
27 /**
28 * A convenient way to verify that a set of operations executed in a specific
29 * order. Simply inject the Logger into each operation and call:
30 *
31 * operation1(Logger logger) => logger('foo');
32 * operation2(Logger logger) => logger('bar');
33 *
34 * Then in the test:
35 *
36 * expect(logger).toEqual(['foo', 'bar']);
37 */
38 class Logger extends ListBase {
39 final List tokens = [];
40
41 /**
42 * Add string token to the list.
43 */
44 call(dynamic text) => tokens.add(text);
45
46 /**
47 * Return a `;` separated list of recorded tokens.
48 */
49 String result() => tokens.join('; ');
50
51
52 int get length => tokens.length;
53
54 operator [](int index) => tokens[index];
55
56 void operator []=(int index, value) { tokens[index] = value; }
57
58 void set length(int newLength) { tokens.length = newLength; }
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698