Add test that late resolved functions don't warn

This commit is contained in:
herr kaste 2016-02-12 22:38:20 +01:00
parent b6abf26fda
commit 0037c535c8
2 changed files with 44 additions and 0 deletions

View File

@ -620,4 +620,35 @@
});
})();
</script>
</dom-module>
<dom-module id="x-bind-computed-property-late-translator">
<template>
<div id="check">[[translate(message)]]</div>
</template>
<script>
Polymer({
is: 'x-bind-computed-property-late-translator',
properties: {
message: {
type: String,
value: 'Hello'
},
translate: {
type: Function,
computed: '_computeTranslateFn(translator)'
},
translator: {
type: Function,
},
},
_computeTranslateFn: function(translator) {
return function(message) {
return translator(message);
}
},
});
</script>
</dom-module>

View File

@ -310,6 +310,19 @@ suite('computed bindings with dynamic functions', function() {
assert.equal(el.$.check.textContent, 'changed: Hello World.');
});
test('annotated computation / late resolved dynamic function', function() {
el = document.createElement('x-bind-computed-property-late-translator');
document.body.appendChild(el);
assert.equal(el.$.check.textContent.trim(), '');
el.translator = function(message) {
return 'translated: ' + message;
};
assert.equal(el.$.check.textContent, 'translated: Hello');
});
test('observer with dynamic function', function() {
Polymer({
is: 'x-observer-with-dynamic-function',