Skip to content

Commit 32c2626

Browse files
authored
Update combine_ways.test.js
1 parent bf4a067 commit 32c2626

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

test/combine_ways.test.js

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ test('Test combining 2 ways 1->2', () => {
3232
let result = BuildingShapeUtils.combineWays([xml1, xml2, xml3]);
3333
// Expect one closed way with 3 unique nodes.
3434
expect(result.length).toBe(1);
35-
expect(BuildingShapeUtils.isClosed(result[0]));
35+
expect(BuildingShapeUtils.isClosed(result[0])).toBe(true);
3636
expect(result[0].getElementsByTagName('nd').length).toBe(4);
37-
// expect result to contain nodes 1, 2 and 3.
37+
expect(BuildingShapeUtils.isSelfIntersecting(result[0])).toBe(false);
3838
});
3939

4040
test('Test combining 3 ways 2->1->3', () => {
@@ -47,9 +47,9 @@ test('Test combining 3 ways 2->1->3', () => {
4747
let xml3 = parser.parseFromString(way3, 'text/xml').getElementsByTagName('way')[0];
4848
let result = BuildingShapeUtils.combineWays([xml1, xml2, xml3]);
4949
expect(result.length).toBe(1);
50-
expect(BuildingShapeUtils.isClosed(result[0]));
51-
// expect 4 nodes
52-
// expect result to contain nodes 1, 2 and 3.
50+
expect(BuildingShapeUtils.isClosed(result[0])).toBe(true);
51+
expect(BuildingShapeUtils.isSelfIntersecting(result[0])).toBe(false);
52+
expect(result[0].getElementsByTagName('nd').length).toBe(4);
5353
});
5454

5555
test('Test combining 2 unaligned ways', () => {
@@ -62,9 +62,9 @@ test('Test combining 2 unaligned ways', () => {
6262
let xml3 = parser.parseFromString(way3, 'text/xml').getElementsByTagName('way')[0];
6363
let result = BuildingShapeUtils.combineWays([xml1, xml2, xml3]);
6464
expect(result.length).toBe(1);
65-
expect(BuildingShapeUtils.isClosed(result[0]));
66-
// expect 4 nodes
67-
// expect result to contain nodes 1, 2 and 3.
65+
expect(BuildingShapeUtils.isClosed(result[0])).toBe(true);
66+
expect(BuildingShapeUtils.isSelfIntersecting(result[0])).toBe(false);
67+
expect(result[0].getElementsByTagName('nd').length).toBe(4);
6868
});
6969

7070
test('Test combining 3 ways 1->2->3', () => {
@@ -78,9 +78,9 @@ test('Test combining 3 ways 1->2->3', () => {
7878
let xml3 = parser.parseFromString(way3, 'text/xml').getElementsByTagName('way')[0];
7979
let result = BuildingShapeUtils.combineWays([xml1, xml2, xml3]);
8080
expect(result.length).toBe(1);
81-
expect(BuildingShapeUtils.isClosed(result[0]));
82-
// expect 4 nodes
83-
// expect result to contain nodes 1, 2 and 3.
81+
expect(BuildingShapeUtils.isClosed(result[0])).toBe(true);
82+
expect(BuildingShapeUtils.isSelfIntersecting(result[0])).toBe(false);
83+
expect(result[0].getElementsByTagName('nd').length).toBe(4);
8484
});
8585

8686
test('Test combining 4 ways', () => {
@@ -96,24 +96,6 @@ test('Test combining 4 ways', () => {
9696
let result = BuildingShapeUtils.combineWays([xml1, xml2, xml3, xml4]);
9797
expect(result.length).toBe(1);
9898
expect(BuildingShapeUtils.isClosed(result[0]));
99-
// expect 5 nodes
100-
// expect result to contain nodes 1, 2 3, and 4.
101-
});
102-
103-
/**test('Test combining 4 ways, one not part of loop', () => {
104-
var way1 = '<way id="1"><nd ref="1"/><nd ref="2"/></way>';
105-
var way2 = '<way id="2"><nd ref="3"/><nd ref="4"/></way>';
106-
var way3 = '<way id="3"><nd ref="3"/><nd ref="1"/></way>';
107-
var way4 = '<way id="4"><nd ref="2"/><nd ref="3"/></way>';
108-
let parser = new window.DOMParser();
109-
let xml1 = parser.parseFromString(way1, 'text/xml').getElementsByTagName('way')[0];
110-
let xml2 = parser.parseFromString(way2, 'text/xml').getElementsByTagName('way')[0];
111-
let xml3 = parser.parseFromString(way3, 'text/xml').getElementsByTagName('way')[0];
112-
let xml4 = parser.parseFromString(way4, 'text/xml').getElementsByTagName('way')[0];
113-
let result = BuildingShapeUtils.combineWays([xml1, xml2, xml3, xml4]);
114-
expect(result.length).toBe(1);
115-
expect(BuildingShapeUtils.isClosed(result[1]));
116-
// expect 4 nodes
117-
// expect result to contain nodes 1, 2 and 3.
99+
expect(BuildingShapeUtils.isSelfIntersecting(result[0])).toBe(false);
100+
expect(result[0].getElementsByTagName('nd').length).toBe(5);
118101
});
119-
*/

0 commit comments

Comments
 (0)