diff --git a/test/spec/api/bounds.test.js b/test/spec/api/bounds.test.js deleted file mode 100644 index 2b56372aa2..0000000000 --- a/test/spec/api/bounds.test.js +++ /dev/null @@ -1,42 +0,0 @@ -describe("ol.bounds", function() { - - it("allows flexible construction", function() { - var bounds, proj; - - // array with min/max - bounds = ol.bounds([1, 2, 3, 4]); - - expect(bounds.minX()).toBe(1); - expect(bounds.minY()).toBe(2); - expect(bounds.maxX()).toBe(3); - expect(bounds.maxY()).toBe(4); - - // object config - bounds = ol.bounds({ - minX: 9, maxX: 10, minY: 11, maxY: 12, - projection: ol.projection("bar") - }); - - expect(bounds.minX()).toBe(9); - expect(bounds.maxX()).toBe(10); - expect(bounds.minY()).toBe(11); - expect(bounds.maxY()).toBe(12); - proj = bounds.projection(); - expect(proj).toBeA(ol.Projection); - expect(proj.code()).toBe("bar"); - - }); - - it("raises an error on invalid keys", function() { - expect(function() { - ol.bounds({ - minX: 9, - minY: 10, - maxX: 11, - maxWhy: 12 - }); - }).toThrow(); - }); - -}); - diff --git a/test/spec/api/feature.test.js b/test/spec/api/feature.test.js deleted file mode 100644 index e65437246e..0000000000 --- a/test/spec/api/feature.test.js +++ /dev/null @@ -1,79 +0,0 @@ -describe("ol.feature", function() { - - it("should be easy to make a feature", function() { - var feat = ol.feature(); - - expect(feat).toBeA(ol.Feature); - }); - - it("should be easy to set feature attribute", function() { - - var feat = ol.feature(); - feat.set('foo', 'bar'); - - expect(feat).toBeA(ol.Feature); - expect(feat.get('foo')).toBe('bar'); - }); - - it("calling set with one argument", function() { - - var feat = ol.feature(); - feat.set('foo'); - - expect(feat.get('foo')).toBe(undefined); - }); - - it("should be easy to set feature geometry", function() { - - var feat = ol.feature(); - var point = ol.geom.point([21, 4]); - feat.geometry(point); - - var geom = feat.geometry(); - expect(feat).toBeA(ol.Feature); - expect(geom.x()).toBe(21); - expect(geom.y()).toBe(4); - }); - - it("should be easy to create a feature from object literals", function() { - - var feat = ol.feature({ - properties: { - foo: 'bar', - two: 'deux', - size: 3, - flag: true - }, - geometry: ol.geom.point([56, 22]) - }); - - var geom = feat.geometry(); - expect(feat).toBeA(ol.Feature); - expect(geom.x()).toBe(56); - expect(geom.y()).toBe(22); - expect(feat.get('foo')).toBe('bar'); - expect(feat.get('two')).toBe('deux'); - expect(feat.get('size')).toBe(3); - expect(feat.get('flag')).toBe(true); - }); - - /* - it("should be easy to create a feature from GeoJSON", function() { - - var geoJson = { - type: "Feature", - geometry: {type: "Point", coordinates: [102.0, 0.5]}, - properties: {prop0: "value0"} - }; - var feat = ol.feature(geoJson); - - var geom = feat.geometry(); - expect(feat).toBeA(ol.Feature); - expect(geom.x()).toBe(102.0); - expect(geom.y()).toBe(0.5); - expect(feat.get('prop0')).toBe('value0'); - }); - */ - -}); - diff --git a/test/spec/api/geom/collection.test.js b/test/spec/api/geom/collection.test.js deleted file mode 100644 index 2607b2ec5a..0000000000 --- a/test/spec/api/geom/collection.test.js +++ /dev/null @@ -1,240 +0,0 @@ -describe("ol.geom.collection", function() { - var c; - beforeEach(function() { - c = ol.geom.collection([ - ol.geom.point([0, 1]), - ol.geom.linestring([ - ol.geom.point([2, 3]), - ol.geom.point([4, 5]) - ]) - ]); - }); - - afterEach(function() { - c = null; - }); - describe("can construct instances with some components", function() { - it("works for instances of ol.geom.Geometry", function(){ - expect( c ).toBeA( ol.geom.Collection ); - }); - }); - - describe("can construct instances without any components", function() { - - it("works with an empty array", function(){ - c = ol.geom.collection([]); - - expect( c ).toBeA( ol.geom.Collection ); - }); - - it("works without arguments", function(){ - c = ol.geom.collection(); - - expect( c ).toBeA( ol.geom.Collection ); - }); - }); - - describe("the method 'add'", function() { - it("exists", function(){ - expect( c.add ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - it("works with a single point specification and an index", function(){ - var p = ol.geom.point([24,7]); - c.add(p, 0); - - expect(c.components().length).toBe(3); - - var firstComponent = c.components()[0]; - - expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' ); - }); - - it("cannot add 'ol.geom.collection'", function(){ - expect(function(){ - c.add( - ol.geom.collection([ - ol.geom.point([5,25]), - ol.geom.point([6,36]) - ]) - ); - }).toThrow(); - }); - - it("allows 'ol.geom.multi*' (even though these are technically ol.geom.collections)", function(){ - expect(function(){ - c.add( - ol.geom.multipoint([ - ol.geom.point([5,25]), - ol.geom.point([6,36]) - ]) - ); - }).not.toThrow(); - }); - - it("the index is functional", function(){ - var p = ol.geom.point([24,7]); - c.add(p, 1); - - expect(c.components().length).toBe(3); - - var firstComponent = c.components()[0], // untouched - secondComponent = c.components()[1], // this should be ours - thirdComponent = c.components()[2]; // shifted here - - expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' ); - expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' ); - expect( thirdComponent ).toBeA( ol.geom.LineString ); - }); - - it("the index is optional", function(){ - var p = ol.geom.point([24,7]); - c.add(p); - - expect(c.components().length).toBe(3); - - var thirdComponent = c.components()[2]; - expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' ); - }); - - it("returns the collection instance", function(){ - var p = ol.geom.point([24,7]); - var returned = c.add(p); - - expect(returned).toBe(c); - }); - }); - }); - - describe("the method 'addAll'", function(){ - it("exists", function(){ - expect( c.addAll ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - - it("works with an array of points and an index", function(){ - var ps = [ - ol.geom.point([24,7]), - ol.geom.point([7,11]) - ]; - c.addAll(ps, 0); - - expect(c.components().length).toBe(4); - - var firstComponent = c.components()[0], - secondComponent = c.components()[1]; - - expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '24,7' ); - expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '7,11' ); - }); - - it("the index is functional", function(){ - var ps = [ - ol.geom.point([24,7]), - ol.geom.point({x:7, y:11}) - ]; - c.addAll(ps, 1); - - expect(c.components().length).toBe(4); - - var firstComponent = c.components()[0], // untouched - secondComponent = c.components()[1], // this should be ours - thirdComponent = c.components()[2], // this should be ours - fourthComponent = c.components()[3]; // shifted here - - expect( firstComponent.x() + ',' + firstComponent.y() ).toBe( '0,1' ); - expect( secondComponent.x() + ',' + secondComponent.y() ).toBe( '24,7' ); - expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '7,11' ); - expect( fourthComponent ).toBeA( ol.geom.LineString ); - }); - - it("the index is optional", function(){ - var ps = [ - ol.geom.point([24,7]), - ol.geom.point({x:7, y:11}) - ]; - c.addAll(ps); - - expect(c.components().length).toBe(4); - - var thirdComponent = c.components()[2], - fourthComponent = c.components()[3]; - expect( thirdComponent.x() + ',' + thirdComponent.y() ).toBe( '24,7' ); - expect( fourthComponent.x() + ',' + fourthComponent.y() ).toBe( '7,11' ); - }); - - it("returns the collection instance", function(){ - var ps = [ - ol.geom.point([24,7]), - ol.geom.point({x:7, y:11}) - ]; - var returned = c.addAll(ps); - - expect(returned).toBe(c); - }); - }); - }); - - - describe("the method 'remove'", function() { - it("exists", function(){ - expect( c.add ).toBeA( Function ); - }); - - it("works with a single point", function(){ - var p = c.components()[0]; - c.remove(p); - expect(c.components().length).toBe(1); - var firstComponent = c.components()[0]; - expect( firstComponent ).toBeA( ol.geom.LineString ); - }); - - it("works with an array of point specifications", function(){ - var ps = [ - c.components()[1], - c.components()[0] - ]; - c.remove(ps); - expect(c.components().length).toBe(0); - }); - }); - - describe("the centroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(c.centroid()).toBeA(ol.geom.Point); - }); - - it("does not choke when components returns a null centroid", function(){ - var centroid; - expect( - function(){ - c.add(new ol.geom.linestring([])); - centroid = c.centroid(); - } - ).not.toThrow(); - - expect(centroid).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - c = ol.geom.collection([ - ol.geom.point([10,10]), - ol.geom.point([30,30]), - ol.geom.linestring([ - ol.geom.point([10,10]), - ol.geom.point([10,30]), - ol.geom.point([30,30]), - ol.geom.point([30,10]) - ]) - ]); - var centroid = c.centroid(); - expect(centroid.x() + ',' + centroid.y()).toBe('20,20'); - }); - }); -}); - - - - diff --git a/test/spec/api/geom/geom.test.js b/test/spec/api/geom/geom.test.js deleted file mode 100644 index 2a3e9f4a20..0000000000 --- a/test/spec/api/geom/geom.test.js +++ /dev/null @@ -1,48 +0,0 @@ -describe("ol.geom.geometry", function() { - var g; - - beforeEach(function() { - g = ol.geom.geometry(); - }); - - afterEach(function() { - g = null; - }); - - - it("constructs instances", function() { - expect( g ).toBeA( ol.geom.Geometry ); - }); - - it("can set bounds", function() { - var oldBounds = g.bounds(); - - expect(oldBounds).toBeUndefined(); - - var b = ol.bounds([0,1,2,3]); - g.bounds(b); - var gotBounds = g.bounds(); - - expect(gotBounds).not.toBeUndefined(); - }); - - it("can get bounds", function() { - var b = ol.bounds([0,1,2,3]); - g.bounds(b); - var gotBounds = g.bounds(); - - expect(gotBounds).toEqual(jasmine.any(ol.Bounds)); - - }); - - it("sets and gets the correct bounds", function() { - var b = ol.bounds([0,1,2,3]); - g.bounds(b); - var gotBounds = g.bounds(); - - expect(gotBounds.minX()).toEqual(0); - expect(gotBounds.minY()).toEqual(1); - expect(gotBounds.maxX()).toEqual(2); - expect(gotBounds.maxY()).toEqual(3); - }); -}); diff --git a/test/spec/api/geom/linestring.test.js b/test/spec/api/geom/linestring.test.js deleted file mode 100644 index 2b401de42b..0000000000 --- a/test/spec/api/geom/linestring.test.js +++ /dev/null @@ -1,243 +0,0 @@ -describe("ol.geom.linestring", function() { - var ls; - beforeEach(function() { - ls = ol.geom.linestring([ - {x:0, y:1}, - {x:2, y:3} - ]); - }); - - afterEach(function() { - ls = null; - }); - describe("can construct instances with some vertices", function() { - it("works for the object notation of vertices", function(){ - expect( ls ).toBeA( ol.geom.LineString ); - }); - - it("works for the array notation of vertices", function(){ - ls = ol.geom.linestring([ - [0, 1], - [2, 3] - ]); - - expect( ls ).toBeA( ol.geom.LineString ); - }); - - it("works for real vertices", function(){ - ls = ol.geom.linestring([ - ol.geom.point([0,1]), - ol.geom.point([2,3]) - ]); - - expect( ls ).toBeA( ol.geom.LineString ); - }); - }); - - describe("can construct instances without any vertices", function() { - - it("works with an empty array", function(){ - ls = ol.geom.linestring([]); - - expect( ls ).toBeA( ol.geom.LineString ); - }); - - it("works without arguments", function(){ - ls = ol.geom.linestring(); - - expect( ls ).toBeA( ol.geom.LineString ); - }); - }); - - describe("the method 'add'", function() { - it("exists", function(){ - expect( ls.add ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - it("works with a single vertex specification and an index", function(){ - var p = ol.geom.point([24,7]); - ls.add(p, 0); - - expect(ls.vertices().length).toBe(3); - - var firstPoint = ls.vertices()[0]; - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("works with point instance", function(){ - ls = ol.geom.linestring(); - ls.add(ol.geom.point([24,7])); - expect(ls.vertices().length).toBe(1); - var firstPoint = ls.vertices()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("works with array specifications", function(){ - ls = ol.geom.linestring(); - ls.add([24,7]); - expect(ls.vertices().length).toBe(1); - var firstPoint = ls.vertices()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("works with object specifications", function(){ - ls = ol.geom.linestring(); - ls.add({x:24,y:7}); - expect(ls.vertices().length).toBe(1); - var firstPoint = ls.vertices()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("the index is functional", function(){ - var p = ol.geom.point([24,7]); - ls.add(p, 1); - - expect(ls.vertices().length).toBe(3); - - var firstPoint = ls.vertices()[0], // untouched - secondPoint = ls.vertices()[1], // this should be ours - thirdPoint = ls.vertices()[2]; // shifted here - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' ); - expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' ); - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' ); - }); - - it("the index is optional", function(){ - var p = ol.geom.point([24,7]); - ls.add(p); - - expect(ls.vertices().length).toBe(3); - - var thirdPoint = ls.vertices()[2]; - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' ); - }); - - it("returns the linestring instance", function(){ - var p = ol.geom.point([24,7]); - var returned = ls.add(p); - - expect(returned).toBe(ls); - }); - }); - }); - - describe("the method 'addAll'", function(){ - it("exists", function(){ - expect( ls.addAll ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - - it("works with an array of point specifications and an index", function(){ - var ps = [ - ol.geom.point([24,7]), - ol.geom.point([7,11]) - ]; - ls.addAll(ps, 0); - - expect(ls.vertices().length).toBe(4); - - var firstPoint = ls.vertices()[0], - secondPoint = ls.vertices()[1]; - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' ); - }); - - it("the index is functional", function(){ - var ps = [ - [24,7], - {x:7, y:11} - ]; - ls.addAll(ps, 1); - - expect(ls.vertices().length).toBe(4); - - var firstPoint = ls.vertices()[0], // untouched - secondPoint = ls.vertices()[1], // this should be ours - thirdPoint = ls.vertices()[2], // this should be ours - fourthPoint = ls.vertices()[3]; // shifted here - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' ); - expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' ); - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' ); - expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' ); - }); - - it("the index is optional", function(){ - var ps = [ - [24,7], - {x:7, y:11} - ]; - ls.addAll(ps); - - expect(ls.vertices().length).toBe(4); - - var thirdPoint = ls.vertices()[2], - fourthPoint = ls.vertices()[3]; - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' ); - expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' ); - }); - - it("returns the linestring instance", function(){ - var ps = [ - [24,7], - {x:7, y:11} - ]; - var returned = ls.addAll(ps); - - expect(returned).toBe(ls); - }); - }); - }); - - describe("the method 'remove'", function() { - it("exists", function(){ - expect( ls.remove ).toBeA( Function ); - }); - - it("works with a single point", function(){ - var p = ls.vertices()[0]; - ls.remove(p); - expect(ls.vertices().length).toBe(1); - var firstPoint = ls.vertices()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' ); - }); - - it("works with an array of point specifications", function(){ - var ps = [ - ls.vertices()[1], - ls.vertices()[0] - ]; - ls.remove(ps); - expect(ls.vertices().length).toBe(0); - }); - }); - - describe("the centroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(ls.centroid()).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - - ls = ol.geom.linestring([ - ol.geom.point([0.5, 1]), - ol.geom.point([1, 1.5]), - ol.geom.point([1.5, 1]), - ol.geom.point([1, 0.5]) - ]); - - var c = ls.centroid(); - - expect(c.x() + ',' + c.y()).toBe('1,1'); - }); - }); -}); - - - - diff --git a/test/spec/api/geom/multilinestring.test.js b/test/spec/api/geom/multilinestring.test.js deleted file mode 100644 index 152bee7eb0..0000000000 --- a/test/spec/api/geom/multilinestring.test.js +++ /dev/null @@ -1,268 +0,0 @@ -describe("ol.geom.multilinestring", function() { - var mls, - formatPoint = function(p){ - return p.x() + ',' + p.y(); - }, - linestringNPointN = function(mls, i, j) { - return formatPoint(mls.linestrings()[i].vertices()[j]); - }; - beforeEach(function() { - mls = ol.geom.multilinestring([ - [ - {x:0, y:0}, - {x:2, y:2} - ], [ - {x:0, y:2}, - {x:2, y:0} - ] - ]); - }); - - afterEach(function() { - mls = null; - }); - describe("can construct instances without some lines", function() { - it("works for the object notation of points", function(){ - expect( mls ).toBeA( ol.geom.MultiLineString ); - }); - - it("works for the array notation of points", function(){ - mls = ol.geom.multilinestring([ - [ - [0, 0], - [2, 2] - ], [ - [0, 2], - [2, 0] - ] - ]); - - expect( mls ).toBeA( ol.geom.MultiLineString ); - }); - - it("works for real lines", function(){ - mls = ol.geom.multilinestring([ - ol.geom.linestring([ - ol.geom.point([0, 0]), - ol.geom.point([2, 2]) - ]), - ol.geom.linestring([ - ol.geom.point([0, 2]), - ol.geom.point([2, 0]) - ]) - ]); - - expect( mls ).toBeA( ol.geom.MultiLineString ); - }); - }); - - describe("can construct instances without any lines", function() { - - it("works with an empty array", function(){ - mls = ol.geom.multilinestring([]); - - expect( mls ).toBeA( ol.geom.MultiLineString ); - }); - - it("works without arguments", function(){ - mls = ol.geom.multilinestring(); - - expect( mls ).toBeA( ol.geom.MultiLineString ); - }); - }); - - describe("the method 'add'", function() { - it("exists", function(){ - expect( mls.add ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - it("works with a single line specification and an index", function(){ - var ls = ol.geom.linestring([ - [5, 7], - [5, 10] - ]); - mls.add(ls, 0); - - expect(mls.linestrings().length).toBe(3); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '5,7' ); - }); - - it("works with a linestring instance", function(){ - mls = ol.geom.multilinestring(); - mls.add(ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ])); - expect(mls.linestrings().length).toBe(1); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '-5.2,7.3' ); - }); - - it("the index is functional", function(){ - var l = ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ]); - mls.add(l, 1); - - expect(mls.linestrings().length).toBe(3); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '0,0' ); - expect( linestringNPointN(mls, 1, 0) ).toBe( '-5.2,7.3' ); - expect( linestringNPointN(mls, 2, 0) ).toBe( '0,2' ); - }); - - it("the index is optional", function(){ - var l = ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ]); - mls.add(l); - - expect(mls.linestrings().length).toBe(3); - - expect( linestringNPointN(mls, 2, 0) ).toBe( '-5.2,7.3' ); - }); - - it("returns the multipoint instance", function(){ - var l = ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ]); - var returned = mls.add(l, 1); - - expect(returned).toBe(mls); - }); - }); - }); - - describe("the method 'addAll'", function(){ - it("exists", function(){ - expect( mls.addAll ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - - it("works with an array of point specifications and an index", function(){ - var lines = [ - ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ]), - ol.geom.linestring([ - [2, 4], - [5, 7] - ]) - ]; - mls.addAll(lines, 0); - - expect(mls.linestrings().length).toBe(4); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '-5.2,7.3' ); - expect( linestringNPointN(mls, 1, 0) ).toBe( '2,4' ); - }); - - it("the index is functional", function(){ - var lines = [ - ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ]), - ol.geom.linestring([ - [2, 4], - [5, 7] - ]) - ]; - mls.addAll(lines, 1); - - expect(mls.linestrings().length).toBe(4); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '0,0' ); - expect( linestringNPointN(mls, 1, 0) ).toBe( '-5.2,7.3' ); - expect( linestringNPointN(mls, 2, 0) ).toBe( '2,4' ); - expect( linestringNPointN(mls, 3, 0) ).toBe( '0,2' ); - }); - - it("the index is optional", function(){ - var lines = [ - ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ]), - ol.geom.linestring([ - [2, 4], - [5, 7] - ]) - ]; - mls.addAll(lines); - - expect(mls.linestrings().length).toBe(4); - - expect( linestringNPointN(mls, 2, 0) ).toBe( '-5.2,7.3' ); - expect( linestringNPointN(mls, 3, 0) ).toBe( '2,4' ); - }); - - it("returns the multipoint instance", function(){ - var lines = [ - ol.geom.linestring([ - [-5.2, 7.3], - [-5.6, 7.7] - ]), - ol.geom.linestring([ - [2, 4], - [5, 7] - ]) - ]; - var returned = mls.addAll(lines, 0); - - expect(returned).toBe(mls); - }); - }); - }); - - describe("the method 'remove'", function() { - it("exists", function(){ - expect( mls.remove ).toBeA( Function ); - }); - - it("works with a single line", function(){ - var l = mls.linestrings()[0]; - mls.remove(l); - expect(mls.linestrings().length).toBe(1); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '0,2' ); - }); - - it("works with an array of linestrings", function(){ - var lines = [ - mls.linestrings()[0], - mls.linestrings()[1] - ]; - mls.remove(lines); - expect(mls.linestrings().length).toBe(0); - }); - }); - - describe("the centroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(mls.centroid()).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - mls = ol.geom.multilinestring([ - ol.geom.linestring([ - ol.geom.point([2, 1]), - ol.geom.point([2, 3]) - ]), - ol.geom.linestring([ - ol.geom.point([1, 2]), - ol.geom.point([3, 2]) - ]) - ]); - var c = mls.centroid(); - expect( formatPoint(c) ).toBe('2,2'); - }); - }); -}); diff --git a/test/spec/api/geom/multipoint.test.js b/test/spec/api/geom/multipoint.test.js deleted file mode 100644 index 5a1a4d350a..0000000000 --- a/test/spec/api/geom/multipoint.test.js +++ /dev/null @@ -1,240 +0,0 @@ -describe("ol.geom.multipoint", function() { - var mp; - beforeEach(function() { - mp = ol.geom.multipoint([ - {x:0, y:1}, - {x:2, y:3} - ]); - }); - - afterEach(function() { - mp = null; - }); - describe("can construct instances without some points", function() { - it("works for the object notation of points", function(){ - expect( mp ).toBeA( ol.geom.MultiPoint ); - }); - - it("works for the array notation of points", function(){ - mp = ol.geom.multipoint([ - [0, 1], - [2, 3] - ]); - - expect( mp ).toBeA( ol.geom.MultiPoint ); - }); - - it("works for real points", function(){ - mp = ol.geom.multipoint([ - ol.geom.point([0,1]), - ol.geom.point([2,3]) - ]); - - expect( mp ).toBeA( ol.geom.MultiPoint ); - }); - }); - - describe("can construct instances without any points", function() { - - it("works with an empty array", function(){ - mp = ol.geom.multipoint([]); - - expect( mp ).toBeA( ol.geom.MultiPoint ); - }); - - it("works without arguments", function(){ - mp = ol.geom.multipoint(); - - expect( mp ).toBeA( ol.geom.MultiPoint ); - }); - }); - - describe("the method 'add'", function() { - it("exists", function(){ - expect( mp.add ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - it("works with a single point specification and an index", function(){ - var p = ol.geom.point([24,7]); - mp.add(p, 0); - - expect(mp.points().length).toBe(3); - - var firstPoint = mp.points()[0]; - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("works with point instance", function(){ - mp = ol.geom.multipoint(); - mp.add(ol.geom.point([24,7])); - expect(mp.points().length).toBe(1); - var firstPoint = mp.points()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("works with array specifications", function(){ - mp = ol.geom.multipoint(); - mp.add([24,7]); - expect(mp.points().length).toBe(1); - var firstPoint = mp.points()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("works with object specifications", function(){ - mp = ol.geom.multipoint(); - mp.add({x:24,y:7}); - expect(mp.points().length).toBe(1); - var firstPoint = mp.points()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - }); - - it("the index is functional", function(){ - var p = ol.geom.point([24,7]); - mp.add(p, 1); - - expect(mp.points().length).toBe(3); - - var firstPoint = mp.points()[0], // untouched - secondPoint = mp.points()[1], // this should be ours - thirdPoint = mp.points()[2]; // shifted here - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' ); - expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' ); - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '2,3' ); - }); - - it("the index is optional", function(){ - var p = ol.geom.point([24,7]); - mp.add(p); - - expect(mp.points().length).toBe(3); - - var thirdPoint = mp.points()[2]; - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' ); - }); - - it("returns the multipoint instance", function(){ - var p = ol.geom.point([24,7]); - var returned = mp.add(p); - - expect(returned).toBe(mp); - }); - }); - }); - - describe("the method 'addAll'", function(){ - it("exists", function(){ - expect( mp.addAll ).toBeA( Function ); - }); - - describe("can be used as setter", function(){ - - it("works with an array of point specifications and an index", function(){ - var ps = [ - ol.geom.point([24,7]), - ol.geom.point([7,11]) - ]; - mp.addAll(ps, 0); - - expect(mp.points().length).toBe(4); - - var firstPoint = mp.points()[0], - secondPoint = mp.points()[1]; - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '24,7' ); - expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '7,11' ); - }); - - it("the index is functional", function(){ - var ps = [ - [24,7], - {x:7, y:11} - ]; - mp.addAll(ps, 1); - - expect(mp.points().length).toBe(4); - - var firstPoint = mp.points()[0], // untouched - secondPoint = mp.points()[1], // this should be ours - thirdPoint = mp.points()[2], // this should be ours - fourthPoint = mp.points()[3]; // shifted here - - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '0,1' ); - expect( secondPoint.x() + ',' + secondPoint.y() ).toBe( '24,7' ); - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '7,11' ); - expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '2,3' ); - }); - - it("the index is optional", function(){ - var ps = [ - [24,7], - {x:7, y:11} - ]; - mp.addAll(ps); - - expect(mp.points().length).toBe(4); - - var thirdPoint = mp.points()[2], - fourthPoint = mp.points()[3]; - expect( thirdPoint.x() + ',' + thirdPoint.y() ).toBe( '24,7' ); - expect( fourthPoint.x() + ',' + fourthPoint.y() ).toBe( '7,11' ); - }); - - it("returns the multipoint instance", function(){ - var ps = [ - [24,7], - {x:7, y:11} - ]; - var returned = mp.addAll(ps); - - expect(returned).toBe(mp); - }); - }); - }); - - - describe("the method 'remove'", function() { - it("exists", function(){ - expect( mp.remove ).toBeA( Function ); - }); - - it("works with a single point", function(){ - var p = mp.points()[0]; - mp.remove(p); - expect(mp.points().length).toBe(1); - var firstPoint = mp.points()[0]; - expect( firstPoint.x() + ',' + firstPoint.y() ).toBe( '2,3' ); - }); - - it("works with an array of point specifications", function(){ - var ps = [ - mp.points()[1], - mp.points()[0] - ]; - mp.remove(ps); - expect(mp.points().length).toBe(0); - }); - }); - - describe("the centroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(mp.centroid()).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - mp.points([ - new ol.geom.Point(10,10), - new ol.geom.Point(20,20), - new ol.geom.Point(30,30) - ]); - var c = mp.centroid(); - expect(c.x() + ',' + c.y()).toBe('20,20'); - }); - }); -}); - - - - diff --git a/test/spec/api/geom/point.test.js b/test/spec/api/geom/point.test.js deleted file mode 100644 index 75bfa50ac3..0000000000 --- a/test/spec/api/geom/point.test.js +++ /dev/null @@ -1,212 +0,0 @@ -describe("ol.geom.point", function() { - var pNoArgs, - pNoZ_arr, - pWithZ_arr, - p_arr, - pNoZ_obj, - pWithZ_obj, - p_obj, - proj = "EPSG:4326"; - - var instances = { - "no arguments passed": ol.geom.point(), - "one argument passed": ol.geom.point([21, 4]), - "one argument passed": ol.geom.point([21, 4, 8]), - "one argument passed": ol.geom.point([21, 4, 8, proj]), - "one argument passed": ol.geom.point({x: 21, y: 4}), - "one argument passed": ol.geom.point({x: 21, y: 4, z: 8}), - "one argument passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj}) - }; - - beforeEach(function() { - proj = ol.projection("EPSG:4326"); - instances = { - "no arguments passed": ol.geom.point(), - "one argument passed": ol.geom.point([21, 4]), - "one argument passed": ol.geom.point([21, 4, 8]), - "one argument passed": ol.geom.point([21, 4, 8, proj]), - "one argument passed": ol.geom.point({x: 21, y: 4}), - "one argument passed": ol.geom.point({x: 21, y: 4, z: 8}), - "one argument passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj}) - }; - pNoArgs = instances["no arguments passed"]; - pNoZ_arr = instances["one argument passed"]; - pWithZ_arr = instances["one argument passed"]; - p_arr = instances["one argument passed"]; - pNoZ_obj = instances["one argument passed"]; - pWithZ_obj = instances["one argument passed"]; - p_obj = instances["one argument passed"]; - }); - - afterEach(function() { - pNoArgs = null; - pNoZ_arr = pWithZ_arr = p_arr = null; - PNoZ_obj = pWithZ_obj = p_obj = null; - instances = { - "no arguments passed": ol.geom.point(), - "one argument passed": ol.geom.point([21, 4]), - "one argument passed": ol.geom.point([21, 4, 8]), - "one argument passed": ol.geom.point([21, 4, 8, proj]), - "one argument passed": ol.geom.point({x: 21, y: 4}), - "one argument passed": ol.geom.point({x: 21, y: 4, z: 8}), - "one argument passed": ol.geom.point({x: 21, y: 4, z: 8, projection: proj}) - }; - }); - - for (instancesDesc in instances) { - if (instances.hasOwnProperty(instancesDesc)) { - var instance = instances[instancesDesc]; - - describe("instantiate with " + instancesDesc, function() { - - it("constructs instances", function() { - expect(instance).toEqual(jasmine.any(ol.geom.Point)); - }); - - it("constructs instances of ol.geom.Geometry", function() { - expect(instance).toEqual(jasmine.any(ol.geom.Geometry)); - }); - - it("has coordinate getter/setter methods", function() { - expect(instance.x).not.toBeUndefined(); - expect(instance.y).not.toBeUndefined(); - expect(instance.z).not.toBeUndefined(); - - // always a number - expect( !isNaN( instance.x() ) ).toBe(true); - // setter returns self - expect(instance.x(47)).toBeA(ol.geom.Point); - // getter returns correct number - expect(instance.x()).toBe(47); - - // always a number - expect( !isNaN( instance.y() ) ).toBe(true); - // setter returns self - expect(instance.y(74)).toBeA(ol.geom.Point); - // getter returns correct number - expect(instance.y()).toBe(74); - - // always number or undefined - expect(instance.z() === undefined || !isNaN(instance.z()) ).toBe(true); - // setter returns self - expect(instance.z(0.074)).toBeA(ol.geom.Point); - // getter returns correct number - expect(instance.z()).toBe(0.074); - - }); - - it("has projection getter/setter methods", function() { - expect(instance.projection).not.toBeUndefined(); - - var getRes = instance.projection(); - expect(getRes === null || getRes instanceof ol.Projection).toBe(true); - - var setRes = instance.projection("EPSG:12345"); - expect(setRes instanceof ol.geom.Point).toBe(true); - - getRes = instance.projection(); - expect(getRes).toBeA(ol.Projection); - expect(getRes.code()).toEqual("EPSG:12345"); - }); - }); - - - } - } - - describe('the getters are functional', function(){ - it("works when no arguments passed", function(){ - expect(pNoArgs.x()).toBe(0); - expect(pNoArgs.y()).toBe(0); - expect(pNoArgs.z()).toBeUndefined(); - expect(pNoArgs.projection()).toBeNull(); - }); - - it("works when one argument passed", function(){ - expect(pNoZ_arr.x()).toBe(21); - expect(pNoZ_arr.y()).toBe(4); - expect(pNoZ_arr.z()).toBeUndefined(); - expect(pNoZ_arr.projection()).toBeNull(); - }); - - it("works when one argument passed", function(){ - expect(pWithZ_arr.x()).toBe(21); - expect(pWithZ_arr.y()).toBe(4); - expect(pWithZ_arr.z()).toBe(8); - expect(pWithZ_arr.projection()).toBeNull(); - }); - - it("works when one argument passed", function(){ - expect(p_arr.x()).toBe(21); - expect(p_arr.y()).toBe(4); - expect(p_arr.z()).toBe(8); - expect(p_arr.projection()).not.toBeNull(); - expect(p_arr.projection()).toBeA(ol.Projection); - }); - - it("works when one argument passed", function(){ - expect(pNoZ_obj.x()).toBe(21); - expect(pNoZ_obj.y()).toBe(4); - expect(pNoZ_obj.z()).toBeUndefined(); - expect(pNoZ_obj.projection()).toBeNull(); - }); - - it("works when one argument passed", function(){ - expect(pWithZ_obj.x()).toBe(21); - expect(pWithZ_obj.y()).toBe(4); - expect(pWithZ_obj.z()).toBe(8); - expect(pWithZ_obj.projection()).toBeNull(); - }); - - it("works when one argument passed", function(){ - expect(p_obj.x()).toBe(21); - expect(p_obj.y()).toBe(4); - expect(p_obj.z()).toBe(8); - expect(p_obj.projection()).not.toBeNull(); - expect(p_obj.projection()).toEqual(jasmine.any(ol.Projection)); - }); - }); - - describe("the centroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(pNoZ_arr.centroid()).toBeA(ol.geom.Point); - expect(pWithZ_arr.centroid()).toBeA(ol.geom.Point); - expect(p_arr.centroid()).toBeA(ol.geom.Point); - - expect(pNoZ_obj.centroid()).toBeA(ol.geom.Point); - expect(pWithZ_obj.centroid()).toBeA(ol.geom.Point); - expect(p_obj.centroid()).toBeA(ol.geom.Point); - }); - - it("does return a clone and not the point itself", function(){ - expect(pNoZ_arr.centroid()).not.toBe(pNoZ_arr); - expect(pWithZ_arr.centroid()).not.toBe(pWithZ_arr); - expect(p_arr.centroid()).not.toBe(p_arr); - - expect(pNoZ_obj.centroid()).not.toBe(pNoZ_obj); - expect(pWithZ_obj.centroid()).not.toBe(pWithZ_obj); - expect(p_obj.centroid()).not.toBe(p_obj); - }); - - it("has the expected coordinates", function(){ - var c1 = pNoZ_arr.centroid(), - c2 = pWithZ_arr.centroid(), - c3 = p_arr.centroid(), - c4 = pNoZ_obj.centroid(), - c5 = pWithZ_obj.centroid(), - c6 = p_obj.centroid(); - - expect(c1.x() + ',' + c1.y()).toBe('21,4'); - expect(c2.x() + ',' + c2.y()).toBe('21,4'); - expect(c3.x() + ',' + c3.y()).toBe('21,4'); - expect(c4.x() + ',' + c4.y()).toBe('21,4'); - expect(c5.x() + ',' + c5.y()).toBe('21,4'); - expect(c6.x() + ',' + c6.y()).toBe('21,4'); - }); - - it("returns point(0,0) when the point was constructed without args", function(){ - var c = pNoArgs.centroid(); - expect(c.x() + ',' + c.y()).toBe('0,0'); - }); - }); -}); diff --git a/test/spec/api/layer/osm.test.js b/test/spec/api/layer/osm.test.js deleted file mode 100644 index a0fcfa2729..0000000000 --- a/test/spec/api/layer/osm.test.js +++ /dev/null @@ -1,12 +0,0 @@ -describe('ol.layer.osm', function() { - - describe('create an OSM layer', function() { - - it('returns an ol.layer.OSM instance', function() { - var layer = ol.layer.osm(); - expect(layer).toBeA(ol.layer.OSM); - }); - - }); - -}); diff --git a/test/spec/api/layer/wms.test.js b/test/spec/api/layer/wms.test.js deleted file mode 100644 index 4896f0b239..0000000000 --- a/test/spec/api/layer/wms.test.js +++ /dev/null @@ -1,14 +0,0 @@ -describe('ol.layer.wms', function() { - - describe('create a wms layer', function() { - - it('creates an ol.layer.WMS instance', function() { - var wms = ol.layer.wms({ - url: 'http://wms', - layers: ['layer1', 'layer2'], - format: 'image/png' - }); - expect(wms).toBeA(ol.layer.WMS); - }); - }); -}); diff --git a/test/spec/api/layer/xyz.test.js b/test/spec/api/layer/xyz.test.js deleted file mode 100644 index e64c363e19..0000000000 --- a/test/spec/api/layer/xyz.test.js +++ /dev/null @@ -1,17 +0,0 @@ -describe('ol.layer.xyz', function() { - - it("doesn't allow empty construction", function() { - - expect(function() { - // nowhere - var layer = ol.layer.xyz(); - }).toThrow(); - - }); - - it("creates an ol.layer.XYZ instance", function() { - var layer = ol.layer.xyz({url: 'http://foo/{x}/{y}/{z}'}); - expect(layer).toBeA(ol.layer.XYZ); - }); - -}); diff --git a/test/spec/api/loc.test.js b/test/spec/api/loc.test.js deleted file mode 100644 index 0296f15ca4..0000000000 --- a/test/spec/api/loc.test.js +++ /dev/null @@ -1,127 +0,0 @@ -describe("ol.loc", function() { - - it("doesn't allow empty construction", function() { - - expect(function() { - // nowhere - var loc = ol.loc(); - }).toThrow(); - - }); - - it("allows construction from an obj config", function() { - var loc; - - // obj config - loc = ol.loc({x: 10, y: 20}); - - expect(loc.x()).toBe(10); - expect(loc.y()).toBe(20); - }); - - it("allows construction from an array config", function() { - var loc; - // array config - loc = ol.loc([30, 40]); - - expect(loc.x()).toBe(30); - expect(loc.y()).toBe(40); - - }); - - it("accounts for the third dimension", function() { - var loc; - - // obj config - loc = ol.loc({x: 10, y: 20, z: 30}); - - expect(loc.z()).toBe(30); - - // array config - loc = ol.loc([40, 50, 60]); - - expect(loc.z()).toBe(60); - - }); - - it("is mutable", function() { - - var loc = ol.loc({x: 10, y: 20, z: 15}); - - loc.z(30); - expect(loc.x()).toBe(10); - expect(loc.y()).toBe(20); - expect(loc.z()).toBe(30); - - }); - - it("has no default projection", function() { - - var loc = ol.loc({x: 1, y: 2}); - - expect(loc.projection()).toBeNull(); - - }); - - it("allows projection to be set", function() { - var proj; - - // at construction - var loc = ol.loc({x: 1, y: 2, projection: "EPSG:4326"}); - - proj = loc.projection(); - expect(proj).toBeA(ol.Projection); - expect(proj.code()).toBe("EPSG:4326"); - - // after construction - loc.projection("EPSG:3857"); - expect(loc.projection().code()).toBe("EPSG:3857"); - - // setting projection does not transform coordinates - expect(loc.x()).toBe(1); - expect(loc.y()).toBe(2); - - }); - - it("can be transformed (to mercator)", function() { - - var loc = ol.loc({x: 10, y: 20, projection: "EPSG:4326"}); - var trans = loc.transform("EPSG:3857"); - - expect(trans).toBeA(ol.Loc); - expect(trans.projection().code()).toBe("EPSG:3857"); - expect(trans.x().toFixed(3)).toBe("1113194.908"); - expect(trans.y().toFixed(3)).toBe("2273030.927"); - - expect(loc.x().toFixed(3)).toBe("10.000"); - expect(loc.y().toFixed(3)).toBe("20.000"); - - }); - - it("can be transformed (to geographic)", function() { - - var loc = ol.loc({x: 1113195, y: 2273031, projection: "EPSG:3857"}); - var trans = loc.transform("EPSG:4326"); - - expect(trans).toBeA(ol.Loc); - expect(trans.projection().code()).toBe("EPSG:4326"); - expect(trans.x().toFixed(3)).toBe("10.000"); - expect(trans.y().toFixed(3)).toBe("20.000"); - - }); - - it("should not be transformable if it has no projection", function() { - var loc = ol.loc([1, 2]); - expect(function() { - loc.transform("EPSG:4326"); - }).toThrow(); - }); - - it("is destroyable", function() { - - var loc = ol.loc([1, 2]); - loc.destroy(); - - }); - -}); diff --git a/test/spec/api/map.test.js b/test/spec/api/map.test.js deleted file mode 100644 index e6a2eddfa1..0000000000 --- a/test/spec/api/map.test.js +++ /dev/null @@ -1,245 +0,0 @@ -describe("ol.map", function() { - - it("should be easy to make a map", function() { - - var map = ol.map(); - - expect(map).toBeA(ol.Map); - - }); - - it("should be easy to set the map center", function() { - var map, center; - - // with array - map = ol.map(); - map.center([-110, 45]); - - center = map.center(); - expect(center.x().toFixed(3)).toBe("-110.000"); - expect(center.y().toFixed(3)).toBe("45.000"); - expect(center).toBeA(ol.Loc); - - // with object literal - map.center({x: -111, y: 46}); - - center = map.center(); - expect(center.x().toFixed(3)).toBe("-111.000"); - expect(center.y().toFixed(3)).toBe("46.000"); - expect(center).toBeA(ol.Loc); - - // more verbose - map = ol.map({ - center: ol.loc({x: -112, y: 47}) - }); - - center = map.center(); - expect(center.x().toFixed(3)).toBe("-112.000"); - expect(center.y().toFixed(3)).toBe("47.000"); - expect(center).toBeA(ol.Loc); - - }); - - it("allows flexible setting of center and zoom", function() { - var map, center, zoom; - - // chained - map = ol.map().center([1, 2]).zoom(3); - - center = map.center(); - zoom = map.zoom(); - expect(center.x().toFixed(3)).toBe("1.000"); - expect(center.y().toFixed(3)).toBe("2.000"); - expect(zoom).toBe(3); - - // all at once - map = ol.map({ - center: [4, 5], - zoom: 6 - }); - - center = map.center(); - zoom = map.zoom(); - expect(center.x().toFixed(3)).toBe("4.000"); - expect(center.y().toFixed(3)).toBe("5.000"); - expect(zoom).toBe(6); - - }); - - it("has a default projection", function() { - - var map = ol.map(); - var proj = map.projection(); - - expect(proj).toBeA(ol.Projection); - expect(proj.code()).toBe("EPSG:3857"); - - }); - - it("allows projection to be set", function() { - var proj; - - // at construction - var map = ol.map({ - projection: ol.projection("EPSG:4326") - }); - proj = map.projection(); - - expect(proj).toBeA(ol.Projection); - expect(proj.code()).toBe("EPSG:4326"); - - // after construction - map.projection("EPSG:3857"); - proj = map.projection(); - - expect(proj).toBeA(ol.Projection); - expect(proj.code()).toBe("EPSG:3857"); - - }); - - it("has a default user projection in 4326", function() { - - var map = ol.map(); - var userproj = map.userProjection(); - - expect(userproj).toBeA(ol.Projection); - expect(userproj.code()).toBe("EPSG:4326"); - - }); - - it("allows number of zoom levels to be set", function() { - - var map = ol.map(); - var nzoom = map.numZoomLevels(); - - expect(nzoom).toBe(22); - - map.numZoomLevels(15); - - nzoom = map.numZoomLevels(); - expect(nzoom).toBe(15); - - }); - - it("allows a user projection to be set", function() { - var proj; - - var map = ol.map(); - proj = map.userProjection(); - - expect(proj).toBeA(ol.Projection); - expect(proj.code()).toBe("EPSG:4326"); - - map.center([10, 20]); - - map.userProjection("EPSG:3857"); - var center = map.center(); - expect(center.x().toFixed(3)).toBe("1113194.908"); - expect(center.y().toFixed(3)).toBe("2273030.927"); - - //make sure the center doesn't change - expect(center.x().toFixed(3)).toBe("1113194.908"); - expect(center.y().toFixed(3)).toBe("2273030.927"); - - }); - - it("provides feedback when you mess up", function() { - expect(function() { - var map = ol.map({ - centre: [1, 2] - }); - }).toThrow(); - }); - - it("is destroyable", function() { - - var map = ol.map(); - map.center([1, 2]); - - map.destroy(); - - expect(map.layers()).not.toBeDefined(); - - }); - - it("allows setting the resolutions array", function() { - var map = ol.map(); - map.resolutions([1,2,3]); - - var resolutions = map.resolutions(); - expect(resolutions.length).toBe(3); - expect(resolutions[0]).toBe(1); - expect(resolutions[1]).toBe(2); - expect(resolutions[2]).toBe(3); - }); - - it("resolutions array is mutable", function() { - var map = ol.map(); - map.resolutions([1,2,3]); - - var resolutions = map.resolutions(); - expect(resolutions[0]).toBe(1); - - map.resolutions([10,9,8,7,6,5]); - - resolutions = map.resolutions(); - expect(resolutions.length).toBe(6); - expect(resolutions[0]).toBe(10); - expect(resolutions[2]).toBe(8); - expect(resolutions[4]).toBe(6); - }); - - it("returns correct maxExtent for default map", function() { - var map = ol.map(); - - var extent = map.maxExtent(); - expect(extent).toBeA(ol.Bounds); - expect(extent.minX()).toBe(-20037508.34); - expect(extent.maxX()).toBe(20037508.34); - expect(extent.minY()).toBe(-20037508.34); - expect(extent.maxY()).toBe(20037508.34); - - }); - - it("returns correct maxExtent for custom map extent", function() { - var map = ol.map(); - map.maxExtent([-5,-4,7,9]); - - var extent = map.maxExtent(); - expect(extent).toBeA(ol.Bounds); - expect(extent.minX()).toBe(-5); - expect(extent.maxX()).toBe(7); - expect(extent.minY()).toBe(-4); - expect(extent.maxY()).toBe(9); - - }); - - it("returns correct maxExtent for custom projection extent", function() { - var map = ol.map(); - map.projection("CRS:84"); - - var extent = map.maxExtent(); - expect(extent).toBeA(ol.Bounds); - expect(extent.minX()).toBe(-180); - expect(extent.maxX()).toBe(180); - expect(extent.minY()).toBe(-90); - expect(extent.maxY()).toBe(90); - - }); - - it("throws an error whith no maxExtent available", function() { - expect(function(){ - map({projection: ol.projection("bar")}); - extent = map.maxExtent(); - }).toThrow(); - }); - - it("has no layers by default", function() { - var map = ol.map(); - - var layers = map.layers(); - expect(layers).toBe(null); - }); - - -}); diff --git a/test/spec/api/popup.test.js b/test/spec/api/popup.test.js deleted file mode 100644 index 34d510a127..0000000000 --- a/test/spec/api/popup.test.js +++ /dev/null @@ -1,346 +0,0 @@ -describe("ol.popup", function() { - - it("should be able to add it to a map", function() { - - var map = ol.map(); - var popup = ol.popup({ - map: map - }); - - expect(popup).toBeA(ol.Popup); - expect(popup.map()).toBeA(ol.Map); - }); - - it("should be able to place it at a specific location", function() { - - var map = ol.map(); - var popup = ol.popup({ - map: map, - anchor: ol.loc([10,20]) - }); - - expect(popup).toBeA(ol.Popup); - expect(popup.anchor()).toBeA(ol.Loc); - expect(popup.anchor().x()).toBe(10); - expect(popup.anchor().y()).toBe(20); - }); - - it("should be able to anchor it with a feature", function() { - - var map = ol.map(); - var feat = ol.feature(); - var point = ol.geom.point([21, 4]); - feat.geometry(point); - - var popup = ol.popup({ - map: map, - anchor: feat - }); - - expect(popup).toBeA(ol.Popup); - expect(popup.anchor()).toBeA(ol.Feature); - expect(popup.anchor().geometry().x()).toBe(21); - expect(popup.anchor().geometry().y()).toBe(4); - }); - - it("should be able to anchor it with a feature", function() { - - var map = ol.map(); - var feat = ol.feature(); - var point = ol.geom.point([21, 4]); - feat.geometry(point); - - var popup = ol.popup({ - map: map - }).anchor(feat); - - expect(popup).toBeA(ol.Popup); - expect(popup.anchor()).toBeA(ol.Feature); - expect(popup.anchor().geometry().x()).toBe(21); - expect(popup.anchor().geometry().y()).toBe(4); - }); - - it("should be able to associate it with a feature", function() { - - var map = ol.map(); - var feat = ol.feature(); - var point = ol.geom.point([21, 4]); - feat.geometry(point); - var popup = ol.popup({ - map: map - }); - popup.anchor(feat); - - expect(popup).toBeA(ol.Popup); - expect(popup.anchor()).toBeA(ol.Feature); - expect(popup.anchor().geometry().x()).toBe(21); - expect(popup.anchor().geometry().y()).toBe(4); - }); - - /* - * not yet implemented - it("should be able to set the placement automatically", function() { - - var map = ol.map(); - var popup = ol.popup({ - map: map, - anchor: ol.loc([10,20]), - placement: 'auto' - }); - - expect(popup).toBeA(ol.Popup); - //expect? - }); - */ - - it("should be able to set the placement top of the location", function() { - - var container = document.createElement('div'); - container.setAttribute('id', 'map'); - document.documentElement.appendChild(container); - var map = ol.map({ - renderTo: 'map', - layers: [ol.layer.osm()], - center: [0, 0], - zoom: 1 - }); - var popup = ol.popup({ - map: map, - anchor: ol.loc([10,20]), - placement: 'top', - content: 'foo bar' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(); - var elems = document.getElementsByClassName('ol-popup-top'); - expect(elems.length).toBe(1); - - popup.close(); - elems = document.getElementsByClassName('ol-popup-top'); - expect(elems.length).toBe(0); - - map.destroy(); - document.documentElement.removeChild(container); - }); - - - it("should be able to open and close a popup", function() { - - var container = document.createElement('div'); - container.setAttribute('id', 'map'); - document.documentElement.appendChild(container); - var map = ol.map({ - renderTo: 'map', - layers: [ol.layer.osm()], - center: [0, 0], - zoom: 1 - }); - var popup = ol.popup({ - map: map, - anchor: ol.loc([10,20]), - content: 'foo bar' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(); - var elems = document.getElementsByClassName('ol-popup'); - expect(elems.length).toBe(1); - - popup.close(); - elems = document.getElementsByClassName('ol-popup'); - expect(elems.length).toBe(0); - - map.destroy(); - document.documentElement.removeChild(container); - }); - - - it("should result in an error to open a popup without an anchor or content", function() { - - var container = document.createElement('div'); - container.setAttribute('id', 'map'); - document.documentElement.appendChild(container); - var map = ol.map({ - renderTo: 'map', - layers: [ol.layer.osm()], - center: [0, 0], - zoom: 1 - }); - var popup = ol.popup({ - map: map - }); - - expect(popup).toBeA(ol.Popup); - expect(function(){popup.open()}).toThrow(); - - popup.content('foo = bar'); - expect(function(){popup.open()}).toThrow(); - - popup.anchor(ol.loc([10,20])); - expect(function(){popup.open()}).not.toThrow(); - - popup.close(); - map.destroy(); - document.documentElement.removeChild(container); - }); - - it("should be able to open and close a popup with a feature argument", function() { - - var container = document.createElement('div'); - container.setAttribute('id', 'map'); - document.documentElement.appendChild(container); - var map = ol.map({ - renderTo: 'map', - layers: [ol.layer.osm()], - center: [0, 0], - zoom: 1 - }); - var point = ol.geom.point([21, 4]); - var feat = ol.feature().geometry(point).set('name','foo'); - - var popup = ol.popup({ - map: map, - template: '

{{name}}

' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(feat); - - expect(popup.anchor()).toBeA(ol.Feature); - expect(popup.anchor().geometry().x()).toBe(21); - expect(popup.anchor().geometry().y()).toBe(4); - var elems = document.getElementsByClassName('ol-popup'); - expect(elems.length).toBe(1); - expect(elems[0].innerHTML).toContain('name'); //TODO check for template replacement when implemented - - feat.set('name','bar'); - popup.open(feat) - expect(elems[0].innerHTML).toContain('name'); //TODO check for template replacement when implemented - - popup.content('testing'); - popup.open(feat) - expect(elems[0].innerHTML).toContain('testing'); //TODO check for template replacement when implemented - - popup.close(); - map.destroy(); - document.documentElement.removeChild(container); - - }); - - /* - it("should be able to open with a new feature and the popup updates", function() { - - var point = ol.geom.point([21, 4]); - var feat = ol.feature().geometry(point).set('name','foo'); - var map = ol.map(); - var popup = ol.popup({ - map: map, - template: '

{{name}}

' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(feat); - - expect(popup.anchor()).toBeA(ol.Feature); - expect(popup.anchor().geometry().x()).toBe(21); - expect(popup.anchor().geometry().y()).toBe(4); - //expect? - - var feat2 = ol.feature().geometry(ol.geom.point([-67,-80])).set('name','bar'); - popup.open(feat2) - expect(popup.anchor().geometry().x()).toBe(-67); - expect(popup.anchor().geometry().y()).toBe(-80); - - popup.close(); - //expect? - - }); - - it("should be able to open and close a popup with a loc argument", function() { - - var map = ol.map(); - var popup = ol.popup({ - map: map, - content: 'test' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(ol.loc([15,3])); - - expect(popup.anchor()).toBeA(ol.Loc); - expect(popup.anchor().x()).toBe(15); - expect(popup.anchor().y()).toBe(3); - - popup.close(); - //expect? - - }); - - it("should be able to set content in the popup", function() { - - var point = ol.geom.point([21, 4]); - var feat = ol.feature().geometry(point); - var map = ol.map(); - var popup = ol.popup({ - map: map, - content: '

hello popup! #ol3

' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(); - //expect? - - popup.content('

content changed! #ol3

'); - //expect? - - popup.close(); - //expect? - - }); - - it("should be able to set content based on a template and feature attributes", function() { - - var point = ol.geom.point([21, 4]); - var feat = ol.feature().geometry(point).set('name', 'foo'); - var map = ol.map(); - var popup = ol.popup({ - map: map, - template: '

hello popup template! #ol3 feature name: {{name}}

' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(feat); - //expect? - - popup.template(); - - popup.close(); - //expect? - - }); - - it("should be able to use a user provided container", function() { - - var point = ol.geom.point([21, 4]); - var feat = ol.feature().geometry(point).set('name', 'foo'); - var map = ol.map(); - var popup = ol.popup({ - map: map, - template: '

hello popup template! #ol3 feature name: {{name}}

' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(feat); - //expect? - - popup.template(); - - popup.close(); - //expect? - - }); -*/ - -}); - diff --git a/test/spec/api/projection.test.js b/test/spec/api/projection.test.js deleted file mode 100644 index aad98e5cac..0000000000 --- a/test/spec/api/projection.test.js +++ /dev/null @@ -1,28 +0,0 @@ -describe("ol.projection", function() { - - it("constructs instances", function() { - var p; - - p = ol.projection("foo"); - expect(p.code()).toBe("foo"); - - p = ol.projection({ - code: "bar", - units: "m" - }); - expect(p.code()).toBe("bar"); - - }); - - it("allows units to be set", function() { - var p; - - p = ol.projection("foo"); - expect(p.units()).toBeUndefined(); - - p = ol.projection({code: "foo", units: "m"}); - expect(p.units()).toBe("m"); - - }); - -}); diff --git a/test/spec/ol/Bounds.test.js b/test/spec/ol/Bounds.test.js deleted file mode 100644 index 51b9032a95..0000000000 --- a/test/spec/ol/Bounds.test.js +++ /dev/null @@ -1,69 +0,0 @@ -describe("ol.Bounds", function() { - - describe("creating a bounds", function() { - it("creates a bounds instance", function() { - var bounds = new ol.Bounds(1, 2, 3, 4); - expect(bounds).toBeA(ol.Bounds); - }); - }); - - describe("getting properties", function() { - var bounds = new ol.Bounds(10, 20, 30, 50); - - it("allows getting width", function() { - expect(bounds.getWidth()).toBe(20); - }); - - it("allows getting height", function() { - expect(bounds.getHeight()).toBe(30); - }); - - it("allows getting null projection", function() { - expect(bounds.getProjection()).toBeNull(); - }); - - it("allws getting a projection", function() { - var proj = new ol.Projection("EPSG:4326"); - var bounds = new ol.Bounds(-180, -90, 180, 90, proj); - expect(bounds.getProjection()).toBe(proj); - }); - - }); - - describe("transforming bounds", function() { - - var gg = new ol.Projection("EPSG:4326"); - var sm = new ol.Projection("EPSG:900913"); - - var bounds = new ol.Bounds(10, -10, 20, 10, gg); - - // approximate bbox array - function bbox(bounds) { - var mult = Math.pow(10, 6); // six figs - return [ - Math.round(bounds.getMinX() * mult) / mult, - Math.round(bounds.getMinY() * mult) / mult, - Math.round(bounds.getMaxX() * mult) / mult, - Math.round(bounds.getMaxY() * mult) / mult - ]; - } - - it("doesn't mind a null transform", function() { - var trans = bounds.transform(new ol.Projection("foo")); - expect(bbox(bounds)).toEqual([10, -10, 20, 10]); - }); - - it("transforms from geographic to spherical mercator", function() { - var trans = bounds.transform(sm); - expect(bbox(trans)).toEqual([1113194.907778, -1118889.974702, 2226389.815556, 1118889.974702]); - }); - - it("transforms from spherical mercator to geographic", function() { - var trans = bounds.transform(sm); - var back = trans.transform(gg); - expect(bbox(back)).toEqual([10, -10, 20, 10]); - }); - - }); - -}); diff --git a/test/spec/ol/Feature.test.js b/test/spec/ol/Feature.test.js deleted file mode 100644 index 6179ca7b91..0000000000 --- a/test/spec/ol/Feature.test.js +++ /dev/null @@ -1,79 +0,0 @@ -describe("ol.Feature", function() { - - it("should be easy to make a feature", function() { - var feat = new ol.Feature(); - - expect(feat).toBeA(ol.Feature); - }); - - it("should be easy to set feature attribute", function() { - - var feat = new ol.Feature(); - feat.setAttribute('foo', 'bar'); - - expect(feat).toBeA(ol.Feature); - expect(feat.getAttribute('foo')).toBe('bar'); - }); - - it("calling set with one argument", function() { - - var feat = new ol.Feature(); - feat.setAttribute('foo'); - - expect(feat.getAttribute('foo')).toBe(undefined); - }); - - it("should be easy to set feature geometry", function() { - - var feat = new ol.Feature(); - var point = ol.geom.point([21, 4]); - feat.setGeometry(point); - - var geom = feat.getGeometry(); - expect(feat).toBeA(ol.Feature); - expect(geom).toBeA(ol.geom.Geometry); - expect(geom.getX()).toBe(21); - expect(geom.getY()).toBe(4); - }); - - it("should be able to set attributes from object literals", function() { - - var feat = new ol.Feature(); - feat.setAttributes({ - foo: 'bar', - two: 'deux', - size: 3, - flag: true - }); - - expect(feat).toBeA(ol.Feature); - expect(feat.getAttribute('foo')).toBe('bar'); - expect(feat.getAttribute('two')).toBe('deux'); - expect(feat.getAttribute('size')).toBe(3); - expect(feat.getAttribute('flag')).toBe(true); - }); - - it("should be able to set attributes keeping existing ones", function() { - - var feat = new ol.Feature(); - feat.setAttributes({ - foo: 'bar', - size: 3 - }); - - expect(feat).toBeA(ol.Feature); - expect(feat.getAttribute('size')).toBe(3); - - feat.setAttributes({ - two: 'deux', - size: -99 - }); - - expect(feat.getAttribute('two')).toBe('deux'); - expect(feat.getAttribute('foo')).toBe('bar'); - expect(feat.getAttribute('size')).toBe(-99); - - }); - -}); - diff --git a/test/spec/ol/Loc.test.js b/test/spec/ol/Loc.test.js deleted file mode 100644 index 1b06695296..0000000000 --- a/test/spec/ol/Loc.test.js +++ /dev/null @@ -1,30 +0,0 @@ -describe('ol.Loc', function() { - - it("should be easy to get a new location with deltas added to coordinates", function() { - var loc, newLoc; - - loc = new ol.Loc(1, 2, 3); - newLoc = loc.add(1, 2, 3); - expect(newLoc.getX()).toBe(2); - expect(newLoc.getY()).toBe(4); - expect(newLoc.getZ()).toBe(6); - - loc = new ol.Loc(1, 2); - newLoc =loc.add(1, 2); - expect(newLoc.getX()).toBe(2); - expect(newLoc.getY()).toBe(4); - expect(newLoc.getZ()).toBeUndefined(); - - newLoc = loc.add(0, 0, 1); - expect(newLoc.getZ()).toBeUndefined(); - }); - - it("should be immutable", function() { - var loc = new ol.Loc(1, 2, 3); - loc.add(1, 2, 3); - expect(loc.getX()).toBe(1); - expect(loc.getY()).toBe(2); - expect(loc.getZ()).toBe(3); - }); - -}); \ No newline at end of file diff --git a/test/spec/ol/Popup.test.js b/test/spec/ol/Popup.test.js deleted file mode 100644 index 9dff39dcff..0000000000 --- a/test/spec/ol/Popup.test.js +++ /dev/null @@ -1,96 +0,0 @@ -describe("ol.Popup", function() { - - it("should be able to add it to a map", function() { - - var map = new ol.Map(); - var popup = new ol.Popup(map); - - expect(popup).toBeA(ol.Popup); - expect(popup.getMap()).toBeA(ol.Map); - }); - - it("should be able to place it at a specific location", function() { - - var map = new ol.Map(); - var popup = new ol.Popup(map, new ol.Loc(10,20)); - - expect(popup).toBeA(ol.Popup); - expect(popup.getAnchor()).toBeA(ol.Loc); - expect(popup.getAnchor().x()).toBe(10); - expect(popup.getAnchor().y()).toBe(20); - }); - - it("should be able to anchor it with a feature", function() { - - var feat = new ol.Feature(); - feat.setGeometry(new ol.geom.Point(21, 4)); - var map = new ol.Map(); - var popup = new ol.Popup(map, feat); - - expect(popup).toBeA(ol.Popup); - var anchor = popup.getAnchor(); - expect(anchor).toBeA(ol.Feature); - var geom = anchor.getGeometry(); - expect(geom.getX()).toBe(21); - expect(geom.getY()).toBe(4); - }); - - /* - it("should be able to set the placement top of the location", function() { - - var map = new ol.Map(); - var popup = new ol.Popup(map, new ol.Loc(10,20),'top'); - - expect(popup).toBeA(ol.Popup); - popup.open(); - var elems = goog.dom.getElementsByClass('ol-popup-top'); - expect(elems.length).toBe(1); - elems = goog.dom.getElementsByClass('ol-popup-close'); - expect(elems.length).toBe(1); - popup.close(); - }); - - it("should be able to change the placement", function() { - - var map = new ol.Map(); - var popup = new ol.Popup(map, new ol.Loc(10,20),'top',false); - - expect(popup).toBeA(ol.Popup); - popup.open(); - var elems = goog.dom.getElementsByClass('ol-popup-top'); - expect(elems.length).toBe(1); - elems = goog.dom.getElementsByClass('ol-popup-close'); - expect(elems.length).toBe(0); - - popup.setPlacement('right'); - elems = goog.dom.getElementsByClass('ol-popup-top'); - expect(elems.length).toBe(0); - elems = goog.dom.getElementsByClass('ol-popup-right'); - expect(elems.length).toBe(1); - - popup.close(); - }); - - it("should be able to use a user provided container", function() { - - var point = ol.geom.point([21, 4]); - var feat = ol.feature().geometry(point).set('name', 'foo'); - var map = ol.map(); - var popup = ol.popup({ - map: map, - template: '

hello popup template! #ol3 feature name: {{name}}

' - }); - - expect(popup).toBeA(ol.Popup); - popup.open(feat); - //expect? - - pop.template(); - - popup.close(); - expect(goog.dom.getElementsByClass('ol-popup')).toBeNull(); - }); -*/ - -}); - diff --git a/test/spec/ol/Projection.test.js b/test/spec/ol/Projection.test.js deleted file mode 100644 index e34322b323..0000000000 --- a/test/spec/ol/Projection.test.js +++ /dev/null @@ -1,20 +0,0 @@ -describe("ol.Projection", function() { - - it("handles transforms", function() { - - var point = {x: 10, y: 20, z: 30}; - - var to = new ol.Projection("EPSG:4326"); - var from = new ol.Projection("EPSG:900913"); - var ret = ol.Projection.transform(point, to, from); - - expect(ret).toBeUndefined(); - - // original is modified - expect(point.x.toFixed(3)).toBe("1113194.908"); - expect(point.y.toFixed(3)).toBe("2273030.927"); - expect(point.z).toBe(30); - - }); - -}); diff --git a/test/spec/ol/Tile.test.js b/test/spec/ol/Tile.test.js deleted file mode 100644 index 527d0ae6cb..0000000000 --- a/test/spec/ol/Tile.test.js +++ /dev/null @@ -1,70 +0,0 @@ -describe("ol.Tile", function() { - - describe("create a tile constructor", function() { - it("returns a constructor than can create tiles with expected properties", function() { - var Tile = ol.Tile.createConstructor(100, 100); - expect(typeof Tile).toEqual("function"); - var tile = new Tile('url'); - expect(tile).toBeA(ol.Tile); - expect(tile.getImg().className).toEqual('olTile'); - expect(tile.getImg().style.width).toEqual("100px"); - expect(tile.getImg().style.height).toEqual("100px"); - }); - }); - - describe("create a tile", function() { - var tile; - beforeEach(function() { - var Tile = ol.Tile.createConstructor(200, 200); - tile = new Tile('http://a.url'); - }); - it("creates a tile instance", function() { - expect(tile).toBeA(ol.Tile); - }); - it("sets an image node in the instance", function() { - expect(tile.getImg()).toBeDefined(); - }); - }); - - describe("handle image load", function() { - var tile; - beforeEach(function() { - var Tile = ol.Tile.createConstructor(200, 200); - tile = new Tile('http://a.url'); - }); - it("fires a load event", function() { - var spy = jasmine.createSpy(); - goog.events.listen(tile, 'load', spy); - tile.handleImageLoad(); - expect(spy).toHaveBeenCalled(); - }); - it("sets the loaded flag", function() { - tile.handleImageLoad(); - expect(tile.isLoaded()).toBeTruthy(); - }); - it("unsets the loading flag", function() { - tile.loading_ = true; - tile.handleImageLoad(); - expect(tile.isLoading()).toBeFalsy(); - }); - }); - - describe("handle image error", function() { - var tile; - beforeEach(function() { - var Tile = ol.Tile.createConstructor(200, 200); - tile = new Tile('http://a.url'); - }); - it("fires a load event", function() { - var spy = jasmine.createSpy(); - goog.events.listen(tile, 'error', spy); - tile.handleImageError(); - expect(spy).toHaveBeenCalled(); - }); - it("unsets the loading flag", function() { - tile.loading_ = true; - tile.handleImageError(); - expect(tile.isLoading()).toBeFalsy(); - }); - }); -}); diff --git a/test/spec/ol/TileCache.test.js b/test/spec/ol/TileCache.test.js deleted file mode 100644 index bcb80bd52a..0000000000 --- a/test/spec/ol/TileCache.test.js +++ /dev/null @@ -1,39 +0,0 @@ -describe('ol.TileCache', function() { - - describe('add tiles to cache', function() { - var Tile, tilecache; - - beforeEach(function() { - Tile = ol.Tile.createConstructor(200, 200); - tilecache = new ol.TileCache(5); - }); - - it('does add tiles, without exceeding cache size', function() { - for (var i=0; i<6; i++) { - var url = 'url' + i; - var tile = new Tile(url); - tilecache.set(url, tile); - } - expect(tilecache.getCount()).toEqual(5); - }); - }); - - describe('exceed the cache capacity', function() { - - var Tile, tilecache, tile; - - beforeEach(function() { - Tile = ol.Tile.createConstructor(200, 200); - tilecache = new ol.TileCache(1); - tile = new Tile('url1'); - tilecache.set('url1', tile); - spyOn(tile, 'destroy'); - }); - - it('calls tile.destroy', function() { - tilecache.set('url2', new Tile('url2')); - expect(tile.destroy).toHaveBeenCalled(); - }); - }); - -}); diff --git a/test/spec/ol/TileSet.test.js b/test/spec/ol/TileSet.test.js deleted file mode 100644 index 8fd5798c84..0000000000 --- a/test/spec/ol/TileSet.test.js +++ /dev/null @@ -1,21 +0,0 @@ -describe("ol.TileSet", function() { - describe("creating a tileset", function() { - it("creates a tileset instance", function() { - var tileset = new ol.TileSet(); - expect(tileset).toBeA(ol.TileSet); - }); - }); - describe("getter methods", function() { - var tileSet = new ol.TileSet([], 123, 456, 10); - - it("allows getting tile width", function() { - expect(tileSet.getTileWidth()).toBe(123); - }); - it("allows getting tile height", function() { - expect(tileSet.getTileHeight()).toBe(456); - }); - it("allows getting resolution", function() { - expect(tileSet.getResolution()).toBe(10); - }); - }); -}); diff --git a/test/spec/ol/UnreferencedBounds.test.js b/test/spec/ol/UnreferencedBounds.test.js deleted file mode 100644 index 7481424b9d..0000000000 --- a/test/spec/ol/UnreferencedBounds.test.js +++ /dev/null @@ -1,57 +0,0 @@ -describe("ol.UnreferencedBounds", function() { - - describe("creating a bounds", function() { - it("creates a bounds instance", function() { - var bounds = new ol.UnreferencedBounds(1, 2, 3, 4); - expect(bounds).toBeA(ol.UnreferencedBounds); - }); - }); - describe("getting properties", function() { - var bounds = new ol.UnreferencedBounds(10, 20, 30, 50); - - it("allows getting width", function() { - expect(bounds.getWidth()).toBe(20); - }); - - it("allows getting height", function() { - expect(bounds.getHeight()).toBe(30); - }); - }); - - describe("intersection", function() { - - var aBounds = new ol.UnreferencedBounds(-180, -90, 180, 90); - - it("works when within", function() { - var bBounds = new ol.UnreferencedBounds(-20, -10, 20, 10); - expect(aBounds.intersects(bBounds)).toBe(true); - expect(bBounds.intersects(aBounds)).toBe(true); - }); - - it("works when contains", function() { - var bBounds = new ol.UnreferencedBounds(-181, -91, 181, 91); - expect(aBounds.intersects(bBounds)).toBe(true); - expect(bBounds.intersects(aBounds)).toBe(true); - }); - - it("works when total intersect", function() { - var bBounds = new ol.UnreferencedBounds(-185, -100, 20, 50); - expect(aBounds.intersects(bBounds)).toBe(true); - expect(bBounds.intersects(aBounds)).toBe(true); - }); - - it("works when borders intersect", function() { - var bBounds = new ol.UnreferencedBounds(-360, -180, -180, -90); - expect(aBounds.intersects(bBounds)).toBe(true); - expect(bBounds.intersects(aBounds)).toBe(true); - }); - - it("works when no intersect", function() { - var bBounds = new ol.UnreferencedBounds(-360, -180, -185, -95); - expect(aBounds.intersects(bBounds)).toBe(false); - expect(bBounds.intersects(aBounds)).toBe(false); - }); - - }); - -}); diff --git a/test/spec/ol/control/Control.test.js b/test/spec/ol/control/Control.test.js deleted file mode 100644 index cb193e2ac2..0000000000 --- a/test/spec/ol/control/Control.test.js +++ /dev/null @@ -1,34 +0,0 @@ -describe('ol.control.Control', function() { - - it('should be easy to create and destroy a control', function() { - var control = new ol.control.Control(); - expect(control).toBeA(ol.control.Control); - expect(control.autoActivate_).toBe(false); - - control.destroy(); - expect(control.autoActivate_).toBeUndefined(); - }); - - it('can be activated and deactivated', function() { - var control = new ol.control.Control(); - expect(control.active_).toBe(false); - expect(control.activate()).toBe(true); - expect(control.active_).toBe(true); - expect(control.activate()).toBe(false); - expect(control.deactivate()).toBe(true); - expect(control.active_).toBe(false); - expect(control.deactivate()).toBe(false); - control.destroy(); - }); - - it('auto-activates itself and can be added to a map', function() { - control = new ol.control.Control(); - control.setMap('foo'); - expect(control.map_).toBe('foo'); - expect(control.active_).toBe(false); - control.autoActivate_ = true; - control.setMap('bar'); - expect(control.map_).toBe('bar'); - expect(control.active_).toBe(true); - }); -}); \ No newline at end of file diff --git a/test/spec/ol/geom/Collection.test.js b/test/spec/ol/geom/Collection.test.js deleted file mode 100644 index a30d9098b6..0000000000 --- a/test/spec/ol/geom/Collection.test.js +++ /dev/null @@ -1,179 +0,0 @@ -describe("ol.geom.Collection", function() { - var c; - - beforeEach(function(){ - c = new ol.geom.Collection([ - new ol.geom.Point(10,20), - new ol.geom.LineString([ - new ol.geom.Point(47,11), - new ol.geom.Point(3.14,2.8) - ]) - ]); - }); - - afterEach(function(){ - c = null; - }); - - it("constructs instances", function() { - expect( c ).toBeA( ol.geom.Collection ); - }); - - it("can construct instances without any components", function() { - // empty array - c = new ol.geom.Collection([]); - expect( c ).toBeA( ol.geom.Collection ); - - // no argument at all - c = new ol.geom.Collection(); - expect( c ).toBeA( ol.geom.Collection ); - }); - - it("cannot construct instances when passed illegal components", function() { - // collection cannot contain collections - expect(function(){ - c = new ol.geom.Collection([ - new ol.geom.Collection() - ]); - }).toThrow(); - - }); - - it("inherits from ol.geom.Geometry", function() { - expect( c ).toBeA( ol.geom.Geometry ); - }); - - it("has a working getter for components", function() { - - var components = c.getComponents(); - - expect( components ).toBeA( Array ); - expect( components.length ).toBe( 2 ); - expect( components[0] ).toBeA( ol.geom.Point ); - expect( components[1] ).toBeA( ol.geom.LineString ); - - expect( components[0].getX() + ',' + components[0].getY()).toBe( '10,20' ); - expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '47,11' ); - - }); - - it("has a working setter for components", function() { - - c.setComponents([ - new ol.geom.Point(30,40), - new ol.geom.LineString([ - new ol.geom.Point(3,9), - new ol.geom.Point(4,16) - ]) - ]); - - var components = c.getComponents(); - - expect( components.length ).toBe( 2 ); - expect( components[0] ).toBeA( ol.geom.Point ); - expect( components[1] ).toBeA( ol.geom.LineString ); - - expect( components[0].getX() + ',' + components[0].getY()).toBe( '30,40' ); - expect( components[1].getVertices()[0].getX() + ',' + components[1].getVertices()[0].getY()).toBe( '3,9' ); - - }); - - it("has a method to add components", function() { - - c.addComponent( - new ol.geom.Point(30,40), - 1 - ); - c.addComponent( - new ol.geom.LineString([ - new ol.geom.Point(5,25), - new ol.geom.Point(6,36) - ]), - 0 - ); - - var components = c.getComponents(); - - expect( components.length ).toBe( 4 ); - expect( components[0].getVertices()[0].getX() + ',' + components[0].getVertices()[0].getY()).toBe( '5,25' ); - expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' ); - expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' ); - expect( components[3].getVertices()[0].getX() + ',' + components[3].getVertices()[0].getY()).toBe( '47,11' ); - - }); - - it("cannot add instances of 'ol.geom.Collection'", function(){ - expect(function(){ - c.addComponent( - new ol.geom.Collection([ - new ol.geom.Point(5,25), - new ol.geom.Point(6,36) - ]) - ); - }).toThrow(); - }); - - it("allows instances of 'ol.geom.Multi*' (even though these are subclasses of ol.geom.Collection)", function(){ - expect(function(){ - c.addComponent( - new ol.geom.MultiPoint([ - new ol.geom.Point(5,25), - new ol.geom.Point(6,36) - ]) - ); - }).not.toThrow(); - }); - - it("has a method to remove components", function() { - c.setComponents([ - new ol.geom.Point(0,10), - new ol.geom.Point(10,20), - new ol.geom.Point(20,30), - new ol.geom.Point(30,40) - ]); - - var p = c.getComponents()[2]; // 20,30; - - c.removeComponent( p ); - - var components = c.getComponents(); - - expect( components.length ).toBe( 3 ); - expect( components[0].getX() + ',' + components[0].getY()).toBe( '0,10' ); - expect( components[1].getX() + ',' + components[1].getY()).toBe( '10,20' ); - expect( components[2].getX() + ',' + components[2].getY()).toBe( '30,40' ); - }); - - describe("the getCentroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(c.getCentroid()).toBeA(ol.geom.Point); - }); - - it("does not choke when components returns a null centroid", function(){ - var centroid; - expect( - function(){ - c.addComponent(new ol.geom.LineString([])); - centroid = c.getCentroid(); - } - ).not.toThrow(); - - expect(centroid).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - c = new ol.geom.Collection([ - new ol.geom.Point(10,10), - new ol.geom.Point(30,30), - new ol.geom.LineString([ - new ol.geom.Point(10,10), - new ol.geom.Point(10,30), - new ol.geom.Point(30,30), - new ol.geom.Point(30,10) - ]) - ]); - var centroid = c.getCentroid(); - expect(centroid.getX() + ',' + centroid.getY()).toBe('20,20'); - }); - }); -}); diff --git a/test/spec/ol/geom/LineString.test.js b/test/spec/ol/geom/LineString.test.js deleted file mode 100644 index 5ddf06f43f..0000000000 --- a/test/spec/ol/geom/LineString.test.js +++ /dev/null @@ -1,131 +0,0 @@ -describe("ol.geom.LineString", function() { - var ls; - - beforeEach(function(){ - ls = new ol.geom.LineString([ - new ol.geom.Point(0,0), - new ol.geom.Point(10,10), - new ol.geom.Point(10,0), - new ol.geom.Point(20,20) - ]); - }); - - afterEach(function(){ - ls = null; - }); - - it("constructs instances", function() { - expect( ls ).toBeA( ol.geom.LineString ); - }); - - it("can construct instances without any points", function() { - // empty array - mp = new ol.geom.LineString([]); - expect( ls ).toBeA( ol.geom.LineString ); - - // no argument at all - mp = new ol.geom.LineString(); - expect( ls ).toBeA( ol.geom.LineString ); - }); - - it("inherits from ol.geom.Geometry", function() { - expect( ls ).toBeA( ol.geom.Geometry ); - }); - - it("has a working getter for vertices", function() { - - var vertices = ls.getVertices(); - - expect( vertices ).toBeA( Array ); - expect( vertices.length ).toBe( 4 ); - expect( vertices[0] ).toBeA( ol.geom.Point ); - - expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,0' ); - - }); - - it("has a working setter for vertices", function() { - - ls.setVertices([ - new ol.geom.Point(30,40), - new ol.geom.Point(50,60) - ]); - - var vertices = ls.getVertices(); - - expect( vertices.length ).toBe( 2 ); - expect( vertices[0] ).toBeA( ol.geom.Point ); - expect( vertices[1] ).toBeA( ol.geom.Point ); - - expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '30,40' ); - expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '50,60' ); - - }); - - it("has a method to add vertices", function() { - - ls.addVertex( - new ol.geom.Point(30,40), - 1 - ); - ls.addVertex( - new ol.geom.Point(50,60), - 2 - ); - ls.addVertex( - new ol.geom.Point(-10,0), - 0 - ); - - var vertices = ls.getVertices(); - - expect( vertices.length ).toBe( 7 ); - expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '-10,0' ); - expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '0,0' ); - expect( vertices[2].getX() + ',' + vertices[2].getY()).toBe( '30,40' ); - expect( vertices[3].getX() + ',' + vertices[3].getY()).toBe( '50,60' ); - expect( vertices[4].getX() + ',' + vertices[4].getY()).toBe( '10,10' ); - expect( vertices[5].getX() + ',' + vertices[5].getY()).toBe( '10,0' ); - expect( vertices[6].getX() + ',' + vertices[6].getY()).toBe( '20,20' ); - - }); - - it("has a method to remove vertices", function() { - ls.setVertices([ - new ol.geom.Point(0,10), - new ol.geom.Point(10,20), - new ol.geom.Point(20,30), - new ol.geom.Point(30,40) - ]); - - var v = ls.getVertices()[2]; // 20,30; - - ls.removeVertex( v ); - - var vertices = ls.getVertices(); - - expect( vertices.length ).toBe( 3 ); - expect( vertices[0].getX() + ',' + vertices[0].getY()).toBe( '0,10' ); - expect( vertices[1].getX() + ',' + vertices[1].getY()).toBe( '10,20' ); - expect( vertices[2].getX() + ',' + vertices[2].getY()).toBe( '30,40' ); - }); - - describe("the getCentroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(ls.getCentroid()).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - - ls.setVertices([ - new ol.geom.Point(0.5, 1), - new ol.geom.Point(1, 1.5), - new ol.geom.Point(1.5, 1), - new ol.geom.Point(1, 0.5) - ]); - var c = ls.getCentroid(); - - expect(c.getX() + ',' + c.getY()).toBe('1,1'); - }); - }); -}); diff --git a/test/spec/ol/geom/MultiLineString.test.js b/test/spec/ol/geom/MultiLineString.test.js deleted file mode 100644 index beb5fec085..0000000000 --- a/test/spec/ol/geom/MultiLineString.test.js +++ /dev/null @@ -1,229 +0,0 @@ -describe("ol.geom.MultiLineString", function() { - - var mls, - formatPoint = function(p){ - return p.getX() + ',' + p.getY(); - }, - linestringNPointN = function(mls, i, j) { - return formatPoint(mls.getLineStrings()[i].getVertices()[j]); - }; - - beforeEach(function(){ - mls = new ol.geom.MultiLineString([ - new ol.geom.LineString([ - new ol.geom.Point(10,10), - new ol.geom.Point(10,0), - new ol.geom.Point(20,20) - ]), - new ol.geom.LineString([ - new ol.geom.Point(30,10), - new ol.geom.Point(30,0), - new ol.geom.Point(40,20) - ]) - ]); - }); - - afterEach(function(){ - mls = null; - }); - - it("constructs instances", function() { - expect( mls ).toBeA( ol.geom.MultiLineString ); - }); - - it("can construct instances without any linestrings", function() { - // empty array - mls = new ol.geom.MultiLineString([]); - expect( mls ).toBeA( ol.geom.MultiLineString ); - - // no argument at all - mls = new ol.geom.MultiLineString(); - expect( mls ).toBeA( ol.geom.MultiLineString ); - }); - - it("cannot be constructed with component-types other than 'ol.geom.Point'", function() { - expect(function(){ - mls = new ol.geom.MultiLineString([ - new ol.geom.Point() - ]); - }).toThrow(); - - expect(function(){ - mls = new ol.geom.MultiLineString([ - new ol.geom.MultiPoint([ - new ol.geom.Point() - ]) - ]); - }).toThrow(); - }); - - it("inherits from ol.geom.Geometry", function() { - expect( mls ).toBeA( ol.geom.Geometry ); - }); - - it("has a working getter for linestrings", function() { - - var linestrings = mls.getLineStrings(); - - expect( linestrings ).toBeA( Array ); - expect( linestrings.length ).toBe( 2 ); - expect( linestrings[0] ).toBeA( ol.geom.LineString ); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '10,10' ); - - }); - - it("has a working setter for linestrings", function() { - - mls.setLineStrings([ - new ol.geom.LineString([ - new ol.geom.Point(-10,10), - new ol.geom.Point(-10,0), - new ol.geom.Point(-20,20) - ]) - ]); - - var linestrings = mls.getLineStrings(); - - expect( linestrings.length ).toBe( 1 ); - expect( linestrings[0] ).toBeA( ol.geom.LineString ); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '-10,10' ); - - }); - - it("has a method to add linestrings", function() { - - mls.addLineString( - new ol.geom.LineString([ - new ol.geom.Point(11,11), - new ol.geom.Point(11,1), - new ol.geom.Point(21,21) - ]), - 1 - ); - mls.addLineString( - new ol.geom.LineString([ - new ol.geom.Point(9,9), - new ol.geom.Point(9,-1), - new ol.geom.Point(19,19) - ]), - 0 - ); - mls.addLineString( - new ol.geom.LineString([ - new ol.geom.Point(31,11), - new ol.geom.Point(31,1), - new ol.geom.Point(41,21) - ]), - 4 - ); - - var linestrings = mls.getLineStrings(); - - expect( linestrings.length ).toBe( 5 ); - expect( linestringNPointN(mls, 0, 0) ).toBe( '9,9' ); - expect( linestringNPointN(mls, 1, 0) ).toBe( '10,10' ); - expect( linestringNPointN(mls, 2, 0) ).toBe( '11,11' ); - expect( linestringNPointN(mls, 3, 0) ).toBe( '30,10' ); - expect( linestringNPointN(mls, 4, 0) ).toBe( '31,11' ); - }); - - it("has a method to remove linestrings", function() { - mls.setLineStrings([ - new ol.geom.LineString([ - new ol.geom.Point(9,9), - new ol.geom.Point(9,-1), - new ol.geom.Point(19,19) - ]), - new ol.geom.LineString([ - new ol.geom.Point(10,10), - new ol.geom.Point(10,0), - new ol.geom.Point(20,20) - ]), - new ol.geom.LineString([ - new ol.geom.Point(11,11), - new ol.geom.Point(11,1), - new ol.geom.Point(21,21) - ]) - ]); - - var ls = mls.getLineStrings()[1]; // p1: 10,10; - - mls.removeLineString( ls ); - - var linestrings = mls.getLineStrings(); - - expect( linestrings.length ).toBe( 2 ); - - expect( linestringNPointN(mls, 0, 0) ).toBe( '9,9' ); - expect( linestringNPointN(mls, 1, 0) ).toBe( '11,11' ); - - }); - - describe('The setters ensure only linestrings can be added', function(){ - - it('addLineString cannot be tricked', function(){ - expect(function(){ - mls.addLineString( - new ol.geom.Point(30,40) - ); - }).toThrow(); - - expect(function(){ - mls.addLineString( - new ol.geom.MultiPoint() - ); - }).toThrow(); - - expect(function(){ - mls.addLineString( - new ol.geom.Collection() - ); - }).toThrow(); - - }); - - it('addComponent cannot be tricked', function(){ - expect(function(){ - mls.addComponent( - new ol.geom.Point(30,40) - ); - }).toThrow(); - - expect(function(){ - mls.addComponent( - new ol.geom.MultiPoint() - ); - }).toThrow(); - - expect(function(){ - mls.addComponent( - new ol.geom.Collection() - ); - }).toThrow(); - }); - - }); - - describe("the getCentroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(mls.getCentroid()).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - mls.setLineStrings([ - new ol.geom.LineString([ - new ol.geom.Point(0,40), - new ol.geom.Point(40,40) - ]), - new ol.geom.LineString([ - new ol.geom.Point(0,0), - new ol.geom.Point(40,40) - ]) - ]); - var c = mls.getCentroid(); - expect( formatPoint(c) ).toBe('20,20'); - }); - }); -}); diff --git a/test/spec/ol/geom/MultiPoint.test.js b/test/spec/ol/geom/MultiPoint.test.js deleted file mode 100644 index 72879491e5..0000000000 --- a/test/spec/ol/geom/MultiPoint.test.js +++ /dev/null @@ -1,141 +0,0 @@ -describe("ol.geom.MultiPoint", function() { - var mp; - - beforeEach(function(){ - mp = new ol.geom.MultiPoint([ - new ol.geom.Point(10,20) - ]); - }); - - afterEach(function(){ - mp = null; - }); - - it("constructs instances", function() { - expect( mp ).toBeA( ol.geom.MultiPoint ); - }); - - it("can construct instances without any points", function() { - // empty array - mp = new ol.geom.MultiPoint([]); - expect( mp ).toBeA( ol.geom.MultiPoint ); - - // no argument at all - mp = new ol.geom.MultiPoint(); - expect( mp ).toBeA( ol.geom.MultiPoint ); - }); - - it("cannot be constructed with component-types other than 'ol.geom.Point'", function() { - expect(function(){ - mp = new ol.geom.MultiPoint([ - new ol.geom.LineString() - ]); - }).toThrow(); - }); - - it("inherits from ol.geom.Geometry", function() { - expect( mp ).toBeA( ol.geom.Geometry ); - }); - - it("has a working getter for points", function() { - - var points = mp.getPoints(); - - expect( points ).toBeA( Array ); - expect( points.length ).toBe( 1 ); - expect( points[0] ).toBeA( ol.geom.Point ); - - expect( points[0].getX() + ',' + points[0].getY()).toBe( '10,20' ); - - }); - - it("has a working setter for points", function() { - - mp.setPoints([ - new ol.geom.Point(30,40), - new ol.geom.Point(50,60) - ]); - - var points = mp.getPoints(); - - expect( points.length ).toBe( 2 ); - expect( points[0] ).toBeA( ol.geom.Point ); - expect( points[1] ).toBeA( ol.geom.Point ); - - expect( points[0].getX() + ',' + points[0].getY()).toBe( '30,40' ); - expect( points[1].getX() + ',' + points[1].getY()).toBe( '50,60' ); - - }); - - it("has a method to add points", function() { - - mp.addPoint( - new ol.geom.Point(30,40), - 1 - ); - mp.addPoint( - new ol.geom.Point(50,60), - 2 - ); - mp.addPoint( - new ol.geom.Point(-10,0), - 0 - ); - - var points = mp.getPoints(); - - expect( points.length ).toBe( 4 ); - expect( points[0].getX() + ',' + points[0].getY()).toBe( '-10,0' ); - expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' ); - expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' ); - expect( points[3].getX() + ',' + points[3].getY()).toBe( '50,60' ); - - }); - - it("can only add ol.geom.Point as components", function() { - expect(function(){ - mp.addComponent( - new ol.geom.LineString([ - new ol.geom.Point(30,40), - new ol.geom.Point(50,60) - ]) - ); - }).toThrow(); - }); - - it("has a method to remove points", function() { - mp.setPoints([ - new ol.geom.Point(0,10), - new ol.geom.Point(10,20), - new ol.geom.Point(20,30), - new ol.geom.Point(30,40) - ]); - - var p = mp.getPoints()[2]; // 20,30; - - mp.removePoint( p ); - - var points = mp.getPoints(); - - expect( points.length ).toBe( 3 ); - expect( points[0].getX() + ',' + points[0].getY()).toBe( '0,10' ); - expect( points[1].getX() + ',' + points[1].getY()).toBe( '10,20' ); - expect( points[2].getX() + ',' + points[2].getY()).toBe( '30,40' ); - }); - - describe("the getCentroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(mp.getCentroid()).toBeA(ol.geom.Point); - }); - - it("has the expected coordinates", function(){ - mp.setPoints([ - new ol.geom.Point(10,10), - new ol.geom.Point(20,20), - new ol.geom.Point(30,30) - ]); - var c = mp.getCentroid(); - expect(c.getX() + ',' + c.getY()).toBe('20,20'); - }); - }); -}); diff --git a/test/spec/ol/geom/Point.test.js b/test/spec/ol/geom/Point.test.js deleted file mode 100644 index 6ffcb12b2f..0000000000 --- a/test/spec/ol/geom/Point.test.js +++ /dev/null @@ -1,149 +0,0 @@ -describe("ol.geom.Point", function() { - var p2Args, - p3Args, - p4Args, - proj = "EPSG:4326"; - - var instances = { - "two arguments , passed": new ol.geom.Point(21, 4), - "three arguments ,, passed": new ol.geom.Point(21, 4, 8), - "four arguments ,,, passed": new ol.geom.Point(21, 4, 8, proj) - }; - - beforeEach(function() { - proj = ol.projection("EPSG:4326"); - instances = { - "two arguments , passed": new ol.geom.Point(21, 4), - "three arguments ,, passed": new ol.geom.Point(21, 4, 8), - "four arguments ,,, passed": new ol.geom.Point(21, 4, 8, proj) - }; - p2Args = instances['two arguments , passed']; - p3Args = instances['three arguments ,, passed']; - p4Args = instances['four arguments ,,, passed']; - }); - - afterEach(function() { - p2Args = p3Args = p4Args = null; - instances = { - "two arguments , passed": new ol.geom.Point(21, 4), - "three arguments ,, passed": new ol.geom.Point(21, 4, 8), - "four arguments ,,, passed": new ol.geom.Point(21, 4, 8, proj) - }; - }); - - for (instancesDesc in instances) { - if (instances.hasOwnProperty(instancesDesc)) { - var instance = instances[instancesDesc]; - - describe("instantiate with " + instancesDesc, function() { - - it("constructs instances", function() { - expect(instance).toEqual(jasmine.any(ol.geom.Point)); - }); - - it("constructs instances of ol.geom.Geometry", function() { - expect(instance).toEqual(jasmine.any(ol.geom.Geometry)); - }); - - it("has the coordinate accessor methods", function() { - expect(instance.getX).not.toBeUndefined(); - expect(instance.getY).not.toBeUndefined(); - expect(instance.getZ).not.toBeUndefined(); - expect(instance.setX).not.toBeUndefined(); - expect(instance.setY).not.toBeUndefined(); - expect(instance.setZ).not.toBeUndefined(); - }); - - it("has the projection accessor methods", function() { - expect(instance.getProjection).not.toBeUndefined(); - expect(instance.setProjection).not.toBeUndefined(); - }); - }); - } - } - describe('the getters are functional', function(){ - it("works when two arguments , passed", function(){ - - expect(p2Args.getX()).toBe(21); - expect(p2Args.getY()).toBe(4); - expect(p2Args.getZ()).toBeUndefined(); - expect(p2Args.getProjection()).toBeNull(); - }); - - it("works when three arguments ,, passed", function(){ - expect(p3Args.getX()).toBe(21); - expect(p3Args.getY()).toBe(4); - expect(p3Args.getZ()).not.toBeUndefined(); - expect(p3Args.getZ()).toBe(8); - expect(p3Args.getProjection()).toBeNull(); - }); - - it("works when four arguments ,,, passed", function(){ - expect(p4Args.getX()).toBe(21); - expect(p4Args.getY()).toBe(4); - expect(p4Args.getZ()).toBe(8); - expect(p4Args.getProjection()).not.toBeNull(); - expect(p4Args.getProjection()).toBeA(ol.Projection); - }); - }); - - describe("transformation is functional", function(){ - it("can be transformed", function(){ - // save for later comparison - var old = { - x: p4Args.getX().toFixed(3), - y: p4Args.getY().toFixed(3) - }; - // with code only - var transformedPoint = p4Args.transform("EPSG:3857"); - - // is it still an instance of ol.geom.Point? - expect(transformedPoint).toBeA(ol.geom.Point); - // coordinates OK? - expect(transformedPoint.getX().toFixed(3)).toBe("2337709.306"); - expect(transformedPoint.getY().toFixed(3)).toBe("445640.110"); - - // with an ol.Projection - var retransformedPoint = transformedPoint.transform(new ol.Projection("EPSG:4326")); - expect(retransformedPoint).toBeA(ol.geom.Point); - - // coordinates shopulkd be the originally configured - expect(retransformedPoint.getX().toFixed(3)).toBe(old.x); - expect(retransformedPoint.getY().toFixed(3)).toBe(old.y); - }); - - it("throws an exception when you try to transform without a source projection", function(){ - expect(function() { - p2Args.transform("EPSG:3857"); - }).toThrow(); - - expect(function() { - p3Args.transform("EPSG:3857"); - }).toThrow(); - }); - }); - - describe("the getCentroid method is functional", function(){ - it("returns an instance of ol.geom.Point", function(){ - expect(p2Args.getCentroid()).toBeA(ol.geom.Point); - expect(p3Args.getCentroid()).toBeA(ol.geom.Point); - expect(p4Args.getCentroid()).toBeA(ol.geom.Point); - }); - - it("does return a clone and not the point itself", function(){ - expect(p2Args.getCentroid()).not.toBe(p2Args); - expect(p3Args.getCentroid()).not.toBe(p3Args); - expect(p4Args.getCentroid()).not.toBe(p4Args); - }); - - it("has the expected coordinates", function(){ - var c2 = p2Args.getCentroid(), - c3 = p3Args.getCentroid(), - c4 = p4Args.getCentroid(); - - expect(c2.getX() + ',' + c2.getY()).toBe('21,4'); - expect(c3.getX() + ',' + c3.getY()).toBe('21,4'); - expect(c4.getX() + ',' + c4.getY()).toBe('21,4'); - }); - }); -}); diff --git a/test/spec/ol/handler/Click.test.js b/test/spec/ol/handler/Click.test.js deleted file mode 100644 index c559f1f777..0000000000 --- a/test/spec/ol/handler/Click.test.js +++ /dev/null @@ -1,47 +0,0 @@ -describe('ol.handler.Click', function() { - var map, elt, listener; - - beforeEach(function() { - map = new ol.Map(); - elt = new goog.events.EventTarget(); - map.viewport_ = elt; - listener = {fn: function() {}}; - spyOn(listener, 'fn'); - }); - - describe('creating a drag handler', function() { - - it('returns an ol.handler.Click instance', function() { - var handler = new ol.handler.Click(map, {}); - expect(handler).toBeA(ol.handler.Click); - }); - - }); - - describe('dispatching events', function() { - - it('dispatches a click event which is an ol.events.MapEvent', function() { - new ol.handler.Click(map, {}); - goog.events.listen(map, 'click', listener.fn); - - goog.events.fireListeners(elt, 'click', false, 'foo'); - var evt = listener.fn.calls[0].args[0]; - expect(evt).toBeA(ol.events.MapEvent); - expect(evt.originalEvent).toBe('foo'); - }); - - it('ignores click events when the dragged state is set', function() { - var states = {}; - new ol.handler.Click(map, states); - goog.events.listen(map, 'click', listener.fn); - - goog.events.fireListeners(elt, 'click', false); - expect(listener.fn.calls.length).toBe(1); - - states.dragged = true; - goog.events.fireListeners(elt, 'click', false); - expect(listener.fn.calls.length).toBe(1); - }); - - }); -}); diff --git a/test/spec/ol/handler/Drag.test.js b/test/spec/ol/handler/Drag.test.js deleted file mode 100644 index d6b1552c3e..0000000000 --- a/test/spec/ol/handler/Drag.test.js +++ /dev/null @@ -1,77 +0,0 @@ -describe('ol.handler.Drag', function() { - var map; - - beforeEach(function() { - map = new ol.Map(); - var elt = new goog.events.EventTarget(); - map.viewport_ = elt; - }); - - describe('creating a drag handler', function() { - - it('returns an ol.handler.Drag instance', function() { - var handler = new ol.handler.Drag(map, {}); - expect(handler).toBeA(ol.handler.Drag); - }); - - }); - - describe('dispatching events', function() { - var handler, states; - - beforeEach(function() { - states = {}; - handler = new ol.handler.Drag(map, states); - }); - - it('dragstart, drag and dragend events', function() { - var spy = spyOn(goog.events.Event, 'preventDefault').andCallThrough(); - goog.events.listen(map, ol.events.MapEventType.DRAGSTART, spy); - goog.events.listen(map, ol.events.MapEventType.DRAG, spy); - goog.events.listen(map, ol.events.MapEventType.DRAGEND, spy); - - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.START}); - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.DRAG}); - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.END}); - - expect(spy.callCount).toEqual(3); - expect(spy.argsForCall[0][0].type).toEqual(ol.events.MapEventType.DRAGSTART); - expect(spy.argsForCall[1][0].type).toEqual(ol.events.MapEventType.DRAG); - expect(spy.argsForCall[2][0].type).toEqual(ol.events.MapEventType.DRAGEND); - }); - - it('sets the dragged state during a drag sequence', function() { - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.DRAG}); - expect(states.dragged).toBeTruthy(); - - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.START}); - expect(states.dragged).toBeFalsy(); - }); - - it('sets deltaX and deltaY on the ol.event.MapEvent', function() { - var spy = spyOn(goog.events.Event, 'preventDefault').andCallThrough(); - goog.events.listen(map, ol.events.MapEventType.DRAG, spy); - - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.START, - clientX: 2, clientY: 4}); - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.DRAG, - clientX: 1, clientY: 2}); - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.DRAG, - clientX: 2, clientY: 4}); - - expect(spy.callCount).toEqual(2); - expect(spy.argsForCall[0][0].deltaX).toEqual(-1); - expect(spy.argsForCall[0][0].deltaY).toEqual(-2); - expect(spy.argsForCall[1][0].deltaX).toEqual(1); - expect(spy.argsForCall[1][0].deltaY).toEqual(2); - }); - - it('calls the default action', function() { - var handler = new ol.handler.Drag(map, {}); - var spy = spyOn(handler, 'defaultDrag'); - - handler.dragger_.dispatchEvent({type: goog.fx.Dragger.EventType.DRAG}); - expect(spy).toHaveBeenCalled(); - }); - }); -}); diff --git a/test/spec/ol/handler/MouseWheel.test.js b/test/spec/ol/handler/MouseWheel.test.js deleted file mode 100644 index ccd9e2aa8d..0000000000 --- a/test/spec/ol/handler/MouseWheel.test.js +++ /dev/null @@ -1,49 +0,0 @@ -describe('ol.handler.MouseWheel', function() { - var map; - - beforeEach(function() { - map = new ol.Map(); - var elt = new goog.events.EventTarget(); - map.viewport_ = elt; - }); - - describe('create a mouse wheel handler', function() { - - it('returns an ol.handler.MouseWheel instance', function() { - var handler = new ol.handler.MouseWheel(map, {}); - expect(handler).toBeA(ol.handler.MouseWheel); - }); - - }); - - describe('dispatching events', function() { - - var handler; - - beforeEach(function() { - handler = new ol.handler.MouseWheel(map, {}); - }); - - it('dispatches a mousewheel event', function() { - var spy = spyOn(goog.events.Event, 'preventDefault').andCallThrough(); - goog.events.listen(map, ol.events.MapEventType.MOUSEWHEEL, spy); - - var evt = new goog.events.MouseWheelEvent(1, 'foo', 0, 1); - handler.handler_.dispatchEvent(evt); - - expect(spy).toHaveBeenCalled(); - expect(spy.argsForCall[0][0].type).toEqual(ol.events.MapEventType.MOUSEWHEEL); - }); - - it('calls the default action', function() { - var handler = new ol.handler.MouseWheel(map, {}); - spyOn(handler, 'defaultMouseWheel'); - - var evt = new goog.events.MouseWheelEvent(1, 'foo', 0, 1); - handler.handler_.dispatchEvent(evt); - - expect(handler.defaultMouseWheel).toHaveBeenCalled(); - }); - - }); -}); diff --git a/test/spec/ol/layer/TileLayer.test.js b/test/spec/ol/layer/TileLayer.test.js deleted file mode 100644 index c4d46ca3a6..0000000000 --- a/test/spec/ol/layer/TileLayer.test.js +++ /dev/null @@ -1,883 +0,0 @@ -describe('ol.layer.TileLayer', function() { - - describe('create a tile layer', function() { - - it('returns an ol.layer.TileLayer instance', function() { - var layer = new ol.layer.TileLayer(); - expect(layer instanceof ol.layer.TileLayer).toBe(true); - }); - - }); - - describe('get tile size', function() { - var layer; - - beforeEach(function() { - layer = new ol.layer.TileLayer(); - }); - - it('returns tile size', function() { - var tilesize = layer.getTileSize(); - expect(tilesize).toEqual([256, 256]); - }); - }); - - describe('axis orientation', function() { - var layer = new ol.layer.TileLayer(); - - it('increases from left to right by default', function() { - expect(layer.getXRight()).toBe(true); - }); - it('increases from top to bottom by default', function() { - expect(layer.getYDown()).toBe(true); - }); - - it('allows people to set things backwards', function() { - var backwards = new ol.layer.TileLayer(); - backwards.setXRight(false); - expect(backwards.getXRight()).toBe(false); - backwards.setYDown(false); - expect(backwards.getYDown()).toBe(false); - }); - - }); - - describe('get tile origin', function() { - var layer; - - beforeEach(function() { - layer = new ol.layer.TileLayer(); - }); - - describe('with tileOriginX and tileOriginY', function() { - - beforeEach(function() { - layer.setTileOrigin(1, 2); - }); - - it('returns the expected origin', function() { - var origin = layer.getTileOrigin(); - expect(origin).toEqual([1, 2]); - }); - - }); - - describe('with extent', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(-180, -90, 180, 90)); - }); - - it('returns the expected origin', function() { - var origin = layer.getTileOrigin(); - expect(origin).toEqual([-180, 90]); - }); - - }); - - describe('with tileOriginCorner and extent', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(-180, -90, 180, 90)); - layer.setTileOriginCorner('tr'); - }); - - it('returns the expected origin', function() { - var origin = layer.getTileOrigin(); - expect(origin).toEqual([180, 90]); - }); - - }); - - describe('with tileOriginCorner, without extent', function() { - - beforeEach(function() { - layer.setTileOriginCorner('tr'); - }); - - it('throws an error or return null', function() { - var origin; - if (ol.error.VERBOSE_ERRORS) { - expect(function() { - origin = layer.getTileOrigin(); - }).toThrow(); - } else { - expect(function() { - origin = layer.getTileOrigin(); - }).not.toThrow(); - expect(origin).toBeNull(); - } - }); - - }); - - describe('with bad tileOriginCorner', function() { - - beforeEach(function() { - layer.setTileOriginCorner('foo'); - }); - - it('returns the expected origin', function() { - if (ol.error.VERBOSE_ERRORS) { - expect(function() { - var origin = layer.getTileOrigin(); - }).toThrow(); - } else { - expect(function() { - var origin = layer.getTileOrigin(); - }).not.toThrow(); - } - }); - - }); - }); - - describe('get resolutions', function() { - var layer; - - beforeEach(function() { - layer = new ol.layer.TileLayer(); - }); - - describe('with resolutions set', function() { - - beforeEach(function() { - layer.setResolutions([1, 0.5, 0.25]); - }); - - it('returns the expected resolutions', function() { - var resolutions = layer.getResolutions(); - expect(resolutions).toEqual([1, 0.5, 0.25]); - }); - - }); - - describe('with maxResolution and numZoomLevels set', function() { - - beforeEach(function() { - layer.setMaxResolution(1); - layer.setNumZoomLevels(3); - }); - - it('returns the expected resolutions', function() { - var resolutions = layer.getResolutions(); - expect(resolutions).toEqual([1, 0.5, 0.25]); - }); - - }); - }); - - describe('get max resolution', function() { - var layer; - - beforeEach(function() { - layer = new ol.layer.TileLayer(); - }); - - describe('with max resolution', function() { - - beforeEach(function() { - layer.setMaxResolution(156543.03390625); - }); - - it('returns the expected maxResolution', function() { - var maxResolution = layer.getMaxResolution(); - expect(maxResolution).toEqual(156543.03390625); - }); - }); - - describe('with projection', function() { - - beforeEach(function() { - layer.setProjection(new ol.Projection("EPSG:3857")); - }); - - it('returns the expected maxResolution', function() { - var maxResolution = layer.getMaxResolution(); - expect(maxResolution).toEqual(156543.03390625); - }); - }); - }); - - describe('get data from the layer', function() { - var layer; - - beforeEach(function() { - layer = new ol.layer.TileLayer(); - layer.setUrl('/{z}/{x}/{y}'); - layer.setResolutions([1, 0.5, 0.25]); - layer.setTileOrigin(-128, 128); - layer.setExtent(new ol.Bounds(-128, -128, 128, 128)); - // we need a TileLayer implementation, just - // use duck-typing on the layer instance - layer.getTileUrl = function(x, y, z) { - return this.getUrl().replace('{x}', x + '') - .replace('{y}', y + '') - .replace('{z}', z + ''); - }; - }); - - describe('extent -128,-128,128,128, resolution 1', function() { - - it('returns the expected data', function() { - var tileset = layer.getData( - new ol.Bounds(-128, -128, 128, 128), 1); - - var tiles = tileset.getTiles(); - expect(tiles.length).toEqual(1); - expect(tiles[0].length).toEqual(1); - - var tile = tiles[0][0]; - expect(tile.getUrl()).toEqual('/0/0/0'); - expect(tile.getImg()).toBeDefined(); - }); - }); - - describe('extent -192,-192,192,192, resolution 1', function() { - - it('returns the expected data', function() { - var tileset = layer.getData( - new ol.Bounds(-192, -192, 192, 192), 1); - - var tiles = tileset.getTiles(); - expect(tiles.length).toEqual(1); - expect(tiles[0].length).toEqual(1); - - var tile = tiles[0][0]; - expect(tile.getUrl()).toEqual('/0/0/0'); - expect(tile.getImg()).toBeDefined(); - }); - }); - - describe('extent -128,-128,128,128, resolution 0.5', function() { - - it('returns the expected data', function() { - var tileset = layer.getData( - new ol.Bounds(-128, -128, 128, 128), 0.5); - - var tiles = tileset.getTiles(); - expect(tiles.length).toEqual(2); - expect(tiles[0].length).toEqual(2); - - var tile; - - tile = tiles[0][0]; - expect(tile.getUrl()).toEqual('/1/0/0'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[0][1]; - expect(tile.getUrl()).toEqual('/1/1/0'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[1][0]; - expect(tile.getUrl()).toEqual('/1/0/1'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[1][1]; - expect(tile.getUrl()).toEqual('/1/1/1'); - expect(tile.getImg()).toBeDefined(); - }); - }); - - describe('extent -64,-64,64,64, resolution 0.5', function() { - - it('returns the expected data', function() { - var tileset = layer.getData( - new ol.Bounds(-64, -64, 64, 64), 0.5); - - var tiles = tileset.getTiles(); - expect(tiles.length).toEqual(2); - expect(tiles[0].length).toEqual(2); - - var tile; - - tile = tiles[0][0]; - expect(tile.getUrl()).toEqual('/1/0/0'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[0][1]; - expect(tile.getUrl()).toEqual('/1/1/0'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[1][0]; - expect(tile.getUrl()).toEqual('/1/0/1'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[1][1]; - expect(tile.getUrl()).toEqual('/1/1/1'); - expect(tile.getImg()).toBeDefined(); - }); - }); - - describe('extent -96,32,-32,96, resolution 0.5', function() { - - it('returns the expected data', function() { - var tileset = layer.getData( - new ol.Bounds(-96, 32, -32, 96), 0.5); - - var tiles = tileset.getTiles(); - expect(tiles.length).toEqual(1); - expect(tiles[0].length).toEqual(1); - - var tile; - - tile = tiles[0][0]; - expect(tile.getUrl()).toEqual('/1/0/0'); - expect(tile.getImg()).toBeDefined(); - }); - }); - - describe('extent -32,32,32,96, resolution 0.5', function() { - - it('returns the expected data', function() { - var tileset = layer.getData( - new ol.Bounds(-32, 32, 32, 96), 0.5); - - var tiles = tileset.getTiles(); - expect(tiles.length).toEqual(1); - expect(tiles[0].length).toEqual(2); - - var tile; - - tile = tiles[0][0]; - expect(tile.getUrl()).toEqual('/1/0/0'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[0][1]; - expect(tile.getUrl()).toEqual('/1/1/0'); - expect(tile.getImg()).toBeDefined(); - }); - }); - - describe('extent 32,-32,96,32, resolution 0.5', function() { - - it('returns the expected data', function() { - var tileset = layer.getData( - new ol.Bounds(32, -32, 96, 32), 0.5); - - var tiles = tileset.getTiles(); - expect(tiles.length).toEqual(2); - expect(tiles[0].length).toEqual(1); - expect(tiles[1].length).toEqual(1); - - var tile; - - tile = tiles[0][0]; - expect(tile.getUrl()).toEqual('/1/1/0'); - expect(tile.getImg()).toBeDefined(); - - tile = tiles[1][0]; - expect(tile.getUrl()).toEqual('/1/1/1'); - expect(tile.getImg()).toBeDefined(); - }); - }); - - }); - - describe('get a tile', function() { - var layer; - - beforeEach(function() { - layer = new ol.layer.TileLayer(); - layer.setUrl('/{z}/{x}/{y}'); - layer.setResolutions([1, 0.5, 0.25]); - layer.setTileOrigin(-128, 128); - // we need a TileLayer implementation, just - // use duck-typing on the layer instance - layer.getTileUrl = function(x, y, z) { - return this.getUrl().replace('{x}', x + '') - .replace('{y}', y + '') - .replace('{z}', z + ''); - }; - }); - - it('returns the expected tile', function() { - var tile = layer.getTileForXYZ(1, 2, 2); - expect(tile.getUrl()).toEqual('/2/1/2'); - }); - - }); - - describe('test x y validity', function() { - var layer; - - beforeEach(function() { - layer = new ol.layer.TileLayer(); - layer.setTileOrigin(0, 0); - layer.setResolutions([1, 0.5, 0.25]); - }); - - describe('tile index goes right/down', function() { - - beforeEach(function() { - layer.setXRight(true); - layer.setYDown(true); - }); - - describe('extent is right/down of origin', function() { - - describe('extent and tile boundaries match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(128, -384, 384, -128)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(0, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 0, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 3, 1); - expect(v).toBeFalsy(); - }); - }); - - describe('extent and tile boundaries do not match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(192, -448, 448, -192)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(0, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(4, 0, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(4, 1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(4, 2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(4, 3, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(4, 4, 1); - expect(v).toBeFalsy(); - }); - }); - - }); - - describe('extent is left/up of origin', function() { - - describe('extent and tile boundaries match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(-384, 128, -128, 384)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(-1, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -3, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -4, 1); - expect(v).toBeFalsy(); - }); - }); - - describe('extent and tile boundaries do not match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(-448, 192, -192, 448)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(-1, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-5, -1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-5, -2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-5, -3, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -4, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -4, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -4, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-5, -4, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-5, -5, 1); - expect(v).toBeFalsy(); - }); - }); - }); - }); - - describe('tile index goes left/up', function() { - - beforeEach(function() { - layer.setXRight(false); - layer.setYDown(false); - }); - - describe('extent is right/down of origin', function() { - - describe('extent and tile boundaries match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(128, -384, 384, -128)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(-1, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -3, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -4, 1); - expect(v).toBeFalsy(); - }); - }); - - describe('extent and tile boundaries do not match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(192, -448, 448, -192)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(-1, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-5, -1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-5, -2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-5, -3, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -4, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-3, -4, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-4, -4, 1); - expect(v).toBeTruthy(); - v = layer.validXY(-5, -4, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(-1, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-2, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-3, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-4, -5, 1); - expect(v).toBeFalsy(); - v = layer.validXY(-5, -5, 1); - expect(v).toBeFalsy(); - }); - }); - }); - - describe('extent is left/up of origin', function() { - - describe('extent and tile boundaries match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(-384, 128, -128, 384)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(0, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 0, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 3, 1); - expect(v).toBeFalsy(); - }); - }); - - describe('extent and tile boundaries do not match', function() { - - beforeEach(function() { - layer.setExtent(new ol.Bounds(-448, 192, -192, 448)); - }); - - it('detects valid x y', function() { - var v; - v = layer.validXY(0, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 0, 1); - expect(v).toBeFalsy(); - v = layer.validXY(4, 0, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 1, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 1, 1); - expect(v).toBeTruthy(); - v = layer.validXY(4, 1, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 2, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 2, 1); - expect(v).toBeTruthy(); - v = layer.validXY(4, 2, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 3, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(2, 3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(3, 3, 1); - expect(v).toBeTruthy(); - v = layer.validXY(4, 3, 1); - expect(v).toBeFalsy(); - - v = layer.validXY(0, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(1, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(2, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(3, 4, 1); - expect(v).toBeFalsy(); - v = layer.validXY(4, 4, 1); - expect(v).toBeFalsy(); - }); - }); - }); - }); - }); -}); diff --git a/test/spec/ol/layer/WMS.test.js b/test/spec/ol/layer/WMS.test.js deleted file mode 100644 index 77a5d4a5b8..0000000000 --- a/test/spec/ol/layer/WMS.test.js +++ /dev/null @@ -1,27 +0,0 @@ -describe('ol.layer.WMS', function() { - - describe('create a wms layer', function() { - - it('returns an ol.layer.WMS instance', function() { - var layer = new ol.layer.WMS(); - expect(layer instanceof ol.layer.WMS).toBe(true); - }); - - }); - - describe('get tile url', function() { - var layer; - beforeEach(function() { - layer = new ol.layer.WMS('/wms', ['layer1', 'layer2']); - layer.setResolutions([1, 0.5, 0.25]); - layer.setTileOrigin(-128, 128); - layer.setExtent(new ol.Bounds(-128, -128, 128, 128)); - layer.setProjection(new ol.Projection('EPSG:900913')); - }); - it('returns a WMS GetMap URL', function() { - var url = layer.getTileUrl(1, 2, 2); - expect(url).toEqual('/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES&FORMAT=image%2Fpng&WIDTH=256&HEIGHT=256&BBOX=-64%2C-64%2C0%2C0&LAYERS=layer1%2Clayer2&SRS=EPSG%3A900913'); - }); - }); - -}); diff --git a/test/spec/ol/layer/XYZ.test.js b/test/spec/ol/layer/XYZ.test.js deleted file mode 100644 index 92cedf109d..0000000000 --- a/test/spec/ol/layer/XYZ.test.js +++ /dev/null @@ -1,12 +0,0 @@ -describe('ol.layer.XYZ', function() { - - describe('create a xyz layer', function() { - - it('returns an ol.layer.XYZ instance', function() { - var layer = new ol.layer.XYZ(); - expect(layer instanceof ol.layer.XYZ).toBe(true); - }); - - }); - -}); diff --git a/test/spec/ol/renderer/TileLayerRenderer.test.js b/test/spec/ol/renderer/TileLayerRenderer.test.js deleted file mode 100644 index 055a737e11..0000000000 --- a/test/spec/ol/renderer/TileLayerRenderer.test.js +++ /dev/null @@ -1,229 +0,0 @@ -describe("ol.renderer.TileLayerRenderer", function() { - - it("is supported in this environment", function() { - // this will not always be true, but for now we expect it to be so - expect(ol.renderer.TileLayerRenderer.isSupported()).toBe(true); - }); - - it("handles tile layers", function() { - var xyz = new ol.layer.XYZ(); - expect(ol.renderer.TileLayerRenderer.canRender(xyz)).toBe(true); - }); - - it("doesn't handle arbitrary layers", function() { - var layer = new ol.layer.Layer(); - expect(ol.renderer.TileLayerRenderer.canRender(layer)).toBe(false); - }); - - it("returns a string type", function() { - expect(ol.renderer.TileLayerRenderer.getType()).toBe("tile"); - }); - - describe("getPreferredResAndZ_", function() { - var layer = new ol.layer.XYZ(); - var resolutions = [100, 80, 50, 10, 1, 0.1]; - layer.setResolutions(resolutions); - - var container = document.createElement("div"); - var renderer = new ol.renderer.TileLayerRenderer(container, layer); - - it("gets the max resolution", function() { - var pair = renderer.getPreferredResAndZ_(100); - expect(pair[0]).toBe(100); - expect(pair[1]).toBe(0); - }); - - it("gets the min resolution", function() { - var pair = renderer.getPreferredResAndZ_(0.1); - expect(pair[0]).toBe(0.1); - expect(pair[1]).toBe(5); - }); - - it("gets the max when bigger", function() { - var pair = renderer.getPreferredResAndZ_(200); - expect(pair[0]).toBe(100); - expect(pair[1]).toBe(0); - }); - - it("gets the min when smaller", function() { - var pair = renderer.getPreferredResAndZ_(0.01); - expect(pair[0]).toBe(0.1); - expect(pair[1]).toBe(5); - }); - - it("gets the first when in the middle", function() { - var pair = renderer.getPreferredResAndZ_(90); - expect(pair[0]).toBe(100); - expect(pair[1]).toBe(0); - }); - - it("gets the closer when elsewhere", function() { - var pair = renderer.getPreferredResAndZ_(89); - expect(pair[0]).toBe(80); - expect(pair[1]).toBe(1); - - pair = renderer.getPreferredResAndZ_(49); - expect(pair[0]).toBe(50); - expect(pair[1]).toBe(2); - - pair = renderer.getPreferredResAndZ_(0.5); - expect(pair[0]).toBe(0.1); - expect(pair[1]).toBe(5); - }); - - }); - - describe("getNormalizedTileCoord_", function() { - var container = document.createElement("div"); - function str(coord) { - return coord.x + "," + coord.y; - } - - describe("simple cases", function() { - var layer = new ol.layer.TileLayer(); - layer.setResolutions([10]); - layer.setTileOrigin(0, 0); - var renderer = new ol.renderer.TileLayerRenderer(container, layer); - - var loc, coord; - - it("gets the first tile at the origin", function() { - loc = new ol.Loc(0, 0); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("0,0"); - }); - - it("gets one tile northwest of the origin", function() { - loc = new ol.Loc(-1280, 1280); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("-1,-1"); - }); - - it("gets one tile northeast of the origin", function() { - loc = new ol.Loc(1280, 1280); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("0,-1"); - }); - - it("gets one tile southeast of the origin", function() { - loc = new ol.Loc(1280, -1280); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("0,0"); - }); - - it("gets one tile southwest of the origin", function() { - loc = new ol.Loc(-1280, -1280); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("-1,0"); - }); - - it("gets the tile to the east when on the edge", function() { - loc = new ol.Loc(2560, -1280); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("1,0"); - }); - - it("gets the tile to the south when on the edge", function() { - loc = new ol.Loc(1280, -2560); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("0,1"); - }); - - it("pixels are top aligned to the origin", function() { - loc = new ol.Loc(1280, -2559.999); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("0,0"); - }); - - it("pixels are left aligned to the origin", function() { - loc = new ol.Loc(2559.999, -1280); - coord = renderer.getNormalizedTileCoord_(loc, 10); - expect(str(coord)).toBe("0,0"); - }); - - }); - - describe("fractional zoom", function() { - var layer = new ol.layer.TileLayer(); - layer.setResolutions([1/3]); - layer.setTileOrigin(0, 0); - var renderer = new ol.renderer.TileLayerRenderer(container, layer); - - var loc, coord; - - /** - These tests render at a resolution of 1. Because the layer's - closest resolution is 1/3, the images are scaled by 1/3. - In this scenario, every third tile will be one pixel wider when - rendered (0,0 is normal; 1,0 is wider; 0,1 is taller; etc.) - */ - - it("gets the first tile at the origin", function() { - loc = new ol.Loc(0, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("0,0"); - }); - - it("gets the 1,0 tile at 256/3,0", function() { - loc = new ol.Loc(256/3, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("1,0"); - }); - - it("still gets the 1,0 tile at 512/3,0 - wider tile", function() { - loc = new ol.Loc(512/3, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("1,0"); - }); - - it("gets the 2,0 tile at 513/3,0", function() { - loc = new ol.Loc(513/3, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("2,0"); - }); - - it("gets the 3,0 tile at 768/3,0", function() { - loc = new ol.Loc(768/3, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("3,0"); - }); - - it("gets the 4,0 tile at 1024/3,0", function() { - loc = new ol.Loc(1024/3, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("4,0"); - }); - - it("still gets the 4,0 tile at 1280/3,0 - wider tile", function() { - loc = new ol.Loc(1280/3, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("4,0"); - }); - - it("gets the 5,0 tile at 1281/3,0", function() { - loc = new ol.Loc(1281/3, 0); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("5,0"); - }); - - it("gets the 0,1 tile at 0,-256/3", function() { - loc = new ol.Loc(0,-256/3); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("0,1"); - }); - - it("still gets the 0,1 tile at 0,-512/3 - taller tile", function() { - loc = new ol.Loc(0,-512/3); - coord = renderer.getNormalizedTileCoord_(loc, 1); - expect(str(coord)).toBe("0,1"); - }); - - - }); - - }); - - - -}); - diff --git a/test/spec/ol/renderer/WebGL.test.js b/test/spec/ol/renderer/WebGL.test.js deleted file mode 100644 index 6d225c61f2..0000000000 --- a/test/spec/ol/renderer/WebGL.test.js +++ /dev/null @@ -1,9 +0,0 @@ -describe("ol.renderer.WebGL", function() { - - it("is supported in this environment", function() { - // this will not always be true, but for now we expect it to be so - expect(ol.renderer.WebGL.isSupported()).toBe(true); - }); - -}); -