mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
refactor(space): separate satellite and mission layer components
This commit is contained in:
1 parent
61db945b21
commit
ce0568983a
44 files changed
+8767
-6095
No files matched your search
@@ -0,0 +1,58 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createSatelliteSource } from './source.js';
|
||||
import { createSatellitesLayer } from './index.js';
|
||||
|
||||
test('satellite sources confine catalog groups and reject a cancelled body', async () => {
|
||||
const controller = new AbortController();
|
||||
let requests = 0;
|
||||
const source = createSatelliteSource({
|
||||
fetchImpl: async (url) => {
|
||||
requests++;
|
||||
assert.equal(url, '/api/celestrak/stations');
|
||||
return {
|
||||
ok: true,
|
||||
status: 200,
|
||||
text: async () => {
|
||||
controller.abort();
|
||||
return 'late catalog';
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
await assert.rejects(
|
||||
source.readGroup('../active'),
|
||||
/Unknown satellite group/,
|
||||
);
|
||||
assert.equal(requests, 0);
|
||||
await assert.rejects(
|
||||
source.readGroup('stations', { signal: controller.signal }),
|
||||
{ name: 'AbortError' },
|
||||
);
|
||||
});
|
||||
|
||||
test('satellite factories keep control state separate and construct without requests', () => {
|
||||
const source = {
|
||||
readGroup() {
|
||||
assert.fail('construction fetched a catalog');
|
||||
},
|
||||
};
|
||||
const services = Object.fromEntries(
|
||||
[
|
||||
'picking',
|
||||
'focus',
|
||||
'readout',
|
||||
'overlays',
|
||||
'context',
|
||||
'render',
|
||||
'layerState',
|
||||
].map((key) => [key, {}]),
|
||||
);
|
||||
services.layerState.isExplicitLayerStateOrigin = () => false;
|
||||
const first = createSatellitesLayer({ source, services });
|
||||
const second = createSatellitesLayer({ source, services });
|
||||
first.setParams({ showPoints: false });
|
||||
assert.equal(first.getParams().showPoints, false);
|
||||
assert.equal(second.getParams().showPoints, true);
|
||||
assert.notEqual(first.getStats(), second.getStats());
|
||||
});
|
||||
Reference in new issue
Block a user