Files
gods-eye-view/src/mapStackController.test.mjs
T
German Khokhlov 72fec292d4 feat(maps): map sources for the Navara engine
createDefaultMapSources takes the engine kind. On Navara, Google 3D is
available from the browser key alone (Navara builds the tiles itself and
has no ion route to them), so it is the default and the recovery stack
when a key is set; without one the default is Esri imagery. Bing (Cesium
ion imagery) has no Navara path and is unavailable with a reason. World
terrain still needs an ion token and falls back to the keyless terrain.
MapStackController passes the kind of the engine it is given; Cesium
sources are unchanged.
2026-10-15 20:55:59 +04:00

50 lines
2.0 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { MapStackController } from './mapStackController.js';
import { createFakeEngine } from './globe/testing/fakeEngine.js';
test('the map stack controller applies its stacks through a given globe engine', async () => {
const engine = createFakeEngine();
const tileset = { show: true };
const controller = new MapStackController(null, {
engine,
googleTileset: tileset,
});
await controller.setStack('photoreal');
assert.equal(
engine.fake.callsOf('maps.setPhotorealTiles')[0].args[0].tileset,
tileset,
);
await controller.setStack('osm');
const [imagery] = engine.fake.callsOf('maps.setBaseImagery')[0].args;
assert.equal(imagery.descriptor.id, 'osm');
assert.ok(imagery.provider, 'a ready provider the controller built');
assert.equal(engine.fake.callsOf('maps.setPhotorealTiles')[1].args[0], null);
controller.destroy();
});
test('on a Navara engine the map stack controller opens on Google 3D from the browser key alone', async (t) => {
const previous = globalThis.window;
globalThis.window = { __GOOGLE_MAPS_API_KEY__: 'google-test' };
t.after(() => {
if (previous === undefined) delete globalThis.window;
else globalThis.window = previous;
});
const engine = createFakeEngine({ kind: 'navara' });
const controller = new MapStackController(null, { engine });
assert.equal(controller.getActiveId(), 'photoreal');
assert.equal(controller.isStackAvailable('bing-aerial'), false);
await controller.setStack('photoreal');
const [photoreal] = engine.fake.callsOf('maps.setPhotorealTiles')[0].args;
assert.equal(photoreal.kind, 'photoreal');
assert.equal('tileset' in photoreal, false);
controller.destroy();
window.__GOOGLE_MAPS_API_KEY__ = '';
const keyless = new MapStackController(null, {
engine: createFakeEngine({ kind: 'navara' }),
});
assert.equal(keyless.getActiveId(), 'esri-imagery');
assert.equal(keyless.isStackAvailable('photoreal'), false);
keyless.destroy();
});