/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { strict as assert } from "assert";
import { mapTreeFromCursor, cursorForMapTreeNode, mapRootChanges, } from "../../feature-libraries/index.js";
import { brand } from "../../util/index.js";
import { deepFreeze } from "../utils.js";
const type = brand("Node");
const emptyMap = new Map();
const nodeX = { type, value: "X", fields: emptyMap };
const nodeXCursor = cursorForMapTreeNode(nodeX);
const fooField = brand("foo");
const detachId = { minor: 43 };
describe("DeltaUtils", () => {
    describe("mapFieldMarks", () => {
        it("maps delta content", () => {
            const nestedCursorInsert = new Map([
                [
                    fooField,
                    {
                        local: [
                            { count: 42 },
                            {
                                count: 1,
                                attach: detachId,
                            },
                        ],
                    },
                ],
            ]);
            const input = {
                build: [{ id: detachId, trees: [nodeXCursor] }],
                fields: new Map([
                    [
                        fooField,
                        {
                            local: [
                                {
                                    count: 1,
                                    fields: nestedCursorInsert,
                                },
                            ],
                            global: [{ id: detachId, fields: nestedCursorInsert }],
                        },
                    ],
                ]),
            };
            deepFreeze(input);
            const actual = mapRootChanges(input, mapTreeFromCursor);
            const nestedMapTreeInsert = new Map([
                [
                    fooField,
                    {
                        local: [
                            { count: 42 },
                            {
                                count: 1,
                                attach: detachId,
                            },
                        ],
                    },
                ],
            ]);
            const expected = {
                build: [{ id: detachId, trees: [nodeX] }],
                fields: new Map([
                    [
                        fooField,
                        {
                            local: [
                                {
                                    count: 1,
                                    fields: nestedMapTreeInsert,
                                },
                            ],
                            global: [{ id: detachId, fields: nestedMapTreeInsert }],
                        },
                    ],
                ]),
            };
            deepFreeze(expected);
            assert.deepEqual(actual, expected);
        });
    });
});
//# sourceMappingURL=deltaUtils.spec.js.map