mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Deep freeze name/tokens/lines/frontMatterLines properties of params object before passing to (custom) rules for shared access.
This commit is contained in:
parent
5253669495
commit
5f0040679d
4 changed files with 98 additions and 16 deletions
|
@ -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.");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue