diff --git a/test/spec/ol/coordinate.test.js b/test/spec/ol/coordinate.test.js index 20dde14807..e5168a5ea5 100644 --- a/test/spec/ol/coordinate.test.js +++ b/test/spec/ol/coordinate.test.js @@ -2,6 +2,47 @@ goog.provide('ol.test.coordinate'); describe('ol.coordinate', function() { + describe('#add', function() { + var coordinate, + delta; + + beforeEach(function() { + coordinate = [50.73, 7.1]; + delta = [-2, 3]; + }); + + it('returns a coordinate', function() { + var returnedCoordinate = ol.coordinate.add(coordinate, delta); + expect(returnedCoordinate).to.be.an('array'); + expect(returnedCoordinate).to.have.length(2); + }); + + it('adds the delta', function() { + var returnedCoordinate = ol.coordinate.add(coordinate, delta); + expect(returnedCoordinate[0]).to.eql(48.73); + expect(returnedCoordinate[1]).to.eql(10.1); + }); + + it('modifies in place', function() { + ol.coordinate.add(coordinate, delta); + expect(coordinate[0]).to.eql(48.73); + expect(coordinate[1]).to.eql(10.1); + }); + }); + + describe('#equals', function() { + var cologne = [50.93333, 6.95], + bonn1 = [50.73, 7.1], + bonn2 = [50.73000, 7.10000]; + + it('compares correctly', function() { + var bonnEqualsBonn = ol.coordinate.equals(bonn1, bonn2), + bonnEqualsCologne = ol.coordinate.equals(bonn1, cologne); + expect(bonnEqualsBonn).to.be(true); + expect(bonnEqualsCologne).to.be(false); + }); + }); + describe('#format', function() { var coordinate; beforeEach(function() { @@ -19,6 +60,35 @@ describe('ol.coordinate', function() { }); }); + describe('#createStringXY', function() { + var coordinate, + created, + formatted; + beforeEach(function() { + coordinate = [6.6123, 46.7919]; + created = null; + formatted = null; + }); + + it('returns a CoordinateFormatType', function() { + created = ol.coordinate.createStringXY(); + expect(created).to.be.a('function'); + + formatted = created(coordinate); + expect(formatted).to.be.a('string'); + expect(formatted).to.eql('7, 47'); + }); + + it('respects opt_fractionDigits', function() { + created = ol.coordinate.createStringXY(3); + expect(created).to.be.a('function'); + + formatted = created(coordinate); + expect(formatted).to.be.a('string'); + expect(formatted).to.eql('6.612, 46.792'); + }); + }); + describe('#closestOnSegment', function() { it('can handle points where the foot of the perpendicular is closest', function() {