Skip to content

Commit

Permalink
Add tests for data binding, remove unused instanceProps
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Mar 2, 2018
1 parent c36cca1 commit 9359a9b
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/vaadin-dialog.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@
}

const Templatizer = Polymer.Templatize.templatize(this._contentTemplate, this, {
instanceProps: {
detail: true,
target: true
},
forwardHostProp: function(prop, value) {
if (this._instance) {
this._instance.forwardHostProp(prop, value);
Expand Down
56 changes: 56 additions & 0 deletions test/vaadin-dialog_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,39 @@
</template>
</test-fixture>

<dom-module id="x-dialog">
<template>
<vaadin-dialog id="dialog">
<template>
<span>[[message]]</span>
<input value="{{text::input}}">
</template>
</vaadin-dialog>
</template>
<script>
window.addEventListener('WebComponentsReady', function() {
class XDialog extends Polymer.Element {
static get is() {
return 'x-dialog';
}
static get properties() {
return {
message: String,
text: String
};
}
}
window.customElements.define(XDialog.is, XDialog);
});
</script>
</dom-module>

<test-fixture id="binding">
<template>
<x-dialog></x-dialog>
</template>
</test-fixture>

<script>
describe('vaadin-dialog', () => {
var dialog, backdrop, overlay;
Expand Down Expand Up @@ -81,5 +114,28 @@
expect(openDialog).to.not.throw();
});
});

describe('vaadin-dialog data binding', () => {
let container, dialog, overlay;

beforeEach(() => {
container = fixture('binding');
dialog = container.$.dialog;
overlay = dialog.$.overlay;
dialog.opened = true;
});

it('dialog should bind parent property', () => {
container.message = 'foo';
expect(overlay.shadowRoot.querySelector('span').textContent.trim()).to.equal('foo');
});

it('dialog should support two-way data binding', () => {
const input = overlay.shadowRoot.querySelector('input');
input.value = 'bar';
input.dispatchEvent(new CustomEvent('input'));
expect(container.text).to.equal('bar');
});
});
</script>
</body>

0 comments on commit 9359a9b

Please sign in to comment.