Files
openlayers/tests/Feature/test_Vector.html

57 lines
1.8 KiB
HTML

<html>
<head>
<script src="../../lib/OpenLayers.js"></script>
<script type="text/javascript">
var map;
var feature;
function test_Feature_Vector_constructor(t) {
t.plan(3);
var geometry = new OpenLayers.Geometry();
geometry.id = Math.random();
var style = {foo: "bar"};
var attributes = {bar: "foo"};
feature = new OpenLayers.Feature.Vector(geometry, attributes, style);
t.ok(feature instanceof OpenLayers.Feature.Vector,
"new OpenLayers.Feature.Vector returns Feature.Vector object" );
t.eq(feature.attributes, attributes,
"attributes property set properly" );
t.eq(feature.geometry.id, geometry.id,
"geometry.property set properly" );
}
function test_Feature_Vector_clone(t) {
t.plan(5);
var geometry = new OpenLayers.Geometry.Point(Math.random(),
Math.random());
var style = {foo: "bar"};
var attributes = {bar: "foo"};
feature = new OpenLayers.Feature.Vector(geometry, attributes, style);
var clone = feature.clone();
t.ok(clone instanceof OpenLayers.Feature.Vector,
"new OpenLayers.Feature.Vector returns Feature.Vector object");
t.eq(clone.attributes, attributes,
"attributes property set properly");
t.eq(clone.style, style,
"style property set properly");
t.eq(clone.geometry.x, geometry.x,
"geometry.x property set properly");
t.eq(clone.geometry.y, geometry.y,
"geometry.y property set properly");
}
</script>
</head>
<body>
<div id="map" style="width: 500px; height: 300px;"></div>
</body>
</html>