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

Unified Diff: packages/observable/test/observable_list_test.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 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
« no previous file with comments | « packages/observable/test/list_change_test.dart ('k') | packages/observable/test/observable_map_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/observable/test/observable_list_test.dart
diff --git a/packages/observe/test/observable_list_test.dart b/packages/observable/test/observable_list_test.dart
similarity index 78%
rename from packages/observe/test/observable_list_test.dart
rename to packages/observable/test/observable_list_test.dart
index adc6e402ebb5e9b29609f4ee713e5211aed9e9f6..0a29fa3f5776e651b4fefa478f735ca2b4c801cc 100644
--- a/packages/observe/test/observable_list_test.dart
+++ b/packages/observable/test/observable_list_test.dart
@@ -1,13 +1,15 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
-import 'package:observe/observe.dart';
-import 'package:unittest/unittest.dart';
-import 'observe_test_utils.dart';
-main() => dirtyCheckZone().run(_runTests);
+import 'package:observable/observable.dart';
+import 'package:test/test.dart';
+
+import 'observable_test_utils.dart';
+
+main() => _runTests();
_runTests() {
// TODO(jmesserly): need all standard List API tests.
@@ -24,12 +26,11 @@ _runTests() {
}
group('observe length', () {
-
ObservableList list;
List<ChangeRecord> changes;
setUp(() {
- list = toObservable([1, 2, 3]);
+ list = toObservable([1, 2, 3]) as ObservableList;
changes = null;
sub = list.changes.listen((records) {
changes = getPropertyChangeRecords(records, #length);
@@ -46,7 +47,7 @@ _runTests() {
});
});
- test('removeObject', () {
+ test('removeObject changes length', () {
list.remove(2);
expect(list, orderedEquals([1, 3]));
@@ -93,9 +94,9 @@ _runTests() {
List<ListChangeRecord> changes;
setUp(() {
- list = toObservable([1, 2, 3]);
+ list = toObservable([1, 2, 3]) as ObservableList;
changes = null;
- sub = list.listChanges.listen((records) {
+ sub = list.listChanges.listen((List<ListChangeRecord> records) {
changes = getListChangeRecords(records, 1);
});
});
@@ -114,7 +115,9 @@ _runTests() {
list[1] = 777;
expect(list, [1, 777, 3]);
return new Future(() {
- expectChanges(changes, [_change(1, addedCount: 1, removed: [2])]);
+ expectChanges(changes, [
+ _change(1, addedCount: 1, removed: [2])
+ ]);
});
});
@@ -149,7 +152,9 @@ _runTests() {
list.length = 1;
expect(list, [1]);
return new Future(() {
- expectChanges(changes, [_change(1, removed: [2, 3])]);
+ expectChanges(changes, [
+ _change(1, removed: [2, 3])
+ ]);
});
});
@@ -180,16 +185,15 @@ _runTests() {
});
group('change records', () {
-
List<ChangeRecord> propRecords;
List<ListChangeRecord> listRecords;
setUp(() {
- list = toObservable([1, 2, 3, 1, 3, 4]);
+ list = toObservable([1, 2, 3, 1, 3, 4]) as ObservableList;
propRecords = null;
listRecords = null;
- sub = list.changes.listen((r) { propRecords = r; });
- sub2 = list.listChanges.listen((r) { listRecords = r; });
+ sub = list.changes.listen((r) => propRecords = r);
+ sub2 = list.listChanges.listen((r) => listRecords = r);
});
tearDown(sharedTearDown);
@@ -203,7 +207,7 @@ _runTests() {
expect(list.lastIndexOf(1), 3);
expect(list.last, 4);
var copy = new List<int>();
- list.forEach((i) { copy.add(i); });
+ list.forEach((int i) => copy.add(i));
expect(copy, orderedEquals([1, 2, 3, 1, 3, 4]));
return new Future(() {
// no change from read-only operators
@@ -222,7 +226,7 @@ _runTests() {
_lengthChange(6, 7),
_lengthChange(7, 8),
]);
- expectChanges(listRecords, [ _change(6, addedCount: 2) ]);
+ expectChanges(listRecords, [_change(6, addedCount: 2)]);
});
});
@@ -232,7 +236,9 @@ _runTests() {
return new Future(() {
expectChanges(propRecords, null);
- expectChanges(listRecords, [ _change(1, addedCount: 1, removed: [2]) ]);
+ expectChanges(listRecords, [
+ _change(1, addedCount: 1, removed: [2])
+ ]);
});
});
@@ -242,7 +248,9 @@ _runTests() {
return new Future(() {
expectChanges(propRecords, [_lengthChange(6, 5)]);
- expectChanges(listRecords, [_change(5, removed: [4])]);
+ expectChanges(listRecords, [
+ _change(5, removed: [4])
+ ]);
});
});
@@ -252,7 +260,9 @@ _runTests() {
return new Future(() {
expectChanges(propRecords, [_lengthChange(6, 3)]);
- expectChanges(listRecords, [_change(1, removed: [2, 3, 1])]);
+ expectChanges(listRecords, [
+ _change(1, removed: [2, 3, 1])
+ ]);
});
});
@@ -273,7 +283,8 @@ _runTests() {
var list = toObservable([3, 1]);
// Dummy listener to record changes.
// TODO(jmesserly): should we just record changes always, to support the sync api?
- sub = list.listChanges.listen((records) => null);
+ sub = list.listChanges.listen((List<ListChangeRecord> records) => null)
+ as StreamSubscription;
list.sort();
expect(list.deliverListChanges(), true);
list.sort();
@@ -281,18 +292,20 @@ _runTests() {
list.sort();
expect(list.deliverListChanges(), false);
});
-
+
test('clear', () {
list.clear();
expect(list, []);
return new Future(() {
expectChanges(propRecords, [
- _lengthChange(6, 0),
- new PropertyChangeRecord(list, #isEmpty, false, true),
- new PropertyChangeRecord(list, #isNotEmpty, true, false),
+ _lengthChange(6, 0),
+ new PropertyChangeRecord(list, #isEmpty, false, true),
+ new PropertyChangeRecord(list, #isNotEmpty, true, false),
+ ]);
+ expectChanges(listRecords, [
+ _change(0, removed: [1, 2, 3, 1, 3, 4])
]);
- expectChanges(listRecords, [_change(0, removed: [1, 2, 3, 1, 3, 4])]);
});
});
});
@@ -300,9 +313,8 @@ _runTests() {
ObservableList list;
-_lengthChange(int oldValue, int newValue) =>
+PropertyChangeRecord _lengthChange(int oldValue, int newValue) =>
new PropertyChangeRecord(list, #length, oldValue, newValue);
-_change(index, {removed: const [], addedCount: 0}) => new ListChangeRecord(
- list, index, removed: removed, addedCount: addedCount);
-
+_change(int index, {List removed: const [], int addedCount: 0}) =>
+ new ListChangeRecord(list, index, removed: removed, addedCount: addedCount);
« no previous file with comments | « packages/observable/test/list_change_test.dart ('k') | packages/observable/test/observable_map_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698