Files
MineGeo/tests/map-refresh.test.ts

28 lines
969 B
TypeScript

import { test } from "node:test";
import assert from "node:assert/strict";
import { refreshCapture } from "../shared/map-refresh";
const original = {
id: "original",
name: "My Minecraft map",
created_at: "2026-10-07T09:51:39Z",
};
const contribution = {
id: "accepted",
name: "My Minecraft map",
created_at: "2026-10-07T10:28:01Z",
};
test("refresh chooses the newest eligible capture, including newly accepted contributions with the same name", () => {
assert.equal(refreshCapture([original]), "original");
assert.equal(refreshCapture([original, contribution]), "accepted");
assert.equal(refreshCapture([contribution, original]), "accepted");
});
test("a deliberately selected older capture stays selected when the list reloads", () => {
assert.equal(
refreshCapture([contribution, original], "original"),
"original",
);
assert.equal(refreshCapture([contribution], "original"), "accepted");
assert.equal(refreshCapture([]), "");
});