refactor(providers): move the tile budget helpers out of the TomTom module

utcDayKey, normalizeBudget and isOverBudget move unchanged to
src/data/tileBudget.js. Nothing in them was TomTom-specific; the next
keyed tile proxy (Xweather) counts a monthly allowance through the same
two functions. tomtomTiles.js re-exports them, so the traffic provider
and its tests keep their imports.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
monwissandClaude Opus 5.5 committed 2026-09-25 11:34:40 -04:00
1 parent b210ab0fe4
commit da689e03ac
5 files changed
+94 -40

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { isOverBudget, normalizeBudget, utcDayKey } from './tileBudget.js';
import * as tomtom from './tomtomTiles.js';
test('tile budget helpers live in one module and TomTom re-exports them', () => {
assert.equal(tomtom.utcDayKey, utcDayKey);
assert.equal(tomtom.normalizeBudget, normalizeBudget);
assert.equal(tomtom.isOverBudget, isOverBudget);
});
test('normalizeBudget keeps a valid state and resets another period', () => {
const state = { date: '2026-09-24', count: 3 };
assert.equal(normalizeBudget(state, '2026-09-24'), state);
assert.deepEqual(normalizeBudget(state, '2026-09-25'), {
date: '2026-09-25',
count: 0,
});
assert.deepEqual(
normalizeBudget({ date: '2026-09-24', count: -1 }, '2026-09-24'),
{
date: '2026-09-24',
count: 0,
},
);
});