style: format terrain traffic fire and bike-share modules

This commit is contained in:
Sameh Khamis committed 2026-09-11 21:57:51 -07:00
1 parent f4054469d5
commit a2d6461b52
13 files changed
+638 -213

No files matched your search

+48 -18
View File
@@ -18,7 +18,13 @@ test('per-point cache reconstruction preserves exact request order with mixed hi
[terrainPointKey([10, 1]), { at: now, result: result('cached-a', 101) }],
[terrainPointKey([30, 3]), { at: now, result: result('cached-c', 303) }],
]);
const points = [[30, 3], [20, 2], [10, 1], [40, 4], [20, 2]];
const points = [
[30, 3],
[20, 2],
[10, 1],
[40, 4],
[20, 2],
];
let fetchedPoints = null;
const response = await resolveTerrainHeightRequest({
@@ -33,11 +39,18 @@ test('per-point cache reconstruction preserves exact request order with mixed hi
});
assert.equal(response.status, 200);
assert.deepEqual(fetchedPoints, [[20, 2], [40, 4]], 'only unique cache misses go upstream');
assert.deepEqual(
fetchedPoints,
[
[20, 2],
[40, 4],
],
'only unique cache misses go upstream',
);
assert.deepEqual(
response.body.results.map((item) => item.id),
['cached-c', 'fresh-b', 'cached-a', 'fresh-d', 'fresh-b'],
'each output position must map back to its own input point'
'each output position must map back to its own input point',
);
});
@@ -59,7 +72,9 @@ test('429 retry honors Retry-After before the next attempt', async () => {
return {
ok: false,
status: 429,
headers: { get: (name) => name.toLowerCase() === 'retry-after' ? '3' : null },
headers: {
get: (name) => (name.toLowerCase() === 'retry-after' ? '3' : null),
},
};
}
return {
@@ -83,21 +98,28 @@ test('permanently failing upstream exhausts retries and returns 502 without fake
cache: new Map(),
ttlMs: 10_000,
now: () => clock,
fetchMissing: (missing) => fetchTerrainChunkWithRetry(missing, {
now: () => clock,
random: () => 0.5,
makeSignal: () => undefined,
sleep: async (ms) => { clock += ms; },
fetchImpl: async () => {
attempts += 1;
return { ok: false, status: 503, headers: { get: () => null } };
},
}),
fetchMissing: (missing) =>
fetchTerrainChunkWithRetry(missing, {
now: () => clock,
random: () => 0.5,
makeSignal: () => undefined,
sleep: async (ms) => {
clock += ms;
},
fetchImpl: async () => {
attempts += 1;
return { ok: false, status: 503, headers: { get: () => null } };
},
}),
});
assert.equal(attempts, 4, 'one initial attempt plus three retries');
assert.equal(response.status, 502);
assert.equal('results' in response.body, false, 'failure body must not fabricate positional heights');
assert.equal(
'results' in response.body,
false,
'failure body must not fabricate positional heights',
);
});
test('stale per-point entries serve through a failed refresh only when every point is real', async () => {
@@ -106,12 +128,20 @@ test('stale per-point entries serve through a failed refresh only when every poi
[terrainPointKey([2, 2]), { at: 0, result: result('stale-b', 22) }],
]);
const response = await resolveTerrainHeightRequest({
points: [[2, 2], [1, 1]],
points: [
[2, 2],
[1, 1],
],
cache,
ttlMs: 100,
now: () => 1000,
fetchMissing: async () => { throw new Error('offline'); },
fetchMissing: async () => {
throw new Error('offline');
},
});
assert.equal(response.status, 200);
assert.deepEqual(response.body.results.map((item) => item.id), ['stale-b', 'stale-a']);
assert.deepEqual(
response.body.results.map((item) => item.id),
['stale-b', 'stale-a'],
);
});