mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 09:12:18 +00:00
A weather source can name its provider for each product
The Rain radar, Lightning density and Satellite clouds rows named NOAA nowCOAST until a manifest named its own source, whatever the source read. A weather source may now supply sourceName(kind), kind being radar, lightning or satellite; the row shows that name until a manifest names one. The name is read once when the layer is built and held to the same rule as a manifest's display.source. A source without names, or one whose name is refused or fails, still shows NOAA nowCOAST.
This commit is contained in:
1 parent
c2e42b5dfd
commit
7f1c35c5ed
4 files changed
+73
-5
No files matched your search
@@ -2694,3 +2694,40 @@ test('the layer hands rendering a frame source only when its feed is one', () =>
|
||||
assert.equal(typeof seen[1].getTile, 'function');
|
||||
assert.equal(seen[1].getImage, undefined);
|
||||
});
|
||||
|
||||
test('a feed names the source behind each product, before any manifest does', (t) => {
|
||||
t.mock.method(console, 'warn', () => {});
|
||||
const quiet = {
|
||||
documentRef: target({ hidden: false }),
|
||||
eventTarget: target(),
|
||||
matchMedia: () => target({ matches: false }),
|
||||
};
|
||||
const asked = [];
|
||||
const feed = {
|
||||
getSnapshot: async () => snapshot,
|
||||
sourceName(kind) {
|
||||
asked.push(kind);
|
||||
if (kind === 'satellite') throw new Error('no name');
|
||||
return kind === 'radar' ? ' NOAA MRMS ' : 'NOAA\u200b GLM';
|
||||
},
|
||||
};
|
||||
const radar = createWeatherLayer({ ...quiet, feed, id: 'weather-radar' });
|
||||
assert.equal(radar.source, 'NOAA MRMS');
|
||||
const stats = radar.getStats();
|
||||
assert.equal(stats.source, 'NOAA MRMS');
|
||||
assert.equal(stats.sourceVerbatim, true);
|
||||
// A name a manifest could not carry, or a failing call, leaves nowCOAST, as
|
||||
// does a feed with no names.
|
||||
for (const id of ['weather-lightning', 'weather-satellite']) {
|
||||
const layer = createWeatherLayer({ ...quiet, feed, id });
|
||||
assert.equal(layer.source, 'NOAA nowCOAST · OBSERVED', id);
|
||||
assert.equal(layer.getStats().source, 'NOAA nowCOAST', id);
|
||||
assert.equal(layer.getStats().sourceVerbatim, undefined, id);
|
||||
}
|
||||
assert.deepEqual(asked, ['radar', 'lightning', 'satellite']);
|
||||
const unnamed = createWeatherLayer({
|
||||
...quiet,
|
||||
feed: { getSnapshot: async () => snapshot },
|
||||
});
|
||||
assert.equal(unnamed.source, 'NOAA nowCOAST · OBSERVED');
|
||||
});
|
||||
Reference in new issue
Block a user