Add test for comp values to same method

The test fails without the other change in this branch.
This commit is contained in:
Ross Allen
2015-03-02 15:43:15 -08:00
parent 8326a9ab2d
commit d028277f4c
2 changed files with 17 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
<template>
<div id="boundChild" value="{{value}}" negvalue="{{!bool}}" attrvalue$="{{attrvalue}}" computedvalue="{{computedvalue}}" camel-case="{{value}}"></div>
<div id="boundChild" value="{{value}}" negvalue="{{!bool}}" attrvalue$="{{attrvalue}}"
computedvalue="{{computedvalue}}" computedvaluetwo="{{computedvaluetwo}}" camel-case="{{value}}"></div>
</template>
<script>
Polymer({
@@ -29,12 +30,14 @@
},
computed: {
computedvalue: 'computeValue(value)',
computedvaluetwo: 'computeValue(valuetwo)',
computednotifyingvalue: 'computeNotifyingValue(notifyingvalue)',
computedFromMultipleValues: 'computeFromMultipleValues(sum1, sum2, divide)'
},
bind: {
value: 'valueChanged',
computedvalue: 'computedvalueChanged',
computedvaluetwo: 'computedvaluetwoChanged',
notifyingvalue: 'notifyingvalueChanged',
readonlyvalue: 'readonlyvalueChanged',
computedFromMultipleValues: 'computedFromMultipleValuesChanged'
@@ -44,6 +47,7 @@
return val + 1;
},
computedvalueChanged: function() {},
computedvaluetwoChanged: function() {},
notifyingvalueChanged: function() {},
readonlyvalueChanged: function() {},
computeNotifyingValue: function(val) {
@@ -121,4 +125,4 @@
}
}
});
</script>
</script>

View File

@@ -70,6 +70,17 @@ suite('single-element binding effects', function() {
});
});
test('computed values to same method updates', function(done) {
el.value = 44;
el.valuetwo = 144;
setTimeout(function() {
assert.equal(el.computedvalue, 45, 'Computed value not correct');
assert.equal(el.computedvaluetwo, 145, 'Computed value not correct');
assert.equal(el.$.boundChild.computedvalue, 45, 'Computed value not propagated to bound child');
done();
});
});
test('notification sent', function() {
var notified = 0;
el.addEventListener('notifyingvalue-changed', function(e) {