add a Jasmine toBeA matcher
This commit is contained in:
121
test/index.html
121
test/index.html
@@ -1,59 +1,62 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OL Spec Runner</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="jasmine-1.2.0/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="jasmine-1.2.0/jasmine.css">
|
||||
<script type="text/javascript" src="jasmine-1.2.0/jasmine.js"></script>
|
||||
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<script type="text/javascript" src="http://localhost:9810/compile?id=ol&mode=SIMPLE"></script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<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/Loc.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Map.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Projection.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Tile.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/TileSet.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/geom/Geometry.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/geom/Point.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/layer/XYZ.test.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
jasmineEnv.execute();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OL Spec Runner</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="jasmine-1.2.0/jasmine_favicon.png">
|
||||
<link rel="stylesheet" type="text/css" href="jasmine-1.2.0/jasmine.css">
|
||||
<script type="text/javascript" src="jasmine-1.2.0/jasmine.js"></script>
|
||||
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
|
||||
|
||||
<!-- include source files here... -->
|
||||
<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... -->
|
||||
<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/Loc.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Map.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Projection.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/Tile.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/TileSet.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/geom/Geometry.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/geom/Point.test.js"></script>
|
||||
<script type="text/javascript" src="spec/ol/layer/XYZ.test.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
var currentWindowOnload = window.onload;
|
||||
|
||||
window.onload = function() {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
}
|
||||
execJasmine();
|
||||
};
|
||||
|
||||
function execJasmine() {
|
||||
jasmineEnv.execute();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
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.maxY()).toBe(12);
|
||||
proj = bounds.projection();
|
||||
expect(proj instanceof ol.Projection).toBe(true);
|
||||
expect(proj).toBeA(ol.Projection);
|
||||
expect(proj.code()).toBe("bar");
|
||||
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@ describe("ol.Loc", function() {
|
||||
|
||||
// nowhere
|
||||
loc = ol.loc();
|
||||
expect(loc instanceof ol.Loc).toBe(true);
|
||||
expect(loc).toBeA(ol.Loc);
|
||||
});
|
||||
|
||||
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"});
|
||||
|
||||
proj = loc.projection();
|
||||
expect(proj instanceof ol.Projection).toBe(true);
|
||||
expect(proj).toBe(ol.Projection);
|
||||
expect(proj.code()).toBe("EPSG:4326");
|
||||
|
||||
// after construction
|
||||
@@ -87,7 +87,7 @@ describe("ol.Loc", function() {
|
||||
var loc = ol.loc({x: 10, y: 20, projection: "EPSG:4326"});
|
||||
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.x().toFixed(3)).toBe("1113194.908");
|
||||
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 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.x().toFixed(3)).toBe("10.000");
|
||||
expect(trans.y().toFixed(3)).toBe("20.000");
|
||||
|
||||
@@ -7,7 +7,7 @@ describe("ol.Map", function() {
|
||||
|
||||
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();
|
||||
expect(center.x().toFixed(3)).toBe("-110.000");
|
||||
expect(center.y().toFixed(3)).toBe("45.000");
|
||||
expect(center instanceof ol.Loc).toBe(true);
|
||||
expect(center).toBeA(ol.Loc);
|
||||
|
||||
// with object literal
|
||||
map.center({x: -111, y: 46});
|
||||
@@ -29,7 +29,7 @@ describe("ol.Map", function() {
|
||||
center = map.center();
|
||||
expect(center.x().toFixed(3)).toBe("-111.000");
|
||||
expect(center.y().toFixed(3)).toBe("46.000");
|
||||
expect(center instanceof ol.Loc).toBe(true);
|
||||
expect(center).toBeA(ol.Loc);
|
||||
|
||||
// more verbose
|
||||
map = ol.map({
|
||||
@@ -39,7 +39,7 @@ describe("ol.Map", function() {
|
||||
center = map.center();
|
||||
expect(center.x().toFixed(3)).toBe("-112.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 proj = map.projection();
|
||||
|
||||
expect(proj instanceof ol.Projection).toBe(true);
|
||||
expect(proj).toBeA(ol.Projection);
|
||||
expect(proj.code()).toBe("EPSG:3857");
|
||||
|
||||
});
|
||||
@@ -88,14 +88,14 @@ describe("ol.Map", function() {
|
||||
});
|
||||
proj = map.projection();
|
||||
|
||||
expect(proj instanceof ol.Projection).toBe(true);
|
||||
expect(proj).toBeA(ol.Projection);
|
||||
expect(proj.code()).toBe("EPSG:4326");
|
||||
|
||||
// after construction
|
||||
map.projection("EPSG:3857");
|
||||
proj = map.projection();
|
||||
|
||||
expect(proj instanceof ol.Projection).toBe(true);
|
||||
expect(proj).toBeA(ol.Projection);
|
||||
expect(proj.code()).toBe("EPSG:3857");
|
||||
|
||||
});
|
||||
@@ -105,7 +105,7 @@ describe("ol.Map", function() {
|
||||
var map = ol.map();
|
||||
var userproj = map.userProjection();
|
||||
|
||||
expect(userproj instanceof ol.Projection).toBe(true);
|
||||
expect(userproj).toBeA(ol.Projection);
|
||||
expect(userproj.code()).toBe("EPSG:4326");
|
||||
|
||||
});
|
||||
@@ -130,7 +130,7 @@ describe("ol.Map", function() {
|
||||
var map = ol.map();
|
||||
proj = map.userProjection();
|
||||
|
||||
expect(proj instanceof ol.Projection).toBe(true);
|
||||
expect(proj).toBeA(ol.Projection);
|
||||
expect(proj.code()).toBe("EPSG:4326");
|
||||
|
||||
map.center([10, 20]);
|
||||
@@ -202,7 +202,7 @@ describe("ol.Map", function() {
|
||||
var map = ol.map();
|
||||
|
||||
var extent = map.maxExtent();
|
||||
expect(extent instanceof ol.Bounds).toBe(true);
|
||||
expect(extent).toBeA(ol.Bounds);
|
||||
expect(extent.minX()).toBe(-20037508.34);
|
||||
expect(extent.maxX()).toBe(-20037508.34);
|
||||
expect(extent.minY()).toBe(20037508.34);
|
||||
@@ -215,7 +215,7 @@ describe("ol.Map", function() {
|
||||
map.maxExtent([-5,-4,7,9]);
|
||||
|
||||
var extent = map.maxExtent();
|
||||
expect(extent instanceof ol.Bounds).toBe(true);
|
||||
expect(extent).toBeA(ol.Bounds);
|
||||
expect(extent.minX()).toBe(-5);
|
||||
expect(extent.maxX()).toBe(-4);
|
||||
expect(extent.minY()).toBe(7);
|
||||
@@ -228,7 +228,7 @@ describe("ol.Map", function() {
|
||||
map.projection("CRS:84");
|
||||
|
||||
var extent = map.maxExtent();
|
||||
expect(extent instanceof ol.Bounds).toBe(true);
|
||||
expect(extent).toBeA(ol.Bounds);
|
||||
expect(extent.minX()).toBe(-180);
|
||||
expect(extent.maxX()).toBe(-90);
|
||||
expect(extent.minY()).toBe(180);
|
||||
|
||||
@@ -3,7 +3,7 @@ describe("ol.Tile", function() {
|
||||
describe("creating a tile", function() {
|
||||
it("creates a tile instance", function() {
|
||||
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() {
|
||||
var tile = new ol.Tile();
|
||||
|
||||
@@ -2,7 +2,7 @@ describe("ol.TileSet", function() {
|
||||
describe("creating a tileset", function() {
|
||||
it("creates a tileset instance", function() {
|
||||
var tileset = new ol.TileSet();
|
||||
expect(tileset instanceof ol.TileSet).toBe(true);
|
||||
expect(tileset).toBeA(ol.TileSet);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user