Skip to content

Commit 1bac46f

Browse files
authored
Update utils.test.js
1 parent 0944f44 commit 1bac46f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

test/utils.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,32 @@ test('Longest side angle', () => {
7575
expect(rightTriangle.extractPoints().shape.length).toBe(3);
7676
expect(BuildingShapeUtils.longestSideAngle(rightTriangle)).toBe(-Math.PI / 4);
7777
});
78+
79+
// Combine these next 4 into a test runner.
80+
test('non-intersecting open way', () => {
81+
const way = '<way id="1"><nd ref="1"/><nd ref="2"/></way>';
82+
let parser = new window.DOMParser();
83+
let xml = parser.parseFromString(way, 'text/xml').getElementsByTagName('way')[0];
84+
expect(BuildingShapeUtils.isSelfIntersecting(xml)).toBe(false);
85+
});
86+
87+
test('non-intersecting closed way', () => {
88+
const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="1"/></way>';
89+
let parser = new window.DOMParser();
90+
let xml = parser.parseFromString(way, 'text/xml').getElementsByTagName('way')[0];
91+
expect(BuildingShapeUtils.isSelfIntersecting(xml)).toBe(false);
92+
});
93+
94+
test('intersecting open way', () => {
95+
const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="2"/></way>';
96+
let parser = new window.DOMParser();
97+
let xml = parser.parseFromString(way, 'text/xml').getElementsByTagName('way')[0];
98+
expect(BuildingShapeUtils.isSelfIntersecting(xml)).toBe(true);
99+
});
100+
101+
test('intersecting closed way', () => {
102+
const way = '<way id="1"><nd ref="1"/><nd ref="2"/><nd ref="3"/><nd ref="4"/><nd ref="3"/><nd ref="1"/></way>';
103+
let parser = new window.DOMParser();
104+
let xml = parser.parseFromString(way, 'text/xml').getElementsByTagName('way')[0];
105+
expect(BuildingShapeUtils.isSelfIntersecting(xml)).toBe(true);
106+
});

0 commit comments

Comments
 (0)