From d159b37ab60ebc5b82e53a191371aabb86f414b6 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Tue, 5 Feb 2013 12:10:05 -0500 Subject: [PATCH] Fix tests --- test/spec/ui/confirm.js | 9 +++++++-- test/spec/ui/flash.js | 10 +++++++++- test/spec/ui/inspector.js | 6 +++--- test/spec/ui/modal.js | 14 ++++++++++++-- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/test/spec/ui/confirm.js b/test/spec/ui/confirm.js index 428a8aa6c..59f1d06df 100644 --- a/test/spec/ui/confirm.js +++ b/test/spec/ui/confirm.js @@ -1,12 +1,17 @@ describe("iD.ui.confirm", function () { + + var elem; + beforeEach(function() { elem = d3.select('body').append('div'); }); + afterEach(function() { elem.remove(); }); + it('can be instantiated', function () { - var confirm = iD.ui.confirm(); + var confirm = iD.ui.confirm(elem); expect(confirm).to.be.ok; happen.keydown(document, {keyCode: 27}); // dismiss }); it('can be dismissed', function () { - var confirm = iD.ui.confirm(); + var confirm = iD.ui.confirm(elem); happen.click(confirm.select('button').node()); expect(confirm.node().parentNode).to.be.null; happen.keydown(document, {keyCode: 27}); // dismiss diff --git a/test/spec/ui/flash.js b/test/spec/ui/flash.js index b0314ffeb..527e8f18b 100644 --- a/test/spec/ui/flash.js +++ b/test/spec/ui/flash.js @@ -1,6 +1,14 @@ describe("iD.ui.flash", function () { var clock; + var elem; + + beforeEach(function() { + elem = d3.select('body').append('div'); + }); + + afterEach(function() { elem.remove(); }); + beforeEach(function () { clock = sinon.useFakeTimers(); }); @@ -10,7 +18,7 @@ describe("iD.ui.flash", function () { }); it('leaves after 1000 ms', function () { - var flash = iD.ui.flash(); + var flash = iD.ui.flash(elem); clock.tick(1610); expect(flash.node().parentNode).to.be.null; }); diff --git a/test/spec/ui/inspector.js b/test/spec/ui/inspector.js index eb5ea6be1..e92604a7a 100644 --- a/test/spec/ui/inspector.js +++ b/test/spec/ui/inspector.js @@ -1,10 +1,10 @@ describe("iD.ui.inspector", function () { var inspector, element, tags = {highway: 'residential'}, - entity, graph; + entity, graph, context; function render() { - inspector = iD.ui.inspector().graph(graph); + inspector = iD.ui.inspector().context(context); element = d3.select('body') .append('div') .attr('id', 'inspector-wrap') @@ -14,7 +14,7 @@ describe("iD.ui.inspector", function () { beforeEach(function () { entity = iD.Entity({type: 'node', id: "n12345", tags: tags}); - graph = iD.Graph([entity]); + context = iD(); render(); }); diff --git a/test/spec/ui/modal.js b/test/spec/ui/modal.js index d7f818d80..b91a05f99 100644 --- a/test/spec/ui/modal.js +++ b/test/spec/ui/modal.js @@ -1,6 +1,16 @@ describe("iD.ui.modal", function () { - it('can be instantiated', function () { - var modal = iD.ui.modal() + var elem; + + beforeEach(function() { + elem = d3.select('body').append('div'); + }); + + afterEach(function() { + elem.remove(); + }); + + it('can be instantiated', function() { + var modal = iD.ui.modal(elem) .select('.content') .text('foo'); expect(modal).to.be.ok;