mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 23:24:52 +09:00
Add notes to hosts, instances, users and other resources (#1000)
This commit is contained in:
1 parent
ee39945c83
commit
cbf2b10782
25 files changed
+830
-52
No files matched your search
@@ -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" });
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user