Don't create Folder name or description if foldersName or foldersDesc are null. r=pgiraud (closes #2417)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9976 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2010-01-27 14:44:35 +00:00
parent e5aab2453d
commit 1f481f3d38
2 changed files with 37 additions and 17 deletions

View File

@@ -66,9 +66,9 @@
t.plan(1);
var kmlExpected = this.test_content;
var options = {
folderName: "OpenLayers export",
foldersName: "OpenLayers export",
foldersDesc: "Vector geometries from OpenLayers"
}
};
var format = new OpenLayers.Format.KML(options);
var features = format.read(kmlExpected);
@@ -76,6 +76,20 @@
var kmlOut = kmlOut.replace(/<\?[^>]*\?>/, ''); // Remove XML Prolog
t.eq(kmlOut, kmlExpected, "correctly writes an KML doc string");
}
function test_Format_KML_write_noNameDesc(t) {
t.plan(1);
var format = new OpenLayers.Format.KML({
foldersName: null,
foldersDesc: null
});
var geom = new OpenLayers.Geometry.Point(0, 0)
var feature = new OpenLayers.Feature.Vector(geom);
feature.id = 42;
var kmlOut = format.write(feature);
var expected = '<kml xmlns="http://earth.google.com/kml/2.0"><Folder><Placemark><name>42</name><description>No description available</description><Point><coordinates>0,0</coordinates></Point></Placemark></Folder></kml>'
t.eq(kmlOut, expected, "null foldersName or foldersDesc don't create elements");
}
function test_Format_KML_write_multis(t) {
/**