@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,5 @@
1
- import assert from 'assert';
1
+ import { describe, it, expect, beforeAll } from 'vitest';
2
+
2
3
  import { JSDOM } from 'jsdom';
3
4
  import {
4
5
  getContainer,
@@ -17,7 +18,7 @@ import {
17
18
 
18
19
  const base = 'https://base.example.com/parent/';
19
20
 
20
- before(() => {
21
+ beforeAll(() => {
21
22
  global.location = {
22
23
  ...global.location,
23
24
  href: base,
@@ -26,58 +27,52 @@ before(() => {
26
27
 
27
28
  describe('Tests for util.js', () => {
28
29
  it('URL should be detected', () => {
29
- assert.deepEqual(true, !!isURL('http://example.com'));
30
+ expect(true).toEqual(!!isURL('http://example.com'));
30
31
  });
31
32
 
32
33
  it('URL with SSL should be detected', () => {
33
- assert.deepEqual(true, !!isURL('https://example.com'));
34
+ expect(true).toEqual(!!isURL('https://example.com'));
34
35
  });
35
36
 
36
37
  it('Path should be detected', () => {
37
- assert.deepEqual(
38
- 'https://base.example.com/parent/example-path',
39
- isURL('./example-path'),
38
+ expect('https://base.example.com/parent/example-path').toEqual(isURL('./example-path'),
40
39
  );
41
40
  });
42
41
 
43
42
  it('Parent path should be detected', () => {
44
- assert.deepEqual(
45
- 'https://base.example.com/example-path',
46
- isURL('../example-path'),
43
+ expect('https://base.example.com/example-path').toEqual(isURL('../example-path'),
47
44
  );
48
45
  });
49
46
 
50
47
  it('Absolute path should be detected', () => {
51
- assert.deepEqual(
52
- 'https://base.example.com/example-path',
53
- isURL('/example-path'),
48
+ expect('https://base.example.com/example-path').toEqual(isURL('/example-path'),
54
49
  );
55
50
  });
56
51
 
57
52
  it('Name should not be detected', () => {
58
- assert.deepEqual(false, isURL('example.com/hello'));
53
+ expect(false).toEqual(isURL('example.com/hello'));
59
54
  });
60
55
 
61
56
  describe('isGeoloniaTilesHost', () => {
62
57
  it('detects primary tileserver hostname', () => {
63
58
  const url =
64
59
  'https://tileserver.geolonia.com/v3/tiles.json?key=YOUR-API-KEY';
65
- assert.strictEqual(isGeoloniaTilesHost(url), true);
60
+ expect(isGeoloniaTilesHost(url)).toBe(true);
66
61
  });
67
62
 
68
63
  it('detects tiles.geolonia.com subdomains', () => {
69
64
  const url = new URL('https://osm.v2.tiles.geolonia.com/tiles.json');
70
- assert.strictEqual(isGeoloniaTilesHost(url), true);
65
+ expect(isGeoloniaTilesHost(url)).toBe(true);
71
66
  });
72
67
 
73
68
  it('detects tiles.geolonia.com subdomains', () => {
74
69
  const url = new URL('https://osm.v3.tiles.geolonia.com/tiles.json');
75
- assert.strictEqual(isGeoloniaTilesHost(url), true);
70
+ expect(isGeoloniaTilesHost(url)).toBe(true);
76
71
  });
77
72
 
78
73
  it('returns false for other hosts or invalid urls', () => {
79
- assert.strictEqual(isGeoloniaTilesHost('https://example.com/tiles'), false);
80
- assert.strictEqual(isGeoloniaTilesHost('not-a-url'), false);
74
+ expect(isGeoloniaTilesHost('https://example.com/tiles')).toBe(false);
75
+ expect(isGeoloniaTilesHost('not-a-url')).toBe(false);
81
76
  });
82
77
  });
83
78
 
@@ -86,12 +81,10 @@ describe('Tests for util.js', () => {
86
81
  <div class="test-class"></div>
87
82
  </body></html>`).window;
88
83
 
89
- assert.deepEqual(
90
- true,
91
- isDomElement(mocDocument.querySelector('.test-class')),
84
+ expect(true).toEqual(isDomElement(mocDocument.querySelector('.test-class')),
92
85
  );
93
- assert.deepEqual(false, isDomElement('hello world'));
94
- assert.deepEqual(false, isDomElement({ hello: 'world' }));
86
+ expect(false).toEqual(isDomElement('hello world'));
87
+ expect(false).toEqual(isDomElement({ hello: 'world' }));
95
88
  });
96
89
 
97
90
  it('should be able to get dom', () => {
@@ -104,23 +97,23 @@ describe('Tests for util.js', () => {
104
97
  global.document = dom.window.document;
105
98
 
106
99
  const el = document.querySelector('#test-element') as HTMLElement;
107
- assert.deepEqual(el, getContainer(el));
100
+ expect(el).toEqual(getContainer(el));
108
101
  const params = { container: el };
109
- assert.deepEqual(el, getContainer(params));
102
+ expect(el).toEqual(getContainer(params));
110
103
 
111
104
  // specify as a selector
112
- assert.deepEqual(el, getContainer('#test-element'));
113
- assert.deepEqual(el, getContainer({ container: '#test-element' }));
105
+ expect(el).toEqual(getContainer('#test-element'));
106
+ expect(el).toEqual(getContainer({ container: '#test-element' }));
114
107
 
115
108
  // specify as an id attribute value
116
- assert.deepEqual(el, getContainer('test-element'));
117
- assert.deepEqual(el, getContainer({ container: 'test-element' }));
109
+ expect(el).toEqual(getContainer('test-element'));
110
+ expect(el).toEqual(getContainer({ container: 'test-element' }));
118
111
 
119
112
  // negative cases
120
- assert.deepEqual(false, getContainer('#fail-element'));
121
- assert.deepEqual(false, getContainer({ container: '#fail-element' }));
122
- assert.deepEqual(false, getContainer('fail-element'));
123
- assert.deepEqual(false, getContainer({ container: 'fail-element' }));
113
+ expect(false).toEqual(getContainer('#fail-element'));
114
+ expect(false).toEqual(getContainer({ container: '#fail-element' }));
115
+ expect(false).toEqual(getContainer('fail-element'));
116
+ expect(false).toEqual(getContainer({ container: 'fail-element' }));
124
117
  });
125
118
 
126
119
  it('should merge legacy options into options as expected.', () => {
@@ -136,14 +129,14 @@ describe('Tests for util.js', () => {
136
129
  document.getElementById('test-element'),
137
130
  { color: '#FF1122' },
138
131
  );
139
- assert.deepEqual(document.getElementById('test-element'), options1.element);
140
- assert.deepEqual(options1.color, '#FF1122');
132
+ expect(document.getElementById('test-element')).toEqual(options1.element);
133
+ expect(options1.color).toEqual('#FF1122');
141
134
 
142
135
  const options2 = handleMarkerOptions(false, { color: '#FF1122' });
143
- assert.deepEqual(options2.color, '#FF1122');
136
+ expect(options2.color).toEqual('#FF1122');
144
137
 
145
138
  const options3 = handleMarkerOptions({ scale: 2 }, { color: '#FF1122' });
146
- assert.deepEqual(options3.scale, 2);
139
+ expect(options3.scale).toEqual(2);
147
140
  });
148
141
 
149
142
  describe('language detection', () => {
@@ -155,7 +148,7 @@ describe('Tests for util.js', () => {
155
148
  languages: ['ja', 'en', 'en-US', 'ar'],
156
149
  },
157
150
  };
158
- assert.equal(getLang(), 'ja');
151
+ expect(getLang()).toEqual('ja');
159
152
  });
160
153
 
161
154
  it('should work with iOS safari', () => {
@@ -166,7 +159,7 @@ describe('Tests for util.js', () => {
166
159
  languages: ['ja-JP'],
167
160
  },
168
161
  };
169
- assert.equal(getLang(), 'ja');
162
+ expect(getLang()).toEqual('ja');
170
163
  });
171
164
  });
172
165
 
@@ -178,58 +171,40 @@ describe('Tests for util.js', () => {
178
171
  };
179
172
 
180
173
  // 従来モード: 論理名(API キー必須)
181
- assert.deepEqual(
182
- 'https://cdn.geolonia.com/style/hello/world/en.json',
183
- getStyle('hello/world', atts),
174
+ expect('https://cdn.geolonia.com/style/hello/world/en.json').toEqual(getStyle('hello/world', atts),
184
175
  );
185
176
 
186
177
  // URL モード: https://(外部 URL、API キー不要)
187
- assert.deepEqual(
188
- 'https://example.com/style.json',
189
- getStyle('https://example.com/style.json', atts),
178
+ expect('https://example.com/style.json').toEqual(getStyle('https://example.com/style.json', atts),
190
179
  );
191
180
 
192
181
  // URL モード: 相対パス ./(外部 URL、API キー不要)
193
- assert.deepEqual(
194
- 'https://base.example.com/parent/style.json',
195
- getStyle('./style.json', atts),
182
+ expect('https://base.example.com/parent/style.json').toEqual(getStyle('./style.json', atts),
196
183
  );
197
184
 
198
185
  // URL モード: 絶対パス /(外部 URL、API キー不要)
199
- assert.deepEqual(
200
- 'https://base.example.com/style.json',
201
- getStyle('/style.json', atts),
186
+ expect('https://base.example.com/style.json').toEqual(getStyle('/style.json', atts),
202
187
  );
203
188
 
204
189
  // URL モード: .json で終わる(外部 URL として解決)
205
- assert.deepEqual(
206
- 'https://base.example.com/parent/custom.json',
207
- getStyle('custom.json', atts),
190
+ expect('https://base.example.com/parent/custom.json').toEqual(getStyle('custom.json', atts),
208
191
  );
209
192
 
210
193
  // デフォルト: 空文字列(API キー必須)
211
- assert.deepEqual(
212
- 'https://cdn.geolonia.com/style/geolonia/basic-v2/en.json',
213
- getStyle('', atts),
194
+ expect('https://cdn.geolonia.com/style/geolonia/basic-v2/en.json').toEqual(getStyle('', atts),
214
195
  );
215
196
 
216
197
  // デフォルト: null/undefined(API キー必須)
217
- assert.deepEqual(
218
- 'https://cdn.geolonia.com/style/geolonia/basic-v2/en.json',
219
- getStyle(null, atts),
198
+ expect('https://cdn.geolonia.com/style/geolonia/basic-v2/en.json').toEqual(getStyle(null, atts),
220
199
  );
221
200
 
222
201
  // 日本語環境でのデフォルト
223
202
  const attsJa = { ...atts, lang: 'ja' };
224
- assert.deepEqual(
225
- 'https://cdn.geolonia.com/style/geolonia/basic-v2/ja.json',
226
- getStyle('', attsJa),
203
+ expect('https://cdn.geolonia.com/style/geolonia/basic-v2/ja.json').toEqual(getStyle('', attsJa),
227
204
  );
228
205
 
229
206
  // 日本語環境での論理名
230
- assert.deepEqual(
231
- 'https://cdn.geolonia.com/style/geolonia/basic/ja.json',
232
- getStyle('geolonia/basic', attsJa),
207
+ expect('https://cdn.geolonia.com/style/geolonia/basic/ja.json').toEqual(getStyle('geolonia/basic', attsJa),
233
208
  );
234
209
  });
235
210
 
@@ -241,93 +216,88 @@ describe('Tests for util.js', () => {
241
216
  };
242
217
 
243
218
  // 論理名: API キー無しでエラー
244
- assert.throws(
219
+ expect(
245
220
  () => getStyle('geolonia/basic', attsNoKey),
246
- /API key is required/,
247
- );
221
+ ).toThrow(/API key is required/);
248
222
 
249
223
  // デフォルト: API キー無しでエラー
250
- assert.throws(
224
+ expect(
251
225
  () => getStyle('', attsNoKey),
252
- /API key is required/,
253
- );
226
+ ).toThrow(/API key is required/);
254
227
 
255
228
  // Geolonia CDN の URL: API キー無しでエラー
256
- assert.throws(
229
+ expect(
257
230
  () => getStyle('https://cdn.geolonia.com/style/geolonia/basic/en.json', attsNoKey),
258
- /API key is required/,
259
- );
231
+ ).toThrow(/API key is required/);
260
232
 
261
233
  // 外部 URL: API キー無しでも OK
262
- assert.doesNotThrow(() => {
234
+ expect(() => {
263
235
  getStyle('https://tile.openstreetmap.jp/styles/osm-bright/style.json', attsNoKey);
264
- });
236
+ }).not.toThrow();
265
237
 
266
- assert.doesNotThrow(() => {
238
+ expect(() => {
267
239
  getStyle('./my-style.json', attsNoKey);
268
- });
240
+ }).not.toThrow();
269
241
  });
270
242
 
271
243
  it('should handle maplibregl options `minZoom` and `maxZoom` well', () => {
272
244
  {
273
245
  const atts = { minZoom: '', maxZoom: '10' };
274
246
  const options = getOptions({}, {}, atts);
275
- assert.deepEqual('undefined', typeof options.minZoom);
276
- assert.deepEqual(10, options.maxZoom);
247
+ expect('undefined').toEqual(typeof options.minZoom);
248
+ expect(10).toEqual(options.maxZoom);
277
249
  }
278
250
 
279
251
  {
280
252
  const atts = { minZoom: '0', maxZoom: '' };
281
253
  const options = getOptions({}, {}, atts);
282
- assert.deepEqual(0, options.minZoom);
283
- assert.deepEqual('undefined', typeof options.maxZoom);
254
+ expect(0).toEqual(options.minZoom);
255
+ expect('undefined').toEqual(typeof options.maxZoom);
284
256
  }
285
257
 
286
258
  {
287
259
  const atts = { minZoom: '0', maxZoom: '' };
288
260
  const params = { minZoom: 7 };
289
261
  const options = getOptions({}, params, atts);
290
- assert.deepEqual(7, options.minZoom);
291
- assert.deepEqual('undefined', typeof options.maxZoom);
262
+ expect(7).toEqual(options.minZoom);
263
+ expect('undefined').toEqual(typeof options.maxZoom);
292
264
  }
293
265
  });
294
266
 
295
267
  it('should handle control position options.', () => {
296
268
  const att = 'top-left';
297
269
  const { enabled, position } = parseControlOption(att);
298
- assert.strictEqual(true, enabled);
299
- assert.strictEqual('top-left', position);
270
+ expect(true).toBe(enabled);
271
+ expect('top-left').toBe(position);
300
272
  });
301
273
 
302
274
  it('should handle control position on.', () => {
303
275
  const att = 'on';
304
276
  const { enabled, position } = parseControlOption(att);
305
- assert.strictEqual(true, enabled);
306
- assert.strictEqual(void 0, position);
277
+ expect(true).toBe(enabled);
278
+ expect(void 0).toBe(position);
307
279
  });
308
280
 
309
281
  it('should handle control position off.', () => {
310
282
  const att = 'off';
311
283
  const { enabled, position } = parseControlOption(att);
312
- assert.strictEqual(false, enabled);
313
- assert.strictEqual(void 0, position);
284
+ expect(false).toBe(enabled);
285
+ expect(void 0).toBe(position);
314
286
  });
315
287
 
316
288
  it('should parse simple vector value with http.', () => {
317
289
  const attributeValue = 'https://example.com/path/to/tile.json';
318
- assert.strictEqual(attributeValue, parseSimpleVector(attributeValue));
290
+ expect(attributeValue).toBe(parseSimpleVector(attributeValue));
319
291
  });
320
292
 
321
293
  it('should parse simple vector value with geolonia schema.', () => {
322
294
  const attributeValue = 'geolonia://tiles/username/ct_123';
323
- assert.strictEqual(attributeValue, parseSimpleVector(attributeValue));
295
+ expect(attributeValue).toBe(parseSimpleVector(attributeValue));
324
296
  });
325
297
 
326
298
  it('should parse simple vector value with custom tile ID', () => {
327
299
  const attributeValue = 'ct_123';
328
- assert.strictEqual(
329
- 'geolonia://tiles/custom/ct_123',
330
- parseSimpleVector(attributeValue),
300
+ expect('geolonia://tiles/custom/ct_123').toBe(parseSimpleVector(attributeValue),
331
301
  );
332
302
  });
333
303
 
@@ -335,9 +305,7 @@ describe('Tests for util.js', () => {
335
305
  it('should sanitize description', async () => {
336
306
  const description =
337
307
  '<script>alert("hello");</script>ここが集合場所です。13時までに集合してください。';
338
- assert.strictEqual(
339
- 'ここが集合場所です。13時までに集合してください。',
340
- await sanitizeDescription(description),
308
+ expect('ここが集合場所です。13時までに集合してください。').toBe(await sanitizeDescription(description),
341
309
  );
342
310
  });
343
311
 
@@ -345,26 +313,21 @@ describe('Tests for util.js', () => {
345
313
  // Ref. https://www.npmjs.com/package/sanitize-html
346
314
  const description =
347
315
  '<img decoding="auto" src="hibiya-park.jpeg" /><br />ここが集合場所です。13時までに集合してください。';
348
- assert.strictEqual(
349
- '<img src="hibiya-park.jpeg" /><br />ここが集合場所です。13時までに集合してください。',
350
- await sanitizeDescription(description),
316
+ expect('<img src="hibiya-park.jpeg" /><br />ここが集合場所です。13時までに集合してください。').toBe(await sanitizeDescription(description),
351
317
  );
352
318
  });
353
319
 
354
320
  it('should not sanitize "class" attribute', async () => {
355
321
  const description =
356
322
  '<span class="red">ここが集合場所です。13時までに集合してください。</span>';
357
- assert.strictEqual(
358
- '<span class="red">ここが集合場所です。13時までに集合してください。</span>',
359
- await sanitizeDescription(description),
323
+ expect('<span class="red">ここが集合場所です。13時までに集合してください。</span>').toBe(await sanitizeDescription(description),
360
324
  );
361
325
  });
362
326
  });
363
327
  });
364
328
 
365
329
  describe('loadImageCompatibility', () => {
366
- it('should call the callback with response data when the promise resolves', (done) => {
367
- // モックされた成功した promise
330
+ it('should call the callback with response data when the promise resolves', async () => {
368
331
  const mockResponse = {
369
332
  data: new Image(),
370
333
  cacheControl: 'public, max-age=3600',
@@ -372,27 +335,30 @@ describe('loadImageCompatibility', () => {
372
335
  };
373
336
  const promise = Promise.resolve(mockResponse);
374
337
 
375
- loadImageCompatibility(promise, (error, data, expiry) => {
376
- assert.equal(error, null);
377
- assert.deepEqual(data, mockResponse.data);
378
- assert.deepEqual(expiry, {
379
- cacheControl: mockResponse.cacheControl,
380
- expires: mockResponse.expires,
338
+ await new Promise<void>((resolve) => {
339
+ loadImageCompatibility(promise, (error, data, expiry) => {
340
+ expect(error).toEqual(null);
341
+ expect(data).toEqual(mockResponse.data);
342
+ expect(expiry).toEqual({
343
+ cacheControl: mockResponse.cacheControl,
344
+ expires: mockResponse.expires,
345
+ });
346
+ resolve();
381
347
  });
382
- done();
383
348
  });
384
349
  });
385
350
 
386
- it('should call the callback with error when the promise rejects', (done) => {
387
- // モックされた失敗した promise
351
+ it('should call the callback with error when the promise rejects', async () => {
388
352
  const mockError = new Error('Failed to load image');
389
353
  const promise = Promise.reject(mockError);
390
354
 
391
- loadImageCompatibility(promise, (error, data, expiry) => {
392
- assert.deepEqual(error, mockError);
393
- assert.strictEqual(data, undefined);
394
- assert.strictEqual(expiry, undefined);
395
- done();
355
+ await new Promise<void>((resolve) => {
356
+ loadImageCompatibility(promise, (error, data, expiry) => {
357
+ expect(error).toEqual(mockError);
358
+ expect(data).toBe(undefined);
359
+ expect(expiry).toBe(undefined);
360
+ resolve();
361
+ });
396
362
  });
397
363
  });
398
364
  });
@@ -1,5 +1,6 @@
1
+ import { describe, it, expect, vi } from 'vitest';
1
2
  import { JSDOM } from 'jsdom';
2
- import assert from 'assert';
3
+
3
4
  import maplibregl from 'maplibre-gl';
4
5
 
5
6
  /**
@@ -10,11 +11,14 @@ import maplibregl from 'maplibre-gl';
10
11
 
11
12
  describe('maplibre-gl jsdom limitation', () => {
12
13
  it('jsdom上ではMaplibre Mapインスタンス生成時にエラー(WebGL未対応のため)', () => {
14
+ // jsdom の "Not implemented" メッセージを抑制
15
+ const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
16
+
13
17
  const dom = new JSDOM(
14
18
  '<!DOCTYPE html><html><body><div id="map"></div></body></html>',
15
19
  {
16
20
  url: 'http://localhost',
17
- pretendToBeVisual: true, // jsdomを視覚的な環境として
21
+ pretendToBeVisual: true,
18
22
  },
19
23
  );
20
24
  // @ts-ignore
@@ -31,16 +35,15 @@ describe('maplibre-gl jsdom limitation', () => {
31
35
  } catch (err) {
32
36
  errorCaught = err;
33
37
  }
34
- assert(errorCaught instanceof Error);
35
- // 期待される理由: WebGLが利用できない旨のエラーメッセージ
36
- assert(
37
- /webgl|WebGL|context|device/i.test(errorCaught.message),
38
- `Error message should mention WebGL or context, but got: ${errorCaught.message}`,
39
- );
38
+ expect(errorCaught).toBeInstanceOf(Error);
39
+ expect(
40
+ /webgl|WebGL|context|device|Not implemented/i.test(errorCaught.message),
41
+ ).toBe(true);
42
+
43
+ consoleSpy.mockRestore();
40
44
  });
41
45
 
42
46
  it('【NOTE】描画テストが必要な場合はE2E(ブラウザ実行)で行うこと', () => {
43
- // このテストは常に成功。ドキュメント用途。
44
- assert.strictEqual(true, true);
47
+ expect(true).toBe(true);
45
48
  });
46
49
  });
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": [
4
+ "src/**/*.test.ts",
5
+ "e2e",
6
+ "playwright.config.ts",
7
+ "vitest.config.ts"
8
+ ]
9
+ }
package/tsconfig.json CHANGED
@@ -26,5 +26,6 @@
26
26
  "src",
27
27
  "e2e",
28
28
  "playwright.config.ts",
29
+ "vitest.config.ts",
29
30
  ]
30
31
  }
@@ -0,0 +1,8 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: ['src/**/*.test.ts'],
6
+ environment: 'jsdom',
7
+ },
8
+ });
package/webpack.config.js CHANGED
@@ -23,7 +23,12 @@ const sharedConfig = {
23
23
  },
24
24
  {
25
25
  test: /\.tsx?$/,
26
- use: 'ts-loader',
26
+ use: {
27
+ loader: 'ts-loader',
28
+ options: {
29
+ configFile: 'tsconfig.build.json',
30
+ },
31
+ },
27
32
  exclude: /node_modules/,
28
33
  },
29
34
  {
package/.mocharc.js DELETED
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- extension: [ "ts", "tsx", "js", "jsx" ],
3
- spec: "src/**/*.test.ts",
4
- recursive: true,
5
- require: [
6
- "jsdom-global/register",
7
- "ts-node/register",
8
- ],
9
- };
@@ -1,8 +0,0 @@
1
- import { Geolonia } from '../src/embed';
2
- declare global {
3
- interface Window {
4
- geolonia: Geolonia;
5
- maplibregl?: Geolonia;
6
- mapboxgl?: Geolonia;
7
- }
8
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import { Page } from '@playwright/test';
2
- export declare const TEST_URL = "http://localhost:3000/e2e";
3
- export declare const LOAD_TIMEOUT = 5000;
4
- export declare function waitForMapLoad(page: Page, selector?: string): Promise<void>;
@@ -1 +0,0 @@
1
- export {};