@geolonia/embed 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/embed +1 -1
  2. package/dist/embed-chunks/12cbd0d1cb4cf744c32f.js +2 -0
  3. package/dist/embed-chunks/8a521e8312a5b4da123d.js +2 -0
  4. package/dist/embed-core.js +1 -1
  5. package/dist/embed-core.js.LICENSE.txt +1 -1
  6. package/dist/embed.js +1 -1
  7. package/dist/embed.js.LICENSE.txt +1 -1
  8. package/dist/version.d.ts +1 -0
  9. package/package.json +4 -7
  10. package/src/lib/keyring.test.ts +34 -46
  11. package/src/lib/parse-atts.test.ts +2 -2
  12. package/src/lib/simplestyle.test.ts +94 -56
  13. package/src/lib/util.test.ts +88 -122
  14. package/src/testability.test.ts +13 -10
  15. package/tsconfig.build.json +9 -0
  16. package/tsconfig.json +1 -0
  17. package/vitest.config.ts +8 -0
  18. package/webpack.config.js +6 -1
  19. package/.mocharc.js +0 -9
  20. package/dist/e2e/basic.spec.d.ts +0 -8
  21. package/dist/e2e/external-style.spec.d.ts +0 -1
  22. package/dist/e2e/helper.d.ts +0 -4
  23. package/dist/e2e/map.spec.d.ts +0 -1
  24. package/dist/embed-chunks/2489af4328c51b71e92d.js +0 -2
  25. package/dist/embed-chunks/8983d465846d11f2859f.js +0 -2
  26. package/dist/playwright.config.d.ts +0 -9
  27. package/dist/src/lib/keyring.test.d.ts +0 -1
  28. package/dist/src/lib/parse-atts.test.d.ts +0 -1
  29. package/dist/src/lib/simplestyle.test.d.ts +0 -1
  30. package/dist/src/lib/util.test.d.ts +0 -1
  31. package/dist/src/testability.test.d.ts +0 -1
  32. package/dist/src/version.d.ts +0 -1
  33. /package/dist/embed-chunks/{2489af4328c51b71e92d.js.LICENSE.txt → 12cbd0d1cb4cf744c32f.js.LICENSE.txt} +0 -0
  34. /package/dist/embed-chunks/{8983d465846d11f2859f.js.LICENSE.txt → 8a521e8312a5b4da123d.js.LICENSE.txt} +0 -0
  35. /package/dist/{src/embed-core.d.ts → embed-core.d.ts} +0 -0
  36. /package/dist/{src/embed.d.ts → embed.d.ts} +0 -0
  37. /package/dist/{src/lib → lib}/CustomAttributionControl.d.ts +0 -0
  38. /package/dist/{src/lib → lib}/controls/geolonia-control.d.ts +0 -0
  39. /package/dist/{src/lib → lib}/geolonia-map.d.ts +0 -0
  40. /package/dist/{src/lib → lib}/geolonia-marker.d.ts +0 -0
  41. /package/dist/{src/lib → lib}/keyring.d.ts +0 -0
  42. /package/dist/{src/lib → lib}/maplibre-util.d.ts +0 -0
  43. /package/dist/{src/lib → lib}/parse-atts.d.ts +0 -0
  44. /package/dist/{src/lib → lib}/render.d.ts +0 -0
  45. /package/dist/{src/lib → lib}/simplestyle-vector.d.ts +0 -0
  46. /package/dist/{src/lib → lib}/simplestyle.d.ts +0 -0
  47. /package/dist/{src/lib → lib}/util.d.ts +0 -0
  48. /package/dist/{src/types-internal.d.ts → types-internal.d.ts} +0 -0
  49. /package/dist/{src/types.d.ts → types.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * MapLibre GL JS
3
- * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.7.0/LICENSE.txt
3
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v5.19.0/LICENSE.txt
4
4
  */
@@ -0,0 +1 @@
1
+ export declare const VERSION = "5.2.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geolonia/embed",
3
- "version": "5.1.0",
3
+ "version": "5.2.1",
4
4
  "description": "Geolonia embed JS API",
5
5
  "main": "dist/embed.js",
6
6
  "types": "dist/src/embed.d.ts",
@@ -24,7 +24,7 @@
24
24
  "analyze": "ANALYZE=true MAP_PLATFORM_STAGE=v1 webpack --mode production",
25
25
  "format": "prettier \"./src/**/*.ts\" --write",
26
26
  "lint": "eslint .",
27
- "test": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' NODE_OPTIONS=\"--no-experimental-strip-types\" mocha",
27
+ "test": "vitest run",
28
28
  "e2e": "playwright test"
29
29
  },
