"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
const assert_1 = require("assert");
const testClient_1 = require("./testClient.cjs");
describe("client.applyMsg", () => {
    const localUserLongId = "localUser";
    const seg1 = "hello";
    const seg2 = "world";
    let client;
    beforeEach(() => {
        client = new testClient_1.TestClient();
        client.insertTextLocal(client.getLength(), seg1);
        client.insertTextLocal(client.getLength(), seg2);
        client.startOrUpdateCollaboration(localUserLongId);
    });
    it("Walk All Segments", () => {
        let segCount = 0;
        let segLen = 0;
        client.walkSegments((s) => {
            segCount++;
            segLen += s.cachedLength;
            return true;
        });
        assert_1.strict.equal(segCount, 2);
        assert_1.strict.equal(segLen, seg1.length + seg2.length);
    });
    it("Walk Segment Range", () => {
        let segCount = 0;
        let segLen = 0;
        client.walkSegments((s) => {
            segCount++;
            segLen += s.cachedLength;
            return true;
        }, seg1.length - 2, seg1.length + 2);
        assert_1.strict.equal(segCount, 2);
        assert_1.strict.equal(segLen, seg1.length + seg2.length);
    });
    it("Walk Segment Range With Split", () => {
        let segCount = 0;
        let segLen = 0;
        client.walkSegments((s) => {
            segCount++;
            segLen += s.cachedLength;
            return true;
        }, seg1.length - 2, seg1.length + 2, undefined, true);
        assert_1.strict.equal(segCount, 2);
        assert_1.strict.equal(segLen, 4);
    });
});
//# sourceMappingURL=client.walkSegments.spec.cjs.map