Test XML formatter as well

This commit is contained in:
Tom MacWright
2012-11-26 17:46:04 -05:00
parent 224420883a
commit 704bd1af2e
3 changed files with 22 additions and 1 deletions

View File

@@ -63,7 +63,6 @@ iD.format.XML = {
'@lat': entity.lat, '@lon': entity.lon,
'@version': (entity.version || 0),
tag: _.map(entity.tags, function(v, k) {
console.log(k, v);
return { keyAttributes: { k: k, v: v } };
})
}

View File

@@ -49,6 +49,7 @@
<script type="text/javascript" src="spec/Map.js"></script>
<script type="text/javascript" src="spec/Connection.js"></script>
<script type="text/javascript" src="spec/GeoJSON.js"></script>
<script type="text/javascript" src="spec/XML.js"></script>
<script type="text/javascript" src="spec/Inspector.js"></script>
<script type="text/javascript">

21
test/spec/XML.js Normal file
View File

@@ -0,0 +1,21 @@
describe('XML', function() {
describe('#rep', function() {
it('should be able to map a node to jxon', function() {
expect(iD.format.XML.rep({ id: 'n-1', type: 'node', lat: 38, lon: -77 }))
.toEqual({ node : { '@id': '-1', '@lat': 38, '@lon': -77, '@version': 0, tag: [ ] } });
});
});
describe('#mapping', function() {
it('should be able to map a node to xml', function() {
expect(iD.format.XML.mapping({ id: 'n-1', type: 'node', lat: 38, lon: -77 }))
.toEqual('&lt;node id=&quot;-1&quot; lat=&quot;38&quot; lon=&quot;-77&quot; version=&quot;0&quot;/&gt;');
});
it('should be able to map a way to xml', function() {
var way = { type: 'way', nodes: [], id: 'w-1' };
var gj = iD.format.XML.mapping(way);
expect(gj).toEqual('&lt;way id=&quot;-1&quot;/&gt;');
});
});
});