mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Use sinon's fake timers
This commit is contained in:
@@ -10,7 +10,7 @@ iD.ui.flash = function() {
|
||||
|
||||
modal.on('click.flash', function() { modal.remove(); });
|
||||
|
||||
d3.timer(function() {
|
||||
setTimeout(function() {
|
||||
modal.remove();
|
||||
return true;
|
||||
}, 1000);
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
describe("iD.ui.flash", function () {
|
||||
var clock;
|
||||
|
||||
beforeEach(function () {
|
||||
clock = sinon.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
clock.restore();
|
||||
});
|
||||
|
||||
it('can be instantiated', function () {
|
||||
var flash = iD.ui.flash();
|
||||
expect(flash).to.be.ok;
|
||||
});
|
||||
it('leaves after 1000 ms', function (done) {
|
||||
|
||||
it('leaves after 1000 ms', function () {
|
||||
var flash = iD.ui.flash();
|
||||
window.setTimeout(function() {
|
||||
expect(flash.node().parentNode).to.be.null;
|
||||
done();
|
||||
}, 1200);
|
||||
clock.tick(1010);
|
||||
expect(flash.node().parentNode).to.be.null;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user