diff --git a/test/unit/element-disable-upgrade.html b/test/unit/element-disable-upgrade.html index 5cc27c3fe4..e83fd108d0 100644 --- a/test/unit/element-disable-upgrade.html +++ b/test/unit/element-disable-upgrade.html @@ -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'); } }); }); @@ -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() {