Index: pkg/polymer/test/unbind_test.dart |
diff --git a/pkg/polymer/test/unbind_test.dart b/pkg/polymer/test/unbind_test.dart |
index 8bf725666e47d1fc86e88ed80355dd4958302ec7..13d80ef289c4c6cde3c0983b3fcf36e1c69b64ce 100644 |
--- a/pkg/polymer/test/unbind_test.dart |
+++ b/pkg/polymer/test/unbind_test.dart |
@@ -64,8 +64,12 @@ delay(x) => new Future.delayed(new Duration(milliseconds: 50), () => x); |
// TODO(jmesserly): fix this when it's easier to get a private symbol. |
final unboundSymbol = reflectClass(Polymer).declarations.keys |
.firstWhere((s) => MirrorSystem.getName(s) == '_unbound'); |
+final observersSymbol = reflectClass(Polymer).declarations.keys |
+ .firstWhere((s) => MirrorSystem.getName(s) == '_observers'); |
_unbound(node) => reflect(node).getField(unboundSymbol).reflectee; |
+_observerCount(node) => |
+ reflect(node).getField(observersSymbol).reflectee.length; |
unbindTests() { |
var xTest = document.querySelector('x-test'); |
@@ -77,38 +81,48 @@ unbindTests() { |
'element is bound when inserted'); |
expect(xTest.fooWasChanged, true, reason: |
'element is actually bound'); |
+ // Dart note: we don't have a way to check for the global count of |
+ // observables/bindables, so we just check the count in the node. |
+ expect(_observerCount(xTest), greaterThan(0)); |
xTest.remove(); |
}).then(delay).then((_) { |
expect(_unbound(xTest), true, reason: |
'element is unbound when removed'); |
+ expect(_observerCount(xTest), 0); |
return new XTest(); |
}).then(delay).then((node) { |
expect(_unbound(node), null, reason: |
'element is bound when not inserted'); |
node.foo = 'bar'; |
+ expect(_observerCount(node), greaterThan(0)); |
scheduleMicrotask(Observable.dirtyCheck); |
return node; |
}).then(delay).then((node) { |
expect(node.fooWasChanged, true, reason: 'node is actually bound'); |
+ node.unbindAll(); |
var n = new XTest(); |
n.cancelUnbindAll(); |
return n; |
}).then(delay).then((node) { |
expect(_unbound(node), null, reason: |
'element is bound when cancelUnbindAll is called'); |
+ expect(_observerCount(node), greaterThan(0)); |
node.unbindAll(); |
expect(_unbound(node), true, reason: |
'element is unbound when unbindAll is called'); |
+ expect(_observerCount(node), 0); |
var n = new XTest()..id = 'foobar!!!'; |
document.body.append(n); |
return n; |
}).then(delay).then((node) { |
expect(_unbound(node), null, reason: |
'element is bound when manually inserted'); |
+ expect(_observerCount(node), greaterThan(0)); |
node.remove(); |
return node; |
}).then(delay).then((node) { |
expect(_unbound(node), true, reason: |
'element is unbound when manually removed is called'); |
+ expect(_observerCount(node), 0); |
}); |
} |