Skip to content

Commit cdf0b09

Browse files
authored
Update utils.test.js
1 parent 4895003 commit cdf0b09

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/utils.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test('Test joining 2 ways', () => {
4747
expect(result.outerHTML).toBe(way3);
4848
});
4949

50-
test('Test combining 2 ways', () => {
50+
test('Test combining 2 ways 1->2', () => {
5151
var way1 = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/></way>';
5252
var way2 = '<way id="2"><nd ref="3"/><nd ref="4"/><nd ref="1"/></way>';
5353
var way3 = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="1"/></way>';
@@ -60,6 +60,19 @@ test('Test combining 2 ways', () => {
6060
expect(result[0].outerHTML).toBe(way3);
6161
});
6262

63+
test('Test combining 2 ways 2->1', () => {
64+
var way2 = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/></way>';
65+
var way1 = '<way id="2"><nd ref="3"/><nd ref="4"/><nd ref="1"/></way>';
66+
var way3 = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="1"/></way>';
67+
let parser = new window.DOMParser();
68+
let xml1 = parser.parseFromString(way1, 'text/xml').getElementsByTagName('way')[0];
69+
let xml2 = parser.parseFromString(way2, 'text/xml').getElementsByTagName('way')[0];
70+
let result = BuildingShapeUtils.combineWays([xml1, xml2]);
71+
expect(result.length).toBe(1);
72+
let expected = parser.parseFromString(way3, 'text/xml');
73+
expect(result[0].outerHTML).toBe(way3);
74+
});
75+
6376
test('Test combining 2 unaligned ways', () => {
6477
var way1 = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/></way>';
6578
var way2 = '<way id="2"><nd ref="1"/><nd ref="4"/><nd ref="3"/></way>';

0 commit comments

Comments
 (0)