add a Jasmine toBeA matcher
This commit is contained in:
@@ -11,6 +11,9 @@
|
|||||||
<!-- include source files here... -->
|
<!-- include source files here... -->
|
||||||
<script type="text/javascript" src="http://localhost:9810/compile?id=ol&mode=SIMPLE"></script>
|
<script type="text/javascript" src="http://localhost:9810/compile?id=ol&mode=SIMPLE"></script>
|
||||||
|
|
||||||
|
<!-- common jasmine extensions -->
|
||||||
|
<script type="text/javascript" src="jasmine-extensions.js"></script>
|
||||||
|
|
||||||
<!-- include spec files here... -->
|
<!-- include spec files here... -->
|
||||||
<script type="text/javascript" src="spec/ol/Bounds.test.js"></script>
|
<script type="text/javascript" src="spec/ol/Bounds.test.js"></script>
|
||||||
<script type="text/javascript" src="spec/ol/Events.test.js"></script>
|
<script type="text/javascript" src="spec/ol/Events.test.js"></script>
|
||||||
|
|||||||
8
test/jasmine-extensions.js
Normal file
8
test/jasmine-extensions.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
beforeEach(function() {
|
||||||
|
var parent = this.getMatchersClass_();
|
||||||
|
this.addMatchers({
|
||||||
|
toBeA: function(type) {
|
||||||
|
return this.actual instanceof type;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -22,7 +22,7 @@ describe("ol.Bounds", function() {
|
|||||||
expect(bounds.minY()).toBe(11);
|
expect(bounds.minY()).toBe(11);
|
||||||
expect(bounds.maxY()).toBe(12);
|
expect(bounds.maxY()).toBe(12);
|
||||||
proj = bounds.projection();
|
proj = bounds.projection();
|
||||||
expect(proj instanceof ol.Projection).toBe(true);
|
expect(proj).toBeA(ol.Projection);
|
||||||
expect(proj.code()).toBe("bar");
|
expect(proj.code()).toBe("bar");
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ describe("ol.Loc", function() {
|
|||||||
|
|
||||||
// nowhere
|
// nowhere
|
||||||
loc = ol.loc();
|
loc = ol.loc();
|
||||||
expect(loc instanceof ol.Loc).toBe(true);
|
expect(loc).toBeA(ol.Loc);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("allows construction from an obj config", function() {
|
it("allows construction from an obj config", function() {
|
||||||
@@ -69,7 +69,7 @@ describe("ol.Loc", function() {
|
|||||||
var loc = ol.loc({x: 1, y: 2, projection: "EPSG:4326"});
|
var loc = ol.loc({x: 1, y: 2, projection: "EPSG:4326"});
|
||||||
|
|
||||||
proj = loc.projection();
|
proj = loc.projection();
|
||||||
expect(proj instanceof ol.Projection).toBe(true);
|
expect(proj).toBe(ol.Projection);
|
||||||
expect(proj.code()).toBe("EPSG:4326");
|
expect(proj.code()).toBe("EPSG:4326");
|
||||||
|
|
||||||
// after construction
|
// after construction
|
||||||
@@ -87,7 +87,7 @@ describe("ol.Loc", function() {
|
|||||||
var loc = ol.loc({x: 10, y: 20, projection: "EPSG:4326"});
|
var loc = ol.loc({x: 10, y: 20, projection: "EPSG:4326"});
|
||||||
var trans = loc.transform("EPSG:3857");
|
var trans = loc.transform("EPSG:3857");
|
||||||
|
|
||||||
expect(trans instanceof ol.Loc).toBe(true);
|
expect(trans).toBeA(ol.Loc);
|
||||||
expect(trans.projection().code()).toBe("EPSG:3857");
|
expect(trans.projection().code()).toBe("EPSG:3857");
|
||||||
expect(trans.x().toFixed(3)).toBe("1113194.908");
|
expect(trans.x().toFixed(3)).toBe("1113194.908");
|
||||||
expect(trans.y().toFixed(3)).toBe("2273030.927");
|
expect(trans.y().toFixed(3)).toBe("2273030.927");
|
||||||
@@ -102,7 +102,7 @@ describe("ol.Loc", function() {
|
|||||||
var loc = ol.loc({x: 1113195, y: 2273031, projection: "EPSG:3857"});
|
var loc = ol.loc({x: 1113195, y: 2273031, projection: "EPSG:3857"});
|
||||||
var trans = loc.transform("EPSG:4326");
|
var trans = loc.transform("EPSG:4326");
|
||||||
|
|
||||||
expect(trans instanceof ol.Loc).toBe(true);
|
expect(trans).toBeA(ol.Loc);
|
||||||
expect(trans.projection().code()).toBe("EPSG:4326");
|
expect(trans.projection().code()).toBe("EPSG:4326");
|
||||||
expect(trans.x().toFixed(3)).toBe("10.000");
|
expect(trans.x().toFixed(3)).toBe("10.000");
|
||||||
expect(trans.y().toFixed(3)).toBe("20.000");
|
expect(trans.y().toFixed(3)).toBe("20.000");
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ describe("ol.Map", function() {
|
|||||||
|
|
||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
|
|
||||||
expect(map instanceof ol.Map).toBe(true);
|
expect(map).toBeA(ol.Map);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ describe("ol.Map", function() {
|
|||||||
center = map.center();
|
center = map.center();
|
||||||
expect(center.x().toFixed(3)).toBe("-110.000");
|
expect(center.x().toFixed(3)).toBe("-110.000");
|
||||||
expect(center.y().toFixed(3)).toBe("45.000");
|
expect(center.y().toFixed(3)).toBe("45.000");
|
||||||
expect(center instanceof ol.Loc).toBe(true);
|
expect(center).toBeA(ol.Loc);
|
||||||
|
|
||||||
// with object literal
|
// with object literal
|
||||||
map.center({x: -111, y: 46});
|
map.center({x: -111, y: 46});
|
||||||
@@ -29,7 +29,7 @@ describe("ol.Map", function() {
|
|||||||
center = map.center();
|
center = map.center();
|
||||||
expect(center.x().toFixed(3)).toBe("-111.000");
|
expect(center.x().toFixed(3)).toBe("-111.000");
|
||||||
expect(center.y().toFixed(3)).toBe("46.000");
|
expect(center.y().toFixed(3)).toBe("46.000");
|
||||||
expect(center instanceof ol.Loc).toBe(true);
|
expect(center).toBeA(ol.Loc);
|
||||||
|
|
||||||
// more verbose
|
// more verbose
|
||||||
map = ol.map({
|
map = ol.map({
|
||||||
@@ -39,7 +39,7 @@ describe("ol.Map", function() {
|
|||||||
center = map.center();
|
center = map.center();
|
||||||
expect(center.x().toFixed(3)).toBe("-112.000");
|
expect(center.x().toFixed(3)).toBe("-112.000");
|
||||||
expect(center.y().toFixed(3)).toBe("47.000");
|
expect(center.y().toFixed(3)).toBe("47.000");
|
||||||
expect(center instanceof ol.Loc).toBe(true);
|
expect(center).toBeA(ol.Loc);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ describe("ol.Map", function() {
|
|||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
var proj = map.projection();
|
var proj = map.projection();
|
||||||
|
|
||||||
expect(proj instanceof ol.Projection).toBe(true);
|
expect(proj).toBeA(ol.Projection);
|
||||||
expect(proj.code()).toBe("EPSG:3857");
|
expect(proj.code()).toBe("EPSG:3857");
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -88,14 +88,14 @@ describe("ol.Map", function() {
|
|||||||
});
|
});
|
||||||
proj = map.projection();
|
proj = map.projection();
|
||||||
|
|
||||||
expect(proj instanceof ol.Projection).toBe(true);
|
expect(proj).toBeA(ol.Projection);
|
||||||
expect(proj.code()).toBe("EPSG:4326");
|
expect(proj.code()).toBe("EPSG:4326");
|
||||||
|
|
||||||
// after construction
|
// after construction
|
||||||
map.projection("EPSG:3857");
|
map.projection("EPSG:3857");
|
||||||
proj = map.projection();
|
proj = map.projection();
|
||||||
|
|
||||||
expect(proj instanceof ol.Projection).toBe(true);
|
expect(proj).toBeA(ol.Projection);
|
||||||
expect(proj.code()).toBe("EPSG:3857");
|
expect(proj.code()).toBe("EPSG:3857");
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -105,7 +105,7 @@ describe("ol.Map", function() {
|
|||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
var userproj = map.userProjection();
|
var userproj = map.userProjection();
|
||||||
|
|
||||||
expect(userproj instanceof ol.Projection).toBe(true);
|
expect(userproj).toBeA(ol.Projection);
|
||||||
expect(userproj.code()).toBe("EPSG:4326");
|
expect(userproj.code()).toBe("EPSG:4326");
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -130,7 +130,7 @@ describe("ol.Map", function() {
|
|||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
proj = map.userProjection();
|
proj = map.userProjection();
|
||||||
|
|
||||||
expect(proj instanceof ol.Projection).toBe(true);
|
expect(proj).toBeA(ol.Projection);
|
||||||
expect(proj.code()).toBe("EPSG:4326");
|
expect(proj.code()).toBe("EPSG:4326");
|
||||||
|
|
||||||
map.center([10, 20]);
|
map.center([10, 20]);
|
||||||
@@ -202,7 +202,7 @@ describe("ol.Map", function() {
|
|||||||
var map = ol.map();
|
var map = ol.map();
|
||||||
|
|
||||||
var extent = map.maxExtent();
|
var extent = map.maxExtent();
|
||||||
expect(extent instanceof ol.Bounds).toBe(true);
|
expect(extent).toBeA(ol.Bounds);
|
||||||
expect(extent.minX()).toBe(-20037508.34);
|
expect(extent.minX()).toBe(-20037508.34);
|
||||||
expect(extent.maxX()).toBe(-20037508.34);
|
expect(extent.maxX()).toBe(-20037508.34);
|
||||||
expect(extent.minY()).toBe(20037508.34);
|
expect(extent.minY()).toBe(20037508.34);
|
||||||
@@ -215,7 +215,7 @@ describe("ol.Map", function() {
|
|||||||
map.maxExtent([-5,-4,7,9]);
|
map.maxExtent([-5,-4,7,9]);
|
||||||
|
|
||||||
var extent = map.maxExtent();
|
var extent = map.maxExtent();
|
||||||
expect(extent instanceof ol.Bounds).toBe(true);
|
expect(extent).toBeA(ol.Bounds);
|
||||||
expect(extent.minX()).toBe(-5);
|
expect(extent.minX()).toBe(-5);
|
||||||
expect(extent.maxX()).toBe(-4);
|
expect(extent.maxX()).toBe(-4);
|
||||||
expect(extent.minY()).toBe(7);
|
expect(extent.minY()).toBe(7);
|
||||||
@@ -228,7 +228,7 @@ describe("ol.Map", function() {
|
|||||||
map.projection("CRS:84");
|
map.projection("CRS:84");
|
||||||
|
|
||||||
var extent = map.maxExtent();
|
var extent = map.maxExtent();
|
||||||
expect(extent instanceof ol.Bounds).toBe(true);
|
expect(extent).toBeA(ol.Bounds);
|
||||||
expect(extent.minX()).toBe(-180);
|
expect(extent.minX()).toBe(-180);
|
||||||
expect(extent.maxX()).toBe(-90);
|
expect(extent.maxX()).toBe(-90);
|
||||||
expect(extent.minY()).toBe(180);
|
expect(extent.minY()).toBe(180);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ describe("ol.Tile", function() {
|
|||||||
describe("creating a tile", function() {
|
describe("creating a tile", function() {
|
||||||
it("creates a tile instance", function() {
|
it("creates a tile instance", function() {
|
||||||
var tile = new ol.Tile();
|
var tile = new ol.Tile();
|
||||||
expect(tile instanceof ol.Tile).toBe(true);
|
expect(tile).toBeA(ol.Tile);
|
||||||
});
|
});
|
||||||
it("sets an image node in the instance", function() {
|
it("sets an image node in the instance", function() {
|
||||||
var tile = new ol.Tile();
|
var tile = new ol.Tile();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ describe("ol.TileSet", function() {
|
|||||||
describe("creating a tileset", function() {
|
describe("creating a tileset", function() {
|
||||||
it("creates a tileset instance", function() {
|
it("creates a tileset instance", function() {
|
||||||
var tileset = new ol.TileSet();
|
var tileset = new ol.TileSet();
|
||||||
expect(tileset instanceof ol.TileSet).toBe(true);
|
expect(tileset).toBeA(ol.TileSet);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user