Skip to content

Commit 5ed43b1

Browse files
committed
test: maplibreMock をテストランナー非依存にする
jest.requireActual を使わず bounds を素のスタブで返す。Nuxt 4 移行で jest から vitest に替わるときにこのファイルを触らずに済ませるため。
1 parent 4aa114b commit 5ed43b1

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

test-unit/mocks/maplibreMock.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ export class MockMap {
4242
return this;
4343
}
4444

45+
// inBounds() は getNorthEast / getSouthWest、serializeBounds() は
46+
// getNorthWest / getSouthEast を使う。この4つを満たせば maplibre の実物は不要
47+
// (テストランナー非依存に保つため実物を持ち込まない)。
4548
getBounds() {
46-
const MapLibre = jest.requireActual('maplibre-gl');
47-
return new MapLibre.LngLatBounds(
48-
new MapLibre.LngLat(130.6, 32.5),
49-
new MapLibre.LngLat(130.8, 32.7)
50-
);
49+
return {
50+
getNorthEast: () => ({ lng: 130.8, lat: 32.7 }),
51+
getSouthWest: () => ({ lng: 130.6, lat: 32.5 }),
52+
getNorthWest: () => ({ lng: 130.6, lat: 32.7 }),
53+
getSouthEast: () => ({ lng: 130.8, lat: 32.5 }),
54+
};
5155
}
5256

5357
remove() {

0 commit comments

Comments
 (0)