diff --git a/test/client/spec-widget.js b/test/client/spec-widget.js index ae14e77..4b9a438 100644 --- a/test/client/spec-widget.js +++ b/test/client/spec-widget.js @@ -521,6 +521,41 @@ describe('widget' , function() { expect(widget.state.count).to.equal(30); }); + + it('should preserve state set from setTimeout when rerendered', function(done) { + var targetEl = document.getElementById('target'); + var widget = require('../fixtures/components/app-stateful-rerender') + .render({ + name: 'Frank', + count: 30 + }) + .appendTo(targetEl) + .getWidget(); + + setTimeout(function(){ + widget.setState('count', 25); + widget.update(); + expect(widget.state.count).to.equal(25); + expect(targetEl.innerHTML).to.contain('Hello Frank! You have 25 new messages.'); + }, 25); + + setTimeout(function(){ + widget.setState('count', 50); + widget.update(); + expect(widget.state.count).to.equal(50); + expect(targetEl.innerHTML).to.contain('Hello Frank! You have 50 new messages.'); + done(); + }, 50); + + setTimeout(function(){ + widget.setState('count', 0); + widget.update(); + expect(widget.state.count).to.equal(0); + expect(targetEl.innerHTML).to.contain('Hello Frank! You have 0 new messages.'); + }, 0); + + }); + it('should allow DOM event listeners on repeated elements for non-bubbling events', function() { var targetEl = document.getElementById('target');