30
30
  "author": "Geolonia (https://geolonia.com)",
@@ -42,7 +42,6 @@
42
42
  "@eslint/eslintrc": "^3.3.1",
43
43
  "@eslint/js": "^9.39.1",
44
44
  "@types/jsdom": "^21.1.7",
45
- "@types/mocha": "^10.0.1",
46
45
  "@types/node": "^24.0.4",
47
46
  "@typescript-eslint/eslint-plugin": "^8.46.4",
48
47
  "@typescript-eslint/parser": "^8.46.4",
@@ -56,15 +55,13 @@
56
55
  "eslint-plugin-react-hooks": "^7.0.1",
57
56
  "globals": "^16.5.0",
58
57
  "jsdom": "^20.0.3",
59
- "jsdom-global": "^3.0.2",
60
- "mocha": "^10.2.0",
61
58
  "node-fetch": "2",
62
59
  "prettier": "^3.6.2",
63
60
  "style-loader": "^3.3.1",
64
61
  "svg-inline-loader": "^0.8.2",
65
62
  "ts-loader": "^9.4.3",
66
- "ts-node": "^10.9.1",
67
63
  "typescript": "^5.1.3",
64
+ "vitest": "^4.1.1",
68
65
  "webpack": "^5.75.0",
69
66
  "webpack-bundle-analyzer": "^4.7.0",
70
67
  "webpack-cli": "^5.0.1",
@@ -76,7 +73,7 @@
76
73
  "@mapbox/point-geometry": "^0.1.0",
77
74
  "@playwright/test": "^1.53.1",
78
75
  "@turf/center": "^6.0.1",
79
- "maplibre-gl": "5.7.0",
76
+ "maplibre-gl": "5.19.0",
80
77
  "pmtiles": "^3.0.6",
81
78
  "sanitize-html": "^2.8.0",
82
79
  "tinycolor2": "^1.4.1"
@@ -1,6 +1,6 @@
1
+ import { describe, it, expect, beforeEach, afterEach, afterAll } from 'vitest';
1
2
  import { keyring } from './keyring';
2
3
  import { JSDOM } from 'jsdom';
3
- import assert from 'assert';
4
4
 
