mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
refactor(geography): separate cable sources and bundled lookup modules
This commit is contained in:
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' });
|
||||
});
|
||||
Reference in new issue
Block a user