refactor(geography): separate cable sources and bundled lookup modules

This commit is contained in:
Sameh Khamis committed 2026-09-13 18:36:33 -07:00
1 parent 2213c42200
commit 3ce5d2e454
21 files changed
+2423 -1437

No files matched your search

@@ -0,0 +1,34 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createBundledCableSource } from './bundledSource.js';
test('a failed bundled response releases its body', async () => {
let released = 0;
const source = createBundledCableSource({
fetchImpl: async () => ({
ok: false,
status: 503,
body: {
cancel: async () => {
released++;
},
},
}),
});
await assert.rejects(source.fetch(), /HTTP 503/);
assert.equal(released, 2);
});
test('cancellation during JSON parsing cannot return a late snapshot', async () => {
const controller = new AbortController();
const source = createBundledCableSource({
fetchImpl: async () => ({
ok: true,
async json() {
controller.abort();
return { type: 'FeatureCollection', features: [] };
},
}),
});
await assert.rejects(source.fetch(controller.signal), { name: 'AbortError' });
});