mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 02:02:21 +00:00
Take the timeline commits back out before merging their reviewed versions from main
5150279cc,97bd61711,900c76425and4f23ad330went to main, reviewed and changed, as #1745. They are taken out here so main brings them in as merged, rather than as two copies of the same changes in conflict.
This commit is contained in:
1 parent
4f23ad330c
commit
961e6321a5
45 files changed
+1316
-1078
No files matched your search
@@ -2,8 +2,6 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createEarthquakesLayer } from './index.js';
|
||||
import { createUsgsEarthquakeSource } from './source.js';
|
||||
import { EARTHQUAKE_MARK_MAGNITUDE, earthquakeMarkLabel } from './model.js';
|
||||
import { worldClock } from '../../time/worldClock.js';
|
||||
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
|
||||
function harness(source) {
|
||||
const events = [];
|
||||
@@ -170,71 +168,3 @@ test('a viewer with nothing to draw with is refused at init, and init can be ret
|
||||
layer.destroy();
|
||||
unbind();
|
||||
});
|
||||
test('the timeline marks only strong quakes, while the layer is on', async () => {
|
||||
assert.equal(EARTHQUAKE_MARK_MAGNITUDE, 6);
|
||||
const rows = [
|
||||
{ ...row, stableId: 'small', mag: 4.5, time: 1_000 },
|
||||
{ ...row, stableId: 'strong', usgsId: 'us-strong', mag: 6, time: 5_000 },
|
||||
{
|
||||
...row,
|
||||
stableId: 'great',
|
||||
usgsId: 'us-great',
|
||||
mag: 7.2,
|
||||
place: ' 113 km SSE of Lata, Solomon Islands region of the Pacific ',
|
||||
time: 3_000,
|
||||
},
|
||||
{ ...row, stableId: 'untimed', mag: 6.5, time: null },
|
||||
];
|
||||
let snapshot = rows;
|
||||
const h = harness({ getSnapshot: async () => snapshot });
|
||||
assert.equal(worldClock.coverage(), null, 'nothing loaded, no time to show');
|
||||
let changes = 0;
|
||||
const unsubscribe = worldClock.subscribe(() => changes++);
|
||||
await h.layer.update(h.viewer);
|
||||
// Every quake is drawn; only M6 and up are marks, spanning their own time.
|
||||
assert.equal(h.draw.find('earthquakes:').items.size, 4);
|
||||
// Each labelled with its magnitude and, cut short, its place.
|
||||
assert.deepEqual(worldClock.coverage(), {
|
||||
start: 3_000,
|
||||
end: 5_000,
|
||||
marks: [3_000, 5_000],
|
||||
markDetails: [
|
||||
{
|
||||
time: 3_000,
|
||||
label: 'M7.2 · 113 km SSE of Lata, Solomon Islands reg…',
|
||||
id: 'us-great',
|
||||
kind: 'earthquake',
|
||||
},
|
||||
{
|
||||
time: 5_000,
|
||||
label: 'M6.0 · Fixture',
|
||||
id: 'us-strong',
|
||||
kind: 'earthquake',
|
||||
},
|
||||
],
|
||||
});
|
||||
const told = changes;
|
||||
await h.layer.update(h.viewer);
|
||||
assert.equal(changes, told, 'the same strong quakes are not told again');
|
||||
snapshot = rows.slice(0, 1);
|
||||
await h.layer.update(h.viewer);
|
||||
assert.equal(worldClock.coverage(), null, 'small shakes alone cover no time');
|
||||
snapshot = rows;
|
||||
await h.layer.update(h.viewer);
|
||||
h.layer.disable(h.viewer);
|
||||
assert.equal(worldClock.coverage(), null, 'off, no time to show');
|
||||
h.layer.enable(h.viewer);
|
||||
assert.deepEqual(worldClock.coverage().marks, [3_000, 5_000]);
|
||||
h.layer.destroy();
|
||||
assert.equal(worldClock.coverage(), null);
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
test('a strong quake with no place is labelled with its magnitude alone', () => {
|
||||
assert.equal(earthquakeMarkLabel({ mag: 6.44, place: null }), 'M6.4');
|
||||
assert.equal(earthquakeMarkLabel({ mag: 6, place: ' ' }), 'M6.0');
|
||||
assert.equal(
|
||||
earthquakeMarkLabel({ mag: 8.1, place: 'Off the coast' }),
|
||||
'M8.1 · Off the coast',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user