3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-08 08:05:03 +00:00
zeppelin/backend/src/utils/validateNoObjectAliases.test.ts
Dragory 45e3fe2ef0
chore: esm imports
This will make merging this into 'next' much easier.
2024-08-11 21:58:52 +03:00

43 lines
1 KiB
TypeScript

import test from "ava";
import { ObjectAliasError, validateNoObjectAliases } from "./validateNoObjectAliases.js";
test("validateNoObjectAliases() disallows object aliases at top level", (t) => {
const obj: any = {
objectRef: {
foo: "bar",
},
};
obj.otherProp = obj.objectRef;
t.throws(() => validateNoObjectAliases(obj), { instanceOf: ObjectAliasError });
});
test("validateNoObjectAliases() disallows aliases to nested objects", (t) => {
const obj: any = {
nested: {
objectRef: {
foo: "bar",
},
},
};
obj.otherProp = obj.nested.objectRef;
t.throws(() => validateNoObjectAliases(obj), { instanceOf: ObjectAliasError });
});
test("validateNoObjectAliases() disallows nested object aliases", (t) => {
const obj: any = {
nested: {
objectRef: {
foo: "bar",
},
},
};
obj.otherProp = {
alsoNested: {
ref: obj.nested.objectRef,
},
};
t.throws(() => validateNoObjectAliases(obj), { instanceOf: ObjectAliasError });
});