Skip to content

Commit 5746cd1

Browse files
authored
Update combine_ways.test.js
1 parent a34c71d commit 5746cd1

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

test/combine_ways.test.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,24 @@ test('Test combining 3 ways 1->2->3', () => {
8282
expect(result[0].getElementsByTagName('nd').length).toBe(4);
8383
});
8484

85-
tests = [
86-
[[
87-
'<way id="1"><nd ref="1"/><nd ref="2"/></way>',
88-
'<way id="2"><nd ref="3"/><nd ref="4"/></way>',
89-
'<way id="3"><nd ref="4"/><nd ref="1"/></way>',
90-
'<way id="4"><nd ref="2"/><nd ref="3"/></way>',
91-
], 1, 4],
92-
];
93-
test.each()('Test combining 4 ways', (ways, length, nodes) => {
94-
let parser = new window.DOMParser();
95-
xml = [];
96-
for (const way of ways){
97-
xml.push(parser.parseFromString(way, 'text/xml').getElementsByTagName('way')[0]);
98-
}
99-
let result = BuildingShapeUtils.combineWays(xml);
100-
expect(result.length).toBe(length);
101-
expect(BuildingShapeUtils.isClosed(result[0]));
102-
expect(BuildingShapeUtils.isSelfIntersecting(result[0])).toBe(false);
103-
expect(result[0].getElementsByTagName('nd').length).toBe(nodes);
85+
describe('Combine Ways', () => {
86+
test.each([
87+
[[
88+
'<way id="1"><nd ref="1"/><nd ref="2"/></way>',
89+
'<way id="2"><nd ref="3"/><nd ref="4"/></way>',
90+
'<way id="3"><nd ref="4"/><nd ref="1"/></way>',
91+
'<way id="4"><nd ref="2"/><nd ref="3"/></way>',
92+
], 1, 4, 'Test combining 4 ways',
93+
])('${description}', (ways, length, nodes, description) => {
94+
let parser = new window.DOMParser();
95+
xml = [];
96+
for (const way of ways){
97+
xml.push(parser.parseFromString(way, 'text/xml').getElementsByTagName('way')[0]);
98+
}
99+
let result = BuildingShapeUtils.combineWays(xml);
100+
expect(result.length).toBe(length);
101+
expect(BuildingShapeUtils.isClosed(result[0]));
102+
expect(BuildingShapeUtils.isSelfIntersecting(result[0])).toBe(false);
103+
expect(result[0].getElementsByTagName('nd').length).toBe(nodes);
104+
});
104105
});

0 commit comments

Comments
 (0)