diff --git a/translations/test/multipolygon_relation.js b/translations/test/multipolygon_relation.js new file mode 100644 index 0000000000..28d39270c4 --- /dev/null +++ b/translations/test/multipolygon_relation.js @@ -0,0 +1,140 @@ +var assert = require('assert'), + DOMParser = new require('xmldom').DOMParser, + parser = new DOMParser(); + +var server = require('../TranslationServer.js'); + +describe('TranslationServer', function () { + + it('should translate a multipolygon relation from osm -> mcgp with error', function() { + + var data = " \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + "; + + var osm_xml = server.handleInputs({ + osm: data, + method: 'POST', + translation: 'MGCP', + path: '/translateTo' + }); + + // console.log(osm_xml); + + var xml = parser.parseFromString(osm_xml); + + assert.equal(xml.getElementsByTagName("osm")[0].getAttribute("schema"), "MGCP"); + + // We expect to see "type=multipolygon" as the ONLY tag + assert.equal(xml.getElementsByTagName("tag")[0].getAttribute("k"), "type"); + assert.equal(xml.getElementsByTagName("tag")[0].getAttribute("v"), "multipolygon"); + + assert.equal(xml.getElementsByTagName("tag").length,1); + }); + + it('should translate an invalid tagged relation from osm -> mcgp with error', function() { + + var data = " \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + "; + + var osm_xml = server.handleInputs({ + osm: data, + method: 'POST', + translation: 'MGCP', + path: '/translateTo' + }); + + // console.log(osm_xml); + + var xml = parser.parseFromString(osm_xml); + + assert.equal(xml.getElementsByTagName("osm")[0].getAttribute("schema"), "MGCP"); + // NOTE: tag[0] == "type=multipolygon" + assert.equal(xml.getElementsByTagName("tag")[1].getAttribute("k"), "error"); + assert.equal(xml.getElementsByTagName("tag")[1].getAttribute("v"), "No Valid Feature Code"); + + }); + + it('should translate an invalid tagged way from osm -> mcgp with error', function() { + + var data = '\ + \ + \ + \ + \ + \ + \ + \ + \ + '; + + var osm_xml = server.handleInputs({ + osm: data, + method: 'POST', + translation: 'MGCP', + path: '/translateTo' + }); + + // console.log(osm_xml); + + var xml = parser.parseFromString(osm_xml); + + assert.equal(xml.getElementsByTagName("osm")[0].getAttribute("schema"), "MGCP"); + assert.equal(xml.getElementsByTagName("tag")[0].getAttribute("k"), "error"); + assert.equal(xml.getElementsByTagName("tag")[0].getAttribute("v"), "No Valid Feature Code"); + + }); + +});