Skip to content

Commit caa56ea

Browse files
authored
Create diagnose.test.js
1 parent bbeba91 commit caa56ea

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

test/diagnose.test.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
5+
import { Shape, Mesh } from 'three';
6+
import { TextEncoder } from 'node:util';
7+
import {expect, test, beforeEach, describe} from '@jest/globals';
8+
global.TextEncoder = TextEncoder;
9+
10+
import {apis} from '../src/apis.js';
11+
global.apis = apis;
12+
13+
import { Building } from '../src/building.js';
14+
15+
import fetchMock from 'jest-fetch-mock';
16+
fetchMock.enableMocks();
17+
18+
const initialData = `<?xml version='1.0' encoding='UTF-8'?>
19+
<osm version="0.6" generator="openstreetmap-cgimap 2.0.1 (13 production-cgimap-deployment-6c848f5954-fwsw9)" copyright="OpenHistoricalMap is dedicated to the public domain except where otherwise noted." attribution="https://www.openhistoricalmap.org/copyright" license="https://creativecommons.org/public-domain/cc0/">
20+
<node id="2091055219" visible="true" version="5" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2578575" lon="-88.9935839"/>
21+
<node id="2091055220" visible="true" version="2" changeset="124696" timestamp="2024-06-24T14:12:44Z" user="CharliePlett" uid="1310" lat="17.2579092" lon="-88.9936201"/>
22+
<node id="2091055221" visible="true" version="4" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2580413" lon="-88.9936212"/>
23+
<node id="2091055225" visible="true" version="5" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2578904" lon="-88.9932578"/>
24+
<node id="2091055226" visible="true" version="5" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2580338" lon="-88.9932589"/>
25+
<node id="2091055229" visible="true" version="5" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2576142" lon="-88.9935169"/>
26+
<node id="2091055230" visible="true" version="5" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2576160" lon="-88.9932556"/>
27+
<node id="2091090152" visible="true" version="4" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2576687" lon="-88.9935824"/>
28+
<node id="2118297439" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2576137" lon="-88.9935820"/>
29+
<node id="2118297440" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2581870" lon="-88.9936225"/>
30+
<node id="2118297441" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2581863" lon="-88.9937191"/>
31+
<node id="2118297442" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2584306" lon="-88.9937212"/>
32+
<node id="2118297443" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2584351" lon="-88.9931509"/>
33+
<node id="2118297444" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2583754" lon="-88.9931504"/>
34+
<node id="2118297445" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2583756" lon="-88.9931220"/>
35+
<node id="2118297446" visible="true" version="3" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2582611" lon="-88.9931210"/>
36+
<node id="2136764872" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2576156" lon="-88.9933122"/>
37+
<node id="2136764874" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2576159" lon="-88.9932694"/>
38+
<node id="2136764882" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2584313" lon="-88.9936317"/>
39+
<node id="2136764893" visible="true" version="1" changeset="183733" timestamp="2025-07-17T03:03:42Z" user="CharliePlett" uid="1310" lat="17.2581813" lon="-88.9932416"/>
40+
<node id="2136764894" visible="true" version="1" changeset="183733" timestamp="2025-07-17T03:03:42Z" user="CharliePlett" uid="1310" lat="17.2581857" lon="-88.9932332"/>
41+
<node id="2136764895" visible="true" version="1" changeset="183733" timestamp="2025-07-17T03:03:42Z" user="CharliePlett" uid="1310" lat="17.2581881" lon="-88.9931285"/>
42+
<node id="2136764896" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2583755" lon="-88.9931289"/>
43+
<node id="2136764905" visible="true" version="1" changeset="183733" timestamp="2025-07-17T03:03:42Z" user="CharliePlett" uid="1310" lat="17.2581826" lon="-88.9932370"/>
44+
<node id="2136764906" visible="true" version="1" changeset="183733" timestamp="2025-07-17T03:03:42Z" user="CharliePlett" uid="1310" lat="17.2581866" lon="-88.9932294"/>
45+
<node id="2136764908" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2582610" lon="-88.9931268"/>
46+
<node id="2136764910" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2582610" lon="-88.9931305"/>
47+
<node id="2136765022" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2581810" lon="-88.9932601"/>
48+
<node id="2136765040" visible="true" version="1" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310" lat="17.2576138" lon="-88.9935727"/>
49+
<way id="201181659" visible="true" version="2" changeset="183738" timestamp="2025-07-17T03:14:16Z" user="CharliePlett" uid="1310">
50+
<nd ref="2091055230"/>
51+
<nd ref="2091055225"/>
52+
<nd ref="2091055226"/>
53+
<nd ref="2136765022"/>
54+
<nd ref="2136764893"/>
55+
<nd ref="2136764905"/>
56+
<nd ref="2136764894"/>
57+
<nd ref="2136764906"/>
58+
<nd ref="2136764895"/>
59+
<nd ref="2136764910"/>
60+
<nd ref="2136764908"/>
61+
<nd ref="2118297446"/>
62+
<nd ref="2118297445"/>
63+
<nd ref="2136764896"/>
64+
<nd ref="2118297444"/>
65+
<nd ref="2118297443"/>
66+
<nd ref="2136764882"/>
67+
<nd ref="2118297442"/>
68+
<nd ref="2118297441"/>
69+
<nd ref="2118297440"/>
70+
<nd ref="2091055221"/>
71+
<nd ref="2091055220"/>
72+
<nd ref="2091055219"/>
73+
<nd ref="2091090152"/>
74+
<nd ref="2118297439"/>
75+
<nd ref="2136765040"/>
76+
<nd ref="2091055229"/>
77+
<nd ref="2136764872"/>
78+
<nd ref="2136764874"/>
79+
<nd ref="2091055230"/>
80+
<tag k="building" v="industrial"/>
81+
<tag k="name" v="Country Foods"/>
82+
<tag k="start_date" v="2025"/>
83+
<tag k="wikidata" v="Q39057725"/>
84+
<tag k="wikipedia" v="en:Country Foods"/>
85+
</way>
86+
</osm>
87+
`;
88+
89+
test('Diagnose Skillion Issue', async() => {
90+
fetch.mockResponses(
91+
[initialData], // /way/201181659/full
92+
[initialData], // /map call
93+
);
94+
const innerData = await Building.downloadDataAroundBuilding('way', '201181659');
95+
const building = new Building('201181659', innerData);
96+
expect(building.id).toBe('201181659');
97+
const urlBase = 'https://api.openstreetmap.org/api/0.6/';
98+
expect(global.fetch.mock.calls[0][0]).toBe(urlBase + 'relation/42/full');
99+
expect(global.fetch.mock.calls[1][0]).toBe(urlBase + 'map?bbox=30.4980057,59.9380365,30.4993839,59.9385087');
100+
});

0 commit comments

Comments
 (0)