| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'package:observe/observe.dart'; | 6 import 'package:observe/observe.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 8 import 'observe_test_utils.dart'; | 8 import 'observe_test_utils.dart'; |
| 9 | 9 |
| 10 // This file contains code ported from: | 10 // This file contains code ported from: |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 }).then(newMicrotask).then((_) { | 195 }).then(newMicrotask).then((_) { |
| 196 expect(fooValues, ['baz']); | 196 expect(fooValues, ['baz']); |
| 197 expect(batValues, []); | 197 expect(batValues, []); |
| 198 }); | 198 }); |
| 199 }); | 199 }); |
| 200 | 200 |
| 201 test('Path Value With Indices', () { | 201 test('Path Value With Indices', () { |
| 202 var model = toObservable([]); | 202 var model = toObservable([]); |
| 203 var path = new PathObserver(model, '0'); | 203 var path = new PathObserver(model, '0'); |
| 204 path.open(expectAsync1((x) { | 204 path.open(expectAsync((x) { |
| 205 expect(path.value, 123); | 205 expect(path.value, 123); |
| 206 expect(x, 123); | 206 expect(x, 123); |
| 207 })); | 207 })); |
| 208 model.add(123); | 208 model.add(123); |
| 209 }); | 209 }); |
| 210 | 210 |
| 211 group('ObservableList', () { | 211 group('ObservableList', () { |
| 212 test('isNotEmpty', () { | 212 test('isNotEmpty', () { |
| 213 var model = new ObservableList(); | 213 var model = new ObservableList(); |
| 214 var path = new PathObserver(model, 'isNotEmpty'); | 214 var path = new PathObserver(model, 'isNotEmpty'); |
| 215 expect(path.value, false); | 215 expect(path.value, false); |
| 216 | 216 |
| 217 path.open(expectAsync1((_) { | 217 path.open(expectAsync((_) { |
| 218 expect(path.value, true); | 218 expect(path.value, true); |
| 219 })); | 219 })); |
| 220 model.add(123); | 220 model.add(123); |
| 221 }); | 221 }); |
| 222 | 222 |
| 223 test('isEmpty', () { | 223 test('isEmpty', () { |
| 224 var model = new ObservableList(); | 224 var model = new ObservableList(); |
| 225 var path = new PathObserver(model, 'isEmpty'); | 225 var path = new PathObserver(model, 'isEmpty'); |
| 226 expect(path.value, true); | 226 expect(path.value, true); |
| 227 | 227 |
| 228 path.open(expectAsync1((_) { | 228 path.open(expectAsync((_) { |
| 229 expect(path.value, false); | 229 expect(path.value, false); |
| 230 })); | 230 })); |
| 231 model.add(123); | 231 model.add(123); |
| 232 }); | 232 }); |
| 233 }); | 233 }); |
| 234 | 234 |
| 235 for (var createModel in [() => new TestModel(), () => new WatcherModel()]) { | 235 for (var createModel in [() => new TestModel(), () => new WatcherModel()]) { |
| 236 test('Path Observation - ${createModel().runtimeType}', () { | 236 test('Path Observation - ${createModel().runtimeType}', () { |
| 237 var model = createModel()..a = | 237 var model = createModel()..a = |
| 238 (createModel()..b = (createModel()..c = 'hello, world')); | 238 (createModel()..b = (createModel()..c = 'hello, world')); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 | 425 |
| 426 class WatcherModel extends Observable { | 426 class WatcherModel extends Observable { |
| 427 // TODO(jmesserly): dart2js does not let these be on the same line: | 427 // TODO(jmesserly): dart2js does not let these be on the same line: |
| 428 // @observable var a, b, c; | 428 // @observable var a, b, c; |
| 429 @observable var a; | 429 @observable var a; |
| 430 @observable var b; | 430 @observable var b; |
| 431 @observable var c; | 431 @observable var c; |
| 432 | 432 |
| 433 WatcherModel(); | 433 WatcherModel(); |
| 434 } | 434 } |
| OLD | NEW |