"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.clientGetSegmentExtentsOfPositionTest = exports.clientGetPropertiesAtPositionTest = void 0;
/* eslint-disable guard-for-in, no-restricted-syntax */
const node_assert_1 = require("node:assert");
const properties_js_1 = require("../properties.js");
const testClient_js_1 = require("./testClient.js");
function checkGetPropertiesAtPos(client, pos, props, verbose = false) {
    const propsRetrieved = client.getPropertiesAtPosition(pos);
    const result = (0, properties_js_1.matchProperties)(props, propsRetrieved);
    if (!result && verbose) {
        console.log(`At pos: ${pos}`);
        console.log("Expected props");
        for (const key in props) {
            console.log(`Key: ${key} Value: ${props[key]}`);
        }
        console.log("Actual props");
        for (const key1 in propsRetrieved) {
            console.log(`Key: ${key1} Value: ${propsRetrieved[key1]}`);
        }
    }
    return result;
}
function clientGetPropertiesAtPositionTest() {
    const client = new testClient_js_1.TestClient();
    client.insertTextLocal(0, "the cat is on the mat");
    const props = { prop1: 10 };
    client.insertTextLocal(4, "fuzzy, fuzzy ", props);
    const testResult1 = checkGetPropertiesAtPos(client, 4, props, true);
    const testResult2 = checkGetPropertiesAtPos(client, 16, props, true);
    const testResult3 = checkGetPropertiesAtPos(client, 3);
    const testResult4 = checkGetPropertiesAtPos(client, 17);
    return (((testResult1 === testResult2) === testResult3) === testResult4) === true;
}
exports.clientGetPropertiesAtPositionTest = clientGetPropertiesAtPositionTest;
function checkGetSegmentExtentsOfPos(client, pos, posStart, posAfterEnd, verbose = false) {
    const segExtents = client.getRangeExtentsOfPosition(pos);
    const result = segExtents.posStart === posStart && segExtents.posAfterEnd === posAfterEnd;
    if (!result && verbose) {
        console.log(`At pos: ${pos}`);
        console.log(`Expected extents -> start: ${posStart} end: ${posAfterEnd}`);
        console.log(`Actual extents -> start: ${segExtents.posStart} end: ${segExtents.posAfterEnd}`);
    }
    return result;
}
function clientGetSegmentExtentsOfPositionTest() {
    const client = new testClient_js_1.TestClient();
    client.insertTextLocal(0, "the cat is on the mat");
    const props = { prop1: 10 };
    client.insertTextLocal(4, "fuzzy, fuzzy ", props);
    client.insertTextLocal(8, "more fuzzy text", {});
    const testResult1 = checkGetSegmentExtentsOfPos(client, 26, 23, 32);
    const testResult2 = checkGetSegmentExtentsOfPos(client, 6, 4, 8);
    const testResult3 = checkGetSegmentExtentsOfPos(client, 32, 32, 49);
    return ((testResult1 === testResult2) === testResult3) === true;
}
exports.clientGetSegmentExtentsOfPositionTest = clientGetSegmentExtentsOfPositionTest;
describe("client.apis", () => {
    it("clientGetPropertiesAtPositionTest", () => {
        (0, node_assert_1.strict)(clientGetPropertiesAtPositionTest() === true);
    });
    it("clientGetSegmentExtentsOfPositionTest", () => {
        (0, node_assert_1.strict)(clientGetSegmentExtentsOfPositionTest() === true);
    });
});
//# sourceMappingURL=client.apis.spec.js.map