Skip to content

Commit

Permalink
Add more tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Orvell committed May 22, 2017
1 parent 4e0abe4 commit 633ce4f
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions test/unit/element-disable-upgrade.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
Polymer({
is: 'x-attach',
attached: function() {
this._wasAttached = true;
this._connectLog = this._connectLog || [];
this._connectLog.push('attached');
},
detached: function() {
this._wasDetached = true;
this._connectLog = this._connectLog || [];
this._connectLog.push('detached');
}
});
});
Expand Down Expand Up @@ -177,32 +179,51 @@
el = fixture('attach');
});
test('attached does not fire when element is not yet enabled', function() {
assert.notOk(el._wasAttached);
assert.notOk(el._connectLog);
el.removeAttribute('disable-upgrade');
assert.ok(el._wasAttached);
assert.equal(el._connectLog.length, 1);
assert.equal(el._connectLog[0], 'attached');
});
test('attached/detached do not fire when element is not yet enabled', function() {
el.parentNode.removeChild(el);
Polymer.dom.flush();
assert.notOk(el._wasAttached);
assert.notOk(el._wasDetached);
assert.notOk(el._connectLog);
el.removeAttribute('disable-upgrade');
assert.notOk(el._wasAttached);
assert.notOk(el._wasDetached);
assert.notOk(el._connectLog);
});
test('attached/detached do not fire when element is detached/attached when not yet enabled', function() {
var parent = el.parentNode;
parent.removeChild(el);
Polymer.dom.flush();
assert.notOk(el._wasAttached);
assert.notOk(el._wasDetached);
assert.notOk(el._connectLog);
parent.appendChild(el);
Polymer.dom.flush();
assert.notOk(el._wasAttached);
assert.notOk(el._wasDetached);
assert.notOk(el._connectLog);
assert.notOk(el._connectLog);
el.removeAttribute('disable-upgrade');
assert.ok(el._wasAttached);
assert.notOk(el._wasDetached);
assert.equal(el._connectLog.length, 1);
assert.equal(el._connectLog[0], 'attached');
});

test('attached/detached fire as expected after element is enabled', function() {
var parent = el.parentNode;
parent.removeChild(el);
Polymer.dom.flush();
assert.notOk(el._connectLog);
parent.appendChild(el);
Polymer.dom.flush();
assert.notOk(el._connectLog);
el.removeAttribute('disable-upgrade');
assert.equal(el._connectLog.length, 1);
assert.equal(el._connectLog[0], 'attached');
parent.removeChild(el);
Polymer.dom.flush();
assert.equal(el._connectLog.length, 2);
assert.equal(el._connectLog[1], 'detached');
parent.appendChild(el);
Polymer.dom.flush();
assert.equal(el._connectLog.length, 3);
assert.equal(el._connectLog[2], 'attached');
});
});
suite('disableUpgrade and Databinding', function() {
Expand Down

0 comments on commit 633ce4f

Please sign in to comment.