-
Notifications
You must be signed in to change notification settings - Fork 74
/
marketplace.js
79 lines (64 loc) · 2.7 KB
/
marketplace.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var assert = require('assert'),
xml2js = require('xml2js'),
DOMParser = new require('@xmldom/xmldom').DOMParser
parser = new DOMParser();
var server = require('../TranslationServer.js');
describe('TranslationServer maintains Building and Facilty with same FFN', function () {
this.timeout(5000);
var fcodes = [
'AL010',
'AL013'
];
var ffns = [272, 343, 459, 460, 464, 465, 466, 474, 475, 476, 478, 640, 691, 701, 706, 711, 714, 717, 752, 760, 770, 775, 801, 810, 811, 812, 813, 814, 818, 819, 961, 962]
var schemas = [
'TDSv71',
'TDSv70',
'TDSv61',
'TDSv40',
// 'MGCP',
'GGDMv30'
]
schemas.forEach(schema => {
var fcode_key = (schema === 'MGCP') ? 'FCODE' : 'F_CODE';
fcodes.forEach(fcode => {
if (schema === 'MGCP' && fcode === 'AL013') fcode = 'AL015';
ffns.forEach(ffn => {
it('should translate ' + fcode_key + '=' + fcode + ' and FFN=' + ffn + ' from ' + schema + ' -> osm -> ' + schema, function() {
var tds_xml = '<osm version="0.6">\
<way id="-19">\
<nd ref="-10" /> <nd ref="-11" /> <nd ref="-12" /> <nd ref="-13" /> <nd ref="-10" />\
<tag k="' + fcode_key + '" v="' + fcode + '"/>\
<tag k="FFN" v="' + ffn + '"/>\
</way>\
</osm>';
var osm_xml = server.handleInputs({
osm: tds_xml,
method: 'POST',
translation: schema,
path: '/translateFrom'
});
// console.log(osm_xml);
var tds_xml = server.handleInputs({
osm: osm_xml,
method: 'POST',
translation: schema,
path: '/translateTo'
});
// console.log(tds_xml);
xml = parser.parseFromString(tds_xml);
for (var i=0; i < xml.getElementsByTagName("tag").length; i++) {
var tag = xml.getElementsByTagName("tag")[i];
if (tag.getAttribute("k") === fcode_key) {
assert.equal(tag.getAttribute("v"), fcode);
continue;
}
if (tag.getAttribute("k") === "FFN") {
assert.equal(tag.getAttribute("v"), ffn);
}
}
assert.equal(xml.getElementsByTagName("osm")[0].getAttribute("schema"), schema);
});
});
});
});
});