Skip to content

Commit

Permalink
Add test for observing id attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed Nov 17, 2017
1 parent 4b9170a commit c56f74f
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/unit/polymer.properties-element.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
static get properties() {
return {
prop: String,
noStomp: String
noStomp: String,
id: String
};
}

Expand All @@ -44,6 +45,15 @@

set noStomp(value) {}

get id() {
return super.id;
}

set id(value) {
this._setProperty('id', value);
super.id = value;
}

connectedCallback() {
super.connectedCallback();
this._calledConnectedCallback++;
Expand Down Expand Up @@ -241,10 +251,20 @@
assert.deepEqual(el._propertiesChanged.args[0][0], {prop: 'prop'});
});

test('properties: accessor for native property', function() {
el.setAttribute('id', 'yo');
assert.equal(el.id, 'yo');
el._flushProperties();
assert.isTrue(el._propertiesChanged.calledTwice);
assert.deepEqual(el._propertiesChanged.args[1][1], {id: 'yo'});
});

test('attributes', function() {
const fixtureEl = fixture('my-element-attr');
assert.equal(fixtureEl.prop, 'attr');
assert.equal(fixtureEl._callAttributeChangedCallback, 1);
fixtureEl.removeAttribute('prop');
assert.equal(fixtureEl.prop, null);
});

test('reflecting attributes', function() {
Expand Down

0 comments on commit c56f74f

Please sign in to comment.