From 0c6830b13e56fdd9a98be00dca06a0e03abe2a0b Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Wed, 26 Jan 2011 12:53:57 -0500 Subject: [PATCH] Test for remote resources. Fixes #27. --- test/rendering.test.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/rendering.test.js b/test/rendering.test.js index 3b98b77..094e2d6 100644 --- a/test/rendering.test.js +++ b/test/rendering.test.js @@ -32,12 +32,16 @@ helper.files('rendering', 'mml', function(file) { var messParser = new xml2js.Parser(); messParser.addListener('end', function(messXML) { removeAbsoluteDatasources(messXML); + removeAbsoluteImages(messXML); completed = true; try { assert.deepEqual(messXML, resultXML); } catch (e) { - console.warn(helper.stylize("Failure", 'red') + ': ' + helper.stylize(file, 'underline') + ' differs from expected result.'); + console.warn( + helper.stylize("Failure", 'red') + ': ' + + helper.stylize(file, 'underline') + + ' differs from expected result.'); helper.showDifferences(e); throw ''; } @@ -62,6 +66,22 @@ helper.files('rendering', 'mml', function(file) { }); +function removeAbsoluteImages(xml) { + (Array.isArray(xml.Style) ? xml.Style : [ xml.Style ]).forEach(function(style) { + if (style && style.Rule) { + for (i in style.Rule) { + if (style.Rule[i].attr) { + for (j in style.Rule[i].attr) { + if (j == 'file' && style.Rule[i].attr[j][0] == '/') { + style.Rule[i].attr[j] = "[absolute path]"; + } + } + } + } + } + }); +} + function removeAbsoluteDatasources(xml) { (Array.isArray(xml.Layer) ? xml.Layer : [ xml.Layer ]).forEach(function(layer) { layer.Datasource.Parameter.forEach(function(param) {