mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-11 05:42:22 +00:00
test(shipwrecks): the page deadline subtracts the newest available source's reported age from the limit
This commit is contained in:
1 parent
41641cd91a
commit
f9b7a77140
1 file changed
+34
-1
@@ -2,7 +2,11 @@ import test from 'node:test';
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import * as Cesium from 'cesium';
|
import * as Cesium from 'cesium';
|
||||||
import * as picking from '../../data/pickRegistry.js';
|
import * as picking from '../../data/pickRegistry.js';
|
||||||
import { createShipwrecksLayer, markerPixelSize } from './index.js';
|
import {
|
||||||
|
createShipwrecksLayer,
|
||||||
|
markerPixelSize,
|
||||||
|
snapshotDeadline,
|
||||||
|
} from './index.js';
|
||||||
|
|
||||||
const wreck = (id, extra = {}) => ({
|
const wreck = (id, extra = {}) => ({
|
||||||
id,
|
id,
|
||||||
@@ -348,3 +352,32 @@ test('a snapshot with no timestamp or ages still expires seven days after it arr
|
|||||||
await h.layer.update();
|
await h.layer.update();
|
||||||
assert.equal(h.layer.getStats().count, 0);
|
assert.equal(h.layer.getStats().count, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('the page deadline subtracts the newest available source age from the limit', () => {
|
||||||
|
const DAY = 24 * 60 * 60 * 1000;
|
||||||
|
const both = { emodnet: true, wikidata: true };
|
||||||
|
assert.equal(
|
||||||
|
snapshotDeadline(
|
||||||
|
{
|
||||||
|
sources: both,
|
||||||
|
ages: { emodnet: 2 * DAY, wikidata: 6.5 * DAY },
|
||||||
|
maxAgeMs: 5 * DAY,
|
||||||
|
},
|
||||||
|
100,
|
||||||
|
),
|
||||||
|
100 + 3 * DAY,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
snapshotDeadline(
|
||||||
|
{
|
||||||
|
sources: { emodnet: false, wikidata: true },
|
||||||
|
ages: { emodnet: null, wikidata: 4 * DAY },
|
||||||
|
maxAgeMs: 5 * DAY,
|
||||||
|
},
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
1 * DAY,
|
||||||
|
'an unavailable source does not count',
|
||||||
|
);
|
||||||
|
assert.equal(snapshotDeadline({ sources: both }, 0), 7 * DAY, 'defaults');
|
||||||
|
});
|
||||||
Reference in new issue
Block a user