Sha256: 1d3e0deb1be18b306eb40e5053857c86c4e12287d172e79df94417d4d429348a

Contents?: true

Size: 1.66 KB

Versions: 12

Compression:

Stored size: 1.66 KB

Contents

<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> 

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
postrunner-0.0.10 misc/openlayers/tests/Format/JSON.html
postrunner-0.0.9 misc/openlayers/tests/Format/JSON.html
postrunner-0.0.8 misc/openlayers/tests/Format/JSON.html
postrunner-0.0.7 misc/openlayers/tests/Format/JSON.html
postrunner-0.0.6 misc/openlayers/tests/Format/JSON.html
postrunner-0.0.5 misc/openlayers/tests/Format/JSON.html
postrunner-0.0.4 misc/openlayers/tests/Format/JSON.html
gb_mapfish_appserver-0.0.5 vendor/assets/javascripts/openlayers/tests/Format/JSON.html
gb_mapfish_appserver-0.0.4 vendor/assets/javascripts/openlayers/tests/Format/JSON.html
gb_mapfish_appserver-0.0.3 vendor/assets/javascripts/openlayers/tests/Format/JSON.html
gb_mapfish_appserver-0.0.2 vendor/assets/javascripts/openlayers/tests/Format/JSON.html
gb_mapfish_appserver-0.0.1 vendor/assets/javascripts/openlayers/tests/Format/JSON.html