Skip to content

Commit

Permalink
Add test that late resolved functions don't warn
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Feb 12, 2016
1 parent b6abf26 commit 0037c53
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/unit/bind-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
13 changes: 13 additions & 0 deletions test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,19 @@
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',
Expand Down

0 comments on commit 0037c53

Please sign in to comment.