Deep freeze name/tokens/lines/frontMatterLines properties of params object before passing to (custom) rules for shared access.

This commit is contained in:
David Anson 2021-12-23 04:34:25 +00:00 committed by GitHub
parent 5253669495
commit 5f0040679d
4 changed files with 98 additions and 16 deletions

View file

@ -938,3 +938,37 @@ test("applyFixes", (t) => {
t.is(actual, expected, "Incorrect fix applied.");
});
});
test("deepFreeze", (t) => {
t.plan(6);
const obj = {
"prop": true,
"func": () => true,
"sub": {
"prop": [ 1 ],
"sub": {
"prop": "one"
}
}
};
t.is(helpers.deepFreeze(obj), obj, "Did not return object.");
[
() => {
obj.prop = false;
},
() => {
obj.func = () => false;
},
() => {
obj.sub.prop = [];
},
() => {
obj.sub.prop[0] = 0;
},
() => {
obj.sub.sub.prop = "zero";
}
].forEach((scenario) => {
t.throws(scenario, null, "Assigned to frozen object.");
});
});