#915 Adding support for GeoJSON vector format. Many thanks to Chris for the exhaustive tests on this one.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@3994 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
41
tests/Format/test_JSON.html
Normal file
41
tests/Format/test_JSON.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script type="text/javascript"><!--
|
||||
|
||||
|
||||
|
||||
function test_Format_JSON_constructor(t) {
|
||||
t.plan(4);
|
||||
|
||||
var options = {'foo': 'bar'};
|
||||
var format = new OpenLayers.Format.JSON(options);
|
||||
t.ok(format instanceof OpenLayers.Format.JSON,
|
||||
"new OpenLayers.Format.JSON returns object" );
|
||||
t.eq(format.foo, "bar", "constructor sets options correctly");
|
||||
t.eq(typeof format.read, "function", "format has a read function");
|
||||
t.eq(typeof format.write, "function", "format has a write function");
|
||||
}
|
||||
function test_Format_JSON_parser(t) {
|
||||
t.plan(2);
|
||||
|
||||
var format = new OpenLayers.Format.JSON();
|
||||
var data = format.read('{"a":["b"], "c":1}');
|
||||
var obj = {"a":["b"], "c":1};
|
||||
t.eq(obj['a'], data['a'], "element with array parsed correctly.");
|
||||
t.eq(obj['c'], data['c'], "element with number parsed correctly.");
|
||||
}
|
||||
function test_Format_JSON_writer(t) {
|
||||
t.plan(1);
|
||||
|
||||
var format = new OpenLayers.Format.JSON();
|
||||
var data = format.write({"a":["b"], "c":1});
|
||||
var obj = '{"a":["b"],"c":1}';
|
||||
t.eq(data, obj, "writing data to json works.");
|
||||
}
|
||||
// -->
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user