git-svn-id: http://svn.openlayers.org/trunk/openlayers@12155 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
52 lines
2.2 KiB
HTML
52 lines
2.2 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../OLLoader.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
var snippet = '<foo version="2.0.0"></foo>';
|
|
var snippet2 = '<foo></foo>';
|
|
|
|
function test_Format_Versioned_constructor(t) {
|
|
t.plan(5);
|
|
|
|
var format = new OpenLayers.Format.XML.VersionedOGC({version: "1.0.0"});
|
|
t.ok(format instanceof OpenLayers.Format.XML.VersionedOGC,
|
|
"new OpenLayers.Format.XML.VersionedOGC returns object" );
|
|
t.eq(format.version, "1.0.0", "constructor sets version correctly");
|
|
t.eq(format.defaultVersion, null, "defaultVersion should be null if not specified");
|
|
t.eq(typeof format.read, "function", "format has a read function");
|
|
t.eq(typeof format.write, "function", "format has a read function");
|
|
}
|
|
|
|
function test_getVersion(t) {
|
|
t.plan(6);
|
|
var format = new OpenLayers.Format.XML.VersionedOGC();
|
|
// read
|
|
var data = new OpenLayers.Format.XML().read(snippet);
|
|
var root = data.documentElement;
|
|
var version = format.getVersion(root);
|
|
t.eq(version, "2.0.0", "Version taken from document");
|
|
format = new OpenLayers.Format.XML.VersionedOGC({version: "1.0.0"});
|
|
version = format.getVersion(root);
|
|
t.eq(version, "1.0.0", "Version taken from parser takes preference");
|
|
format = new OpenLayers.Format.XML.VersionedOGC({defaultVersion: "3.0.0"});
|
|
data = new OpenLayers.Format.XML().read(snippet2);
|
|
root = data.documentElement;
|
|
version = format.getVersion(root);
|
|
t.eq(version, "3.0.0", "If nothing else is set, defaultVersion should be returned");
|
|
// write
|
|
version = format.getVersion(null, {version: "1.3.0"});
|
|
t.eq(version, "1.3.0", "Version from options returned");
|
|
version = format.getVersion(null);
|
|
t.eq(version, "3.0.0", "defaultVersion returned if no version specified in options and no version on the format");
|
|
format.version = "2.1.3";
|
|
version = format.getVersion(null);
|
|
t.eq(version, "2.1.3", "version returned of the Format if no version specified in options");
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|