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

Unified Diff: pkg/polymer_expressions/test/bindings_test.dart

Issue 213743012: [observe] provide notifications of keys/values changed for ObservableMap (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « pkg/observe/test/observable_map_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer_expressions/test/bindings_test.dart
diff --git a/pkg/polymer_expressions/test/bindings_test.dart b/pkg/polymer_expressions/test/bindings_test.dart
index e8e2f6c7a8a3d382e76aec747e7bd92e87404d07..d5e1063c32ad84bbec298cd5b6e1ed187fe593b8 100644
--- a/pkg/polymer_expressions/test/bindings_test.dart
+++ b/pkg/polymer_expressions/test/bindings_test.dart
@@ -47,16 +47,15 @@ main() => dirtyCheckZone().run(() {
'<template><span>{{x}}</span></template>'));
testDiv.append(template.createInstance(model, new PolymerExpressions()));
+ var el;
return new Future(() {
- var el = testDiv.query("span");
+ el = testDiv.query("span");
expect(el.text, 'abcde');
expect(model.x, 'abcde');
model.x = '___';
-
- return new Future(() {
- expect(model.x, '___');
- expect(el.text, '___');
- });
+ }).then(_nextMicrotask).then((_) {
+ expect(model.x, '___');
+ expect(el.text, '___');
});
});
@@ -69,7 +68,7 @@ main() => dirtyCheckZone().run(() {
testDiv.append(template.createInstance(model,
new PolymerExpressions()));
- return new Future(() {});
+ return _nextMicrotask(null);
}, onError: (e) {
expect('$e', startsWith("Error evaluating expression 'foo':"));
completer.complete(true);
@@ -118,9 +117,32 @@ main() => dirtyCheckZone().run(() {
subscription.cancel();
});
});
+
+
+ test('detects changes to ObservableMap keys/values', () {
+ var map = new ObservableMap.from({'a': 1, 'b': 2});
+ var template = templateBind(new Element.html('<template>'
+ '<template repeat="{{k in x.keys}}">{{k}}:{{x[k]}},</template>'
+ '</template>'));
+ var model = new NotifyModel(map);
+ testDiv.append(template.createInstance(model, new PolymerExpressions()));
+
+ return new Future(() {
+ expect(testDiv.text, 'a:1,b:2,');
+ map.remove('b');
+ map['c'] = 3;
+ }).then(_nextMicrotask).then((_) {
+ expect(testDiv.text, 'a:1,c:3,');
+ map['a'] = 4;
+ }).then(_nextMicrotask).then((_) {
+ expect(testDiv.text, 'a:4,c:3,');
+ });
+ });
});
});
+_nextMicrotask(_) => new Future(() {});
+
@reflectable
class NotifyModel extends ChangeNotifier {
var _x;
« no previous file with comments | « pkg/observe/test/observable_map_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698