5
5
  describe('parse api key from dom', () => {
6
6
  beforeEach(() => {
@@ -10,7 +10,7 @@ describe('parse api key from dom', () => {
10
10
  afterEach(() => {
11
11
  delete process.env.MAP_PLATFORM_STAGE;
12
12
  });
13
- after(() => {
13
+ afterAll(() => {
14
14
  keyring.reset();
15
15
  });
16
16
 
@@ -20,19 +20,19 @@ describe('parse api key from dom', () => {
20
20
  </body></html>`).window;
21
21
 
22
22
  keyring.parse(mocDocument);
23
- assert.deepEqual('abc', keyring.apiKey);
24
- assert.deepEqual('dev', keyring.stage);
23
+ expect(keyring.apiKey).toEqual('abc');
24
+ expect(keyring.stage).toEqual('dev');
25
25
  });
26
26
 
27
- it('should parse with geolonia flag', () => {
27
+ it('should parse with geolonia flag (multiple scripts)', () => {
28
28
  const { document: mocDocument } = new JSDOM(`<html><body>
29
29
  <script src="https://external.example.com/jquery.js"></script>
30
30
  <script src="https://external.example.com/?geolonia-api-key=def"></script>
31
31
  </body></html>`).window;
32
32
 
33
33
  keyring.parse(mocDocument);
34
- assert.deepEqual('def', keyring.apiKey);
35
- assert.deepEqual('dev', keyring.stage);
34
+ expect(keyring.apiKey).toEqual('def');
35
+ expect(keyring.stage).toEqual('dev');
36
36
  });
37
37
 
38
38
  it('should be "YOUR-API-KEY" and "dev"', () => {
@@ -42,8 +42,8 @@ describe('parse api key from dom', () => {
42
42
  </body></html>`).window;
43
43
 
44
44
  keyring.parse(mocDocument);
45
- assert.deepEqual('YOUR-API-KEY', keyring.apiKey);
46
- assert.deepEqual('dev', keyring.stage);
45
+ expect(keyring.apiKey).toEqual('YOUR-API-KEY');
46
+ expect(keyring.stage).toEqual('dev');
47
47
  });
48
48
 
49
49
  it('should be "YOUR-API-KEY" and "v1"', () => {
@@ -54,8 +54,8 @@ describe('parse api key from dom', () => {
54
54
  </body></html>`).window;
55
55
 
56
56
  keyring.parse(mocDocument);
57
- assert.deepEqual('YOUR-API-KEY', keyring.apiKey);
58
- assert.deepEqual('v1', keyring.stage);
57
+ expect(keyring.apiKey).toEqual('YOUR-API-KEY');
58
+ expect(keyring.stage).toEqual('v1');
59
59
  });
60
60
 
61
61
  it('should be "YOUR-API-KEY" and "v123.4"', () => {
@@ -66,8 +66,8 @@ describe('parse api key from dom', () => {
66
66
  </body></html>`).window;
67
67
 
68
68
  keyring.parse(mocDocument);
69
- assert.deepEqual('YOUR-API-KEY', keyring.apiKey);
70
- assert.deepEqual('v123.4', keyring.stage);
69
+ expect(keyring.apiKey).toEqual('YOUR-API-KEY');
70
+ expect(keyring.stage).toEqual('v123.4');
71
71
  });
72
72
 
73
73
  it('should be "YOUR-API-KEY" and "dev" if process.env.MAP_PLATFORM_STAGE is not set', () => {
@@ -78,62 +78,50 @@ describe('parse api key from dom', () => {
78
78
  </body></html>`).window;
79
79
 
80
80
  keyring.parse(mocDocument);
81
- assert.deepEqual('YOUR-API-KEY', keyring.apiKey);
82
- assert.deepEqual('dev', keyring.stage);
81
+ expect(keyring.apiKey).toEqual('YOUR-API-KEY');
82
+ expect(keyring.stage).toEqual('dev');
83
83
  });
84
84
  });
85
85
 
86
86
  describe('isGeoloniaStyleCheck', () => {
87
- const originalHref = 'https://base.example.com/parent/';
88
-
89
- before(() => {
90
- global.location = {
91
- ...global.location,
92
- href: originalHref,
93
- };
94
- });
95
-
96
- afterEach(() => {
97
- // Reset location after each test
98
- global.location = {
99
- ...global.location,
100
- href: originalHref,
101
- };
102
- });
103
-
104
87
  it('should return true for empty or null style (default)', () => {
105
- assert.strictEqual(keyring.isGeoloniaStyleCheck(''), true);
106
- assert.strictEqual(keyring.isGeoloniaStyleCheck(null), true);
107
- assert.strictEqual(keyring.isGeoloniaStyleCheck(undefined), true);
88
+ expect(keyring.isGeoloniaStyleCheck('')).toBe(true);
89
+ expect(keyring.isGeoloniaStyleCheck(null)).toBe(true);
90
+ expect(keyring.isGeoloniaStyleCheck(undefined)).toBe(true);
108
91
  });
109
92
 
110
93
  it('should return true for Geolonia logical names', () => {
111
- assert.strictEqual(keyring.isGeoloniaStyleCheck('geolonia/basic'), true);
112
- assert.strictEqual(keyring.isGeoloniaStyleCheck('geolonia/basic-v2'), true);
113
- assert.strictEqual(keyring.isGeoloniaStyleCheck('geolonia/gsi'), true);
94
+ expect(keyring.isGeoloniaStyleCheck('geolonia/basic')).toBe(true);
95
+ expect(keyring.isGeoloniaStyleCheck('geolonia/basic-v2')).toBe(true);
96
+ expect(keyring.isGeoloniaStyleCheck('geolonia/gsi')).toBe(true);
114
97
  });
115
98
 
116
99
  it('should return true for Geolonia CDN URLs', () => {
117
- assert.strictEqual(keyring.isGeoloniaStyleCheck('https://cdn.geolonia.com/style/geolonia/basic/ja.json'), true);
118
- assert.strictEqual(keyring.isGeoloniaStyleCheck('https://api.geolonia.com/v1/styles/basic.json'), true);
100
+ expect(keyring.isGeoloniaStyleCheck('https://cdn.geolonia.com/style/geolonia/basic/ja.json')).toBe(true);
101
+ expect(keyring.isGeoloniaStyleCheck('https://api.geolonia.com/v1/styles/basic.json')).toBe(true);
119
102
  });
120
103
 
121
104
  it('should return false for external HTTPS URLs', () => {
122
- assert.strictEqual(keyring.isGeoloniaStyleCheck('https://tile.openstreetmap.jp/styles/osm-bright/style.json'), false);
123
- assert.strictEqual(keyring.isGeoloniaStyleCheck('https://example.com/style.json'), false);
105
+ expect(keyring.isGeoloniaStyleCheck('https://tile.openstreetmap.jp/styles/osm-bright/style.json')).toBe(false);
106
+ expect(keyring.isGeoloniaStyleCheck('https://example.com/style.json')).toBe(false);
124
107
  });
125
108
 
126
109
  it('should return false for relative paths to external .json files', () => {
127
- assert.strictEqual(keyring.isGeoloniaStyleCheck('./my-style.json'), false);
128
- assert.strictEqual(keyring.isGeoloniaStyleCheck('/styles/custom.json'), false);
110
+ expect(keyring.isGeoloniaStyleCheck('./my-style.json')).toBe(false);
111
+ expect(keyring.isGeoloniaStyleCheck('/styles/custom.json')).toBe(false);
129
112
  });
130
113
 
131
114
  it('should return true for relative paths to geolonia.com', () => {
132
115
  // Simulate being on geolonia.com
116
+ const origHref = global.location?.href;
133
117
  global.location = {
134
118
  ...global.location,
135
119
  href: 'https://cdn.geolonia.com/demo.html',
136
120
  };
137
- assert.strictEqual(keyring.isGeoloniaStyleCheck('./style.json'), true);
121
+ expect(keyring.isGeoloniaStyleCheck('./style.json')).toBe(true);
122
+ // Restore
123
+ if (origHref) {
124
+ global.location = { ...global.location, href: origHref };
125
+ }
138
126
  });
139
- });
127
+ });
@@ -1,5 +1,5 @@
1
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest';
1
2
  import parseAtts from './parse-atts';
2
- import assert from 'assert';
3
3
  import { JSDOM } from 'jsdom';
4
4
  import { keyring } from './keyring';
5
5
 
@@ -22,7 +22,7 @@ describe('tests for parse Attributes', () => {
22
22
  </body></html>`).window;
23
23
 
24
24
  const atts = parseAtts(mocDocument);
25
- assert.deepStrictEqual(atts, {
25
+ expect(atts).toEqual({
26
26
  lat: 0,
27
27
  lng: 0,
28
28
  zoom: 0,
@@ -1,16 +1,45 @@
1
1
  /* eslint-disable no-loss-of-precision */
2
2
  'use strict';
3
3
 
4
- import assert from 'assert';
5
- import nodeFetch from 'node-fetch';
4
+ import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
6
5
  import { random } from './util';
7
6
 
8
- window.URL.createObjectURL ||= (_: Blob | MediaSource) => 'dummy'; // To prevent `TypeError: window.URL.createObjectURL is not a function`
9
- window.requestAnimationFrame = (cb) => {
10
- cb(performance.now());
11
- return random(999999);
7
+ const originalRequestAnimationFrame = window.requestAnimationFrame;
8
+ const originalCreateObjectURL = window.URL.createObjectURL;
9
+
10
+ beforeAll(() => {
11
+ window.URL.createObjectURL ||= (_: Blob | MediaSource) => 'dummy';
12
+ window.requestAnimationFrame = (cb) => {
13
+ cb(performance.now());
14
+ return random(999999);
15
+ };
16
+ });
17
+
18
+ afterAll(() => {
19
+ window.requestAnimationFrame = originalRequestAnimationFrame;
20
+ if (originalCreateObjectURL) {
21
+ window.URL.createObjectURL = originalCreateObjectURL;
22
+ }
23
+ });
24
+
25
+ const sampleRemoteGeoJSON = {
26
+ type: 'FeatureCollection',
27
+ features: [
28
+ {
29
+ type: 'Feature',
30
+ properties: {},
31
+ geometry: {
32
+ type: 'LineString',
33
+ coordinates: [
34
+ [139.6870422363281, 35.73425097869431],
35
+ [139.76943969726562, 35.73425097869431],
36
+ [139.73922729492188, 35.66399091134812],
37
+ [139.70352172851562, 35.698571062054015],
38
+ ],
39
+ },
40
+ },
41
+ ],
12
42
  };
13
- window.fetch = nodeFetch;
14
43
 
15
44
  class Map {
16
45
  public bounds = false;
@@ -53,7 +82,6 @@ class Map {
53
82
  return { dataset: true };
54
83
  }
55
84
 
56
- // It should not be fired if GeoJSON is empty.
57
85
  fitBounds() {
58
86
  this.bounds = true;
59
87
  }
@@ -80,24 +108,21 @@ describe('Tests for simpleStyle()', () => {
80
108
  const map = new Map();
81
109
  new SimpleStyle(geojson).addTo(map).fitBounds();
82
110
 
83
- assert.deepEqual(
111
+ expect(Object.keys(map.sources)).toEqual(
84
112
  ['geolonia-simple-style', 'geolonia-simple-style-points'],
85
- Object.keys(map.sources),
86
113
  );
87
- assert.deepEqual(8, map.layers.length);
88
- assert.deepEqual(true, map.bounds);
89
- assert.deepEqual(
90
- true,
114
+ expect(map.layers.length).toEqual(8);
115
+ expect(map.bounds).toEqual(true);
116
+ expect(
91
117
  map.layers.find(
92
118
  (layer) => layer.id === 'geolonia-simple-style-symbol-points',
93
119
  ).layout['icon-allow-overlap'],
94
- );
95
- assert.deepEqual(
96
- true,
120
+ ).toEqual(true);
121
+ expect(
97
122
  map.layers.find(
98
123
  (layer) => layer.id === 'geolonia-simple-style-symbol-points',
99
124
  ).layout['text-allow-overlap'],
100
- );
125
+ ).toEqual(true);
101
126
  });
102
127
 
103
128
  it('should has sources and layers as expected with custom IDs', async () => {
@@ -106,12 +131,11 @@ describe('Tests for simpleStyle()', () => {
106
131
  const map = new Map();
107
132
  new SimpleStyle(geojson, { id: 'hello-world' }).addTo(map).fitBounds();
108
133
 
109
- assert.deepEqual(
134
+ expect(Object.keys(map.sources)).toEqual(
110
135
  ['hello-world', 'hello-world-points'],
111
- Object.keys(map.sources),
112
136
  );
113
- assert.deepEqual(8, map.layers.length);
114
- assert.deepEqual(true, map.bounds);
137
+ expect(map.layers.length).toEqual(8);
138
+ expect(map.bounds).toEqual(true);
115
139
  });
116
140
 
117
141
  it('should has sources and layers as expected with empty GeoJSON', async () => {
@@ -126,12 +150,11 @@ describe('Tests for simpleStyle()', () => {
126
150
 
127
151
  new SimpleStyle(empty, { id: 'hello-world' }).addTo(map).fitBounds();
128
152
 
129
- assert.deepEqual(
153
+ expect(Object.keys(map.sources)).toEqual(
130
154
  ['hello-world', 'hello-world-points'],
131
- Object.keys(map.sources),
132
155
  );
133
- assert.deepEqual(8, map.layers.length);
134
- assert.deepEqual(false, map.bounds);
156
+ expect(map.layers.length).toEqual(8);
157
+ expect(map.bounds).toEqual(false);
135
158
  });
136
159
 
137
160
  it('should update GeoJSON', async () => {
@@ -146,32 +169,34 @@ describe('Tests for simpleStyle()', () => {
146
169
 
147
170
  const ss = new SimpleStyle(empty).addTo(map).fitBounds();
148
171
 
149
- assert.deepEqual(
172
+ expect(Object.keys(map.sources)).toEqual(
150
173
  ['geolonia-simple-style', 'geolonia-simple-style-points'],
151
- Object.keys(map.sources),
152
174
  );
153
- assert.deepEqual(8, map.layers.length);
154
- assert.deepEqual(false, map.bounds);
155
- assert.deepEqual(
156
- 0,
175
+ expect(map.layers.length).toEqual(8);
176
+ expect(map.bounds).toEqual(false);
177
+ expect(
157
178
  map.sources['geolonia-simple-style-points'].data.features.length,
158
- );
179
+ ).toEqual(0);
159
180
 
160
- ss.updateData(geojson); // The GeoJSON is not empty.
161
- assert.deepEqual(false, map.bounds); // `fitBounds()` doesn't fire.
162
- assert.deepEqual(
163
- 1,
181
+ ss.updateData(geojson);
182
+ expect(map.bounds).toEqual(false);
183
+ expect(
164
184
  map.sources['geolonia-simple-style-points'].data.features.length,
165
- );
185
+ ).toEqual(1);
166
186
  });
167
187
 
168
188
  it('should load GeoJSON from url', async () => {
169
189
  const { SimpleStyle } = await import('./simplestyle');
190
+ const fetchSpy = vi.spyOn(window, 'fetch').mockResolvedValue(
191
+ new Response(JSON.stringify(sampleRemoteGeoJSON), {
192
+ status: 200,
193
+ headers: { 'content-type': 'application/json' },
194
+ }),
195
+ );
170
196
 
171
197
  const map = new Map();
172
- const geojson =
173
- 'https://gist.githubusercontent.com/miya0001/56c3dc174f5cdf1d9565cbca0fbd3c48/raw/c13330036d28ef547a8a87cb6df3fa12de19ddb6/test.geojson';
174
- const ss = new SimpleStyle(geojson);
198
+ const geojsonUrl = 'https://example.com/test.geojson';
199
+ const ss = new SimpleStyle(geojsonUrl);
175
200
  ss.addTo(map).fitBounds();
176
201
 
177
202
  await ss._loadingPromise;
@@ -188,31 +213,43 @@ describe('Tests for simpleStyle()', () => {
188
213
  [139.70352172851562, 35.698571062054015],
189
214
  ];
190
215
 
191
- assert.deepEqual(expectCoordinates, coordinates);
192
- assert.deepEqual('LineString', type);
193
- assert.deepEqual(true, map.bounds);
216
+ expect(coordinates).toEqual(expectCoordinates);
217
+ expect(type).toEqual('LineString');
218
+ expect(map.bounds).toEqual(true);
219
+
220
+ fetchSpy.mockRestore();
194
221
  });
195
222
 
196
223
  it('should load empty GeoJSON when failed to fetch GeoJSON', async () => {
197
224
  const { SimpleStyle } = await import('./simplestyle');
225
+ const fetchSpy = vi.spyOn(window, 'fetch').mockResolvedValue(
226
+ new Response('Not Found', { status: 404 }),
227
+ );
198
228
 
199
229
  const map = new Map();
200
- const geojson = 'https://example.com/404.geojson';
201
- const ss = new SimpleStyle(geojson);
230
+ const geojsonUrl = 'https://example.com/404.geojson';
231
+ const ss = new SimpleStyle(geojsonUrl);
202
232
  ss.addTo(map).fitBounds();
203
233
 
204
234
  await ss._loadingPromise;
205
235
 
206
- assert.deepEqual(
236
+ expect(Object.keys(map.sources)).toEqual(
207
237
  ['geolonia-simple-style', 'geolonia-simple-style-points'],
208
- Object.keys(map.sources),
209
238
  );
210
- assert.deepEqual(8, map.layers.length);
211
- assert.deepEqual(false, map.bounds);
239
+ expect(map.layers.length).toEqual(8);
240
+ expect(map.bounds).toEqual(false);
241
+
242
+ fetchSpy.mockRestore();
212
243
  });
213
244
 
214
245
  it('should update GeoJSON from url', async () => {
215
246
  const { SimpleStyle } = await import('./simplestyle');
247
+ const fetchSpy = vi.spyOn(window, 'fetch').mockResolvedValue(
248
+ new Response(JSON.stringify(sampleRemoteGeoJSON), {
249
+ status: 200,
250
+ headers: { 'content-type': 'application/json' },
251
+ }),
252
+ );
216
253
 
217
254
  const map = new Map();
218
255
  const empty = {
@@ -225,10 +262,9 @@ describe('Tests for simpleStyle()', () => {
225
262
 
226
263
  await ss._loadingPromise;
227
264
 
228
- const geojson =
229
- 'https://gist.githubusercontent.com/miya0001/56c3dc174f5cdf1d9565cbca0fbd3c48/raw/c13330036d28ef547a8a87cb6df3fa12de19ddb6/test.geojson';
265
+ const geojsonUrl = 'https://example.com/test.geojson';
230
266
 
231
- ss.updateData(geojson);
267
+ ss.updateData(geojsonUrl);
232
268
 
233
269
  await ss._loadingPromise;
234
270
 
@@ -244,8 +280,10 @@ describe('Tests for simpleStyle()', () => {
244
280
  [139.70352172851562, 35.698571062054015],
245
281
  ];
246
282
 
247
- assert.deepEqual(expectCoordinates, coordinates);
248
- assert.deepEqual('LineString', type);
249
- assert.deepEqual(true, map.bounds);
283
+ expect(coordinates).toEqual(expectCoordinates);
284
+ expect(type).toEqual('LineString');
285
+ expect(map.bounds).toEqual(true);
286
+
287
+ fetchSpy.mockRestore();
250
288
  });
251
289
  });