Skip to content

Commit

Permalink
Write test in attempt to isolate bug causing issue #3. Test doesn't t…
Browse files Browse the repository at this point in the history
…hrow any errors, but hey - new test!
  • Loading branch information
justinmanley committed Sep 8, 2014
1 parent ffe857b commit 32d87b6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion test/create/CreateTextboxSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ describe("L.Illustrate.Create.Textbox", function() {
var map;

beforeEach(function() {
map = new L.Map(document.createElement('div'));
map = new L.Map(document.createElement('div'))
.setView([0, 0], 15);
});

describe("_setShapeOptions", function() {
Expand Down Expand Up @@ -34,4 +35,25 @@ describe("L.Illustrate.Create.Textbox", function() {
expect(create.options.shapeOptions.weight).to.equal(options.borderWidth);
});
});

describe("#_drawShape", function() {
it("Should yield a textbox of the correct size.", function(done) {
var create = new L.Illustrate.Create.Textbox(map, {}),
start = new L.LatLng(0, 0),
size = new L.Point(200, 100),
latlng = map.layerPointToLatLng(map.latLngToLayerPoint(start).add(size));

create._startLatLng = start;
L.Draw.Rectangle.prototype._drawShape.call(create, latlng);

map.on('draw:created', function(event) {
var textbox = event.layer;

expect(textbox.getSize()).to.be.closeToPoint(size, 3);
done();
});

create._fireCreatedEvent();
});
});
});

0 comments on commit 32d87b6

Please sign in to comment.