Skip to content

Commit

Permalink
Merge pull request #85 from yomed/test-setstate-settimeout
Browse files Browse the repository at this point in the history
Add test case for using setState from setTimeout - #70
  • Loading branch information
patrick-steele-idem committed Aug 27, 2015
2 parents 60a7522 + 891d676 commit e5b2436
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/client/spec-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down

0 comments on commit e5b2436

Please sign in to comment.