@player-ui/player
Version:
54 lines (46 loc) • 1.51 kB
text/typescript
import { describe, it, expect } from "vitest";
import { BindingParser } from "../../binding";
import { removeBindingAndChildrenFromMap } from "../binding-map-splice";
const parser = new BindingParser({
get: () => undefined,
set: () => undefined,
evaluate: () => undefined,
});
describe("removeBindingAndChildrenFromMap", () => {
it("removes a binding and its chidlren", () => {
const sourceMap = new Map([
[],
[],
[],
]);
const result = removeBindingAndChildrenFromMap(
sourceMap,
parser.parse("foo.bar"),
);
expect(result).toStrictEqual(new Map([[parser.parse("foo.baz"), 3]]));
});
it("splices a binding and its children", () => {
const sourceMap = new Map([
[],
[],
[],
[],
[],
[],
[],
]);
const result = removeBindingAndChildrenFromMap(
sourceMap,
parser.parse("foo.bar.1"),
);
expect(result).toStrictEqual(
new Map([
[],
[],
[],
[],
[],
]),
);
});
});