mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 16:23:12 +09:00
Fixed test causing missed coverage
This commit is contained in:
1 file changed
+9
-4
@@ -46,11 +46,15 @@ describe("lib/config/classes", function() {
|
|||||||
"test.dependent": {
|
"test.dependent": {
|
||||||
type: "number",
|
type: "number",
|
||||||
initialValue: 1,
|
initialValue: 1,
|
||||||
dependsOn: ["test.base"],
|
dependsOn: ["test.base", "test.objDependent"],
|
||||||
validator(value, config) {
|
validator(value, config) {
|
||||||
if (value < config.get("test.base")) {
|
if (value < config.get("test.base")) {
|
||||||
throw new Error("dependent must be >= base");
|
throw new Error("dependent must be >= base");
|
||||||
}
|
}
|
||||||
|
const dep = config.get("test.objDependent")?.base;
|
||||||
|
if (dep === 0) {
|
||||||
|
throw new Error("objDependent cannot be 0");
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"test.objDependent": {
|
"test.objDependent": {
|
||||||
@@ -58,7 +62,7 @@ describe("lib/config/classes", function() {
|
|||||||
initialValue: {},
|
initialValue: {},
|
||||||
dependsOn: ["test.base"],
|
dependsOn: ["test.base"],
|
||||||
validator(value, config) {
|
validator(value, config) {
|
||||||
if (value.base !== undefined && value.base !== config.get("test.base")) {
|
if (value.base && value.base !== config.get("test.base")) {
|
||||||
throw new Error("base prop must match test.base");
|
throw new Error("base prop must match test.base");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -867,9 +871,10 @@ describe("lib/config/classes", function() {
|
|||||||
assert.deepEqual(testInstance.get("test.objDependent"), { base: 1 });
|
assert.deepEqual(testInstance.get("test.objDependent"), { base: 1 });
|
||||||
});
|
});
|
||||||
it("should throw if dependent validation fails", function() {
|
it("should throw if dependent validation fails", function() {
|
||||||
|
testInstance.set("test.base", 0);
|
||||||
assert.throws(
|
assert.throws(
|
||||||
() => testInstance.setProp("test.objDependent", "base", 5),
|
() => testInstance.setProp("test.objDependent", "base", 0),
|
||||||
new lib.InvalidValue("Failed validation of test.objDependent: base prop must match test.base")
|
new lib.InvalidValue("Failed validation of dependent test.dependent: objDependent cannot be 0")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user