diff options
author | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
---|---|---|
committer | Chris Schlaeger <chris@linux.com> | 2014-08-12 21:56:44 +0200 |
commit | ea346a785dc1b3f7c156f6fc33da634e1f1a627b (patch) | |
tree | af67530553d20b6e82ad60fd79593e9c4abf5565 /misc/openlayers/tests/Format/JSON.html | |
parent | 59741cd535c47f25971bf8c32b25da25ceadc6d5 (diff) | |
download | postrunner-ea346a785dc1b3f7c156f6fc33da634e1f1a627b.zip |
Adding jquery, flot and openlayers to be included with the GEM.v0.0.4
Diffstat (limited to 'misc/openlayers/tests/Format/JSON.html')
-rw-r--r-- | misc/openlayers/tests/Format/JSON.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/misc/openlayers/tests/Format/JSON.html b/misc/openlayers/tests/Format/JSON.html new file mode 100644 index 0000000..84461e1 --- /dev/null +++ b/misc/openlayers/tests/Format/JSON.html @@ -0,0 +1,53 @@ +<html> +<head> + <script src="../OLLoader.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."); + } + + + function test_keepData(t) { + t.plan(2); + + var options = {'keepData': true}; + var format = new OpenLayers.Format.JSON(options); + format.read('{"a":["b"], "c":1}'); + + t.ok(format.data != null, 'data property is not null after read with keepData=true'); + t.eq(format.data.c,1,'keepData keeps the right data'); + } + + </script> +</head> +<body> +</body> +</html> |