Add map import and export with durable refresh progress
This commit is contained in:
27
tests/map-refresh.test.ts
Normal file
27
tests/map-refresh.test.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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([]), "");
|
||||
});
|
||||
Reference in New Issue
Block a user