Add more d3.timerFlush to avoid false test failures (hopefully)

This commit is contained in:
Bryan Housel
2017-04-24 16:15:41 -04:00
parent 129450f4ad
commit 3b54743f86
2 changed files with 12 additions and 8 deletions
+7 -4
View File
@@ -43,9 +43,10 @@ describe('iD.Map', function() {
expect(map.zoom(4)).to.equal(map);
map.zoomIn();
window.setTimeout(function() {
d3.timerFlush();
expect(map.zoom()).to.be.closeTo(5, 1e-6);
done();
}, 300);
}, 275);
});
});
@@ -54,9 +55,10 @@ describe('iD.Map', function() {
expect(map.zoom(4)).to.equal(map);
map.zoomOut();
window.setTimeout(function() {
d3.timerFlush();
expect(map.zoom()).to.be.closeTo(3, 1e-6);
done();
}, 300);
}, 275);
});
});
@@ -95,12 +97,13 @@ describe('iD.Map', function() {
describe('#centerEase', function() {
it('sets center', function(done) {
expect(map.center([10, 10])).to.equal(map);
expect(map.centerEase([20, 20])).to.equal(map);
expect(map.centerEase([20, 20], 250)).to.equal(map);
window.setTimeout(function() {
d3.timerFlush();
expect(map.center()[0]).to.be.closeTo(20, 1e-6);
expect(map.center()[1]).to.be.closeTo(20, 1e-6);
done();
}, 1000);
}, 275);
});
});
+5 -4
View File
@@ -8,7 +8,7 @@ describe('iD.uiFlash', function () {
.attr('id', 'footer-wrap');
});
afterEach(function () {
afterEach(function() {
d3.select('body > div').remove();
});
@@ -18,7 +18,7 @@ describe('iD.uiFlash', function () {
expect(content.classed('content')).to.be.ok;
});
it('flash is shown', function () {
it('flash is shown', function() {
iD.uiFlash(200);
var flashWrap = d3.selectAll('#flash-wrap');
var footerWrap = d3.selectAll('#footer-wrap');
@@ -26,15 +26,16 @@ describe('iD.uiFlash', function () {
expect(footerWrap.classed('footer-hide')).to.be.ok;
});
it('flash goes away', function (done) {
it('flash goes away', function(done) {
iD.uiFlash(200);
window.setTimeout(function() {
d3.timerFlush();
var flashWrap = d3.selectAll('#flash-wrap');
var footerWrap = d3.selectAll('#footer-wrap');
expect(flashWrap.classed('footer-hide')).to.be.ok;
expect(footerWrap.classed('footer-show')).to.be.ok;
done();
}, 500);
}, 225);
});
});