Add notes to hosts, instances, users and other resources (#1000)

This commit is contained in:
Bastiaan authored and GitHub committed 2026-10-18 20:06:15 +03:00
1 parent ee39945c83
commit cbf2b10782
25 files changed
+830 -52

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import assert from "node:assert/strict";
import * as lib from "@clusterio/lib";
import { testRoundTripJsonSerialisable } from "../../common.js";
describe("lib/data/Note", function() {
describe("class Note", function() {
it("should derive its id from the resource type and id", function() {
const note = new lib.Note("host", "12", "Runs on the basement box");
assert.equal(note.id, "host/12");
assert.equal(lib.Note.idFor("instance", 4), "instance/4");
});
it("should round trip serialize", function() {
testRoundTripJsonSerialisable(lib.Note, [
["host", "1", "text"],
["user", "player", "multi\nline", "admin"],
["mod", "mod_1.0.0", "text", "admin", 1234],
["save", "1/world.zip", "text", "", 1234, true],
]);
});
it("should omit default optional fields from json", function() {
const note = new lib.Note("role", "5", "text");
assert.deepEqual(note.toJSON(), { resourceType: "role", resourceId: "5", content: "text" });
});
});
});