| OLD | NEW |
| (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 } |
| OLD | NEW |