Skip to content

Commit

Permalink
Set timeout for fireClick, otherwise IE8 breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
javve committed Feb 3, 2014
1 parent 57cb63a commit 2a39183
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions test/test.buttons.js
Expand Up @@ -66,17 +66,22 @@ describe('Button', function() {
});

it('should switch sorting order when clicking multiple times', function(done) {
this.timeout(5000);
var sortRun = 0;
list.on('sortComplete', function() {
sortRun++;
if (sortRun == 1) {
expect($('#sort1').hasClass('asc')).to.be(true);
expect($('#sort1').hasClass('desc')).to.be(false);
fireClick($('#sort1')[0]);
setTimeout(function() {
fireClick($('#sort1')[0]);
}, 50);
} else if (sortRun == 2) {
expect($('#sort1').hasClass('asc')).to.be(false);
expect($('#sort1').hasClass('desc')).to.be(true);
fireClick($('#sort1')[0]);
setTimeout(function() {
fireClick($('#sort1')[0]);
}, 50);
} else if (sortRun == 3) {
expect($('#sort1').hasClass('asc')).to.be(true);
expect($('#sort1').hasClass('desc')).to.be(false);
Expand All @@ -89,6 +94,7 @@ describe('Button', function() {
});

it('should sort with predefined order', function(done) {
this.timeout(10000);
var sortRun = 0;
list.on('sortComplete', function() {
sortRun++;
Expand All @@ -99,31 +105,39 @@ describe('Button', function() {
expect($('#sort2').hasClass('desc')).to.be(false);
expect($('#sort3').hasClass('asc')).to.be(false);
expect($('#sort3').hasClass('desc')).to.be(false);
fireClick($('#sort2')[0]);
setTimeout(function() {
fireClick($('#sort2')[0]);
}, 50);
} else if (sortRun == 2) {
expect($('#sort1').hasClass('asc')).to.be(false);
expect($('#sort1').hasClass('desc')).to.be(false);
expect($('#sort2').hasClass('asc')).to.be(true);
expect($('#sort2').hasClass('desc')).to.be(false);
expect($('#sort3').hasClass('asc')).to.be(false);
expect($('#sort3').hasClass('desc')).to.be(false);
fireClick($('#sort2')[0]);
setTimeout(function() {
fireClick($('#sort2')[0]);
}, 50);
} else if (sortRun == 3) {
expect($('#sort1').hasClass('asc')).to.be(false);
expect($('#sort1').hasClass('desc')).to.be(false);
expect($('#sort2').hasClass('asc')).to.be(true);
expect($('#sort2').hasClass('desc')).to.be(false);
expect($('#sort3').hasClass('asc')).to.be(false);
expect($('#sort3').hasClass('desc')).to.be(false);
fireClick($('#sort3')[0]);
setTimeout(function() {
fireClick($('#sort3')[0]);
}, 50);
} else if (sortRun == 4) {
expect($('#sort1').hasClass('asc')).to.be(false);
expect($('#sort1').hasClass('desc')).to.be(false);
expect($('#sort2').hasClass('asc')).to.be(false);
expect($('#sort2').hasClass('desc')).to.be(false);
expect($('#sort3').hasClass('asc')).to.be(false);
expect($('#sort3').hasClass('desc')).to.be(true);
fireClick($('#sort3')[0]);
setTimeout(function() {
fireClick($('#sort3')[0]);
}, 50);
} else if (sortRun == 5) {
expect($('#sort1').hasClass('asc')).to.be(false);
expect($('#sort1').hasClass('desc')).to.be(false);
Expand Down

0 comments on commit 2a39183

Please sign in to comment.