Skip to content

Commit 704dbfd

Browse files
authored
Update utils.test.js
1 parent 7ad6fe4 commit 704dbfd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/utils.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ test('Test combining 2 ways', () => {
5151
expect(result[0].outerHTML).toBe(way3);
5252
});
5353

54+
test('Test combining 2 unaligned ways', () => {
55+
var way1 = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/></way>';
56+
var way2 = '<way id="2"><nd ref="1"/><nd ref="4"/><nd ref="3"/></way>';
57+
var way3 = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="1"/></way>';
58+
let parser = new window.DOMParser();
59+
let xml1 = parser.parseFromString(way1, 'text/xml').getElementsByTagName('way')[0];
60+
let xml2 = parser.parseFromString(way2, 'text/xml').getElementsByTagName('way')[0];
61+
let result = BuildingShapeUtils.combineWays([xml1, xml2]);
62+
expect(result.length).toBe(1);
63+
let expected = parser.parseFromString(way3, 'text/xml');
64+
expect(result[0].outerHTML).toBe(way3);
65+
});
66+
5467
const rightTriangle = new Shape();
5568
rightTriangle.moveTo(1, 1);
5669
rightTriangle.lineTo(1, -1);

0 commit comments

Comments
 (0)