"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = __importDefault(require("node:test"));
const strict_1 = __importDefault(require("node:assert/strict"));
const schema_cypher_parser_js_1 = require("../schema-cypher-parser.js");
(0, node_test_1.default)("parseLabelsFromSchemaCypher: extracts labels from constraint and index forms", () => {
    const text = `
CREATE CONSTRAINT person_email IF NOT EXISTS
FOR (p:Person) REQUIRE p.email IS UNIQUE;

CREATE CONSTRAINT business_account IF NOT EXISTS
FOR (b:LocalBusiness) REQUIRE b.accountId IS UNIQUE;

CREATE INDEX admin_user_account IF NOT EXISTS
FOR (au:AdminUser) ON (au.accountId);

CREATE INDEX knowledge_doc IF NOT EXISTS
FOR (k:KnowledgeDocument) ON (k.embedding) OPTIONS { ... };
`;
    const labels = (0, schema_cypher_parser_js_1.parseLabelsFromSchemaCypher)(text);
    strict_1.default.deepEqual(labels, [
        "AdminUser",
        "KnowledgeDocument",
        "LocalBusiness",
        "Person",
    ]);
});
(0, node_test_1.default)("parseLabelsFromSchemaCypher: deduplicates labels declared multiple times", () => {
    const text = `
FOR (p:Person) REQUIRE p.email IS UNIQUE;
FOR (p:Person) REQUIRE p.telephone IS UNIQUE;
FOR (p:Person) ON (p.status);
`;
    strict_1.default.deepEqual((0, schema_cypher_parser_js_1.parseLabelsFromSchemaCypher)(text), ["Person"]);
});
(0, node_test_1.default)("parseLabelsFromSchemaCypher: returns sorted output", () => {
    const text = `FOR (z:Zebra) ON (z.x); FOR (a:Aardvark) ON (a.x); FOR (m:Mongoose) ON (m.x);`;
    strict_1.default.deepEqual((0, schema_cypher_parser_js_1.parseLabelsFromSchemaCypher)(text), [
        "Aardvark",
        "Mongoose",
        "Zebra",
    ]);
});
(0, node_test_1.default)("parseLabelsFromSchemaCypher: ignores non-constraint cypher", () => {
    const text = `
MATCH (n:Person) RETURN n;
CREATE (b:Business { name: 'X' });
FOR (p:Person) REQUIRE p.email IS UNIQUE;
`;
    // MATCH/CREATE patterns don't include FOR, so they're ignored.
    strict_1.default.deepEqual((0, schema_cypher_parser_js_1.parseLabelsFromSchemaCypher)(text), ["Person"]);
});
(0, node_test_1.default)("parseLabelsFromSchemaCypher: empty input returns empty array", () => {
    strict_1.default.deepEqual((0, schema_cypher_parser_js_1.parseLabelsFromSchemaCypher)(""), []);
});
(0, node_test_1.default)("levenshtein: identical strings", () => {
    strict_1.default.equal((0, schema_cypher_parser_js_1.levenshtein)("Person", "Person"), 0);
});
(0, node_test_1.default)("levenshtein: substitution distance", () => {
    // LocaIBusiness vs LocalBusiness — capital-I-as-l typo from the incident.
    strict_1.default.equal((0, schema_cypher_parser_js_1.levenshtein)("LocaIBusiness", "LocalBusiness"), 1);
});
(0, node_test_1.default)("levenshtein: insertion + deletion", () => {
    strict_1.default.equal((0, schema_cypher_parser_js_1.levenshtein)("Person", "Persons"), 1);
    strict_1.default.equal((0, schema_cypher_parser_js_1.levenshtein)("Persons", "Person"), 1);
});
(0, node_test_1.default)("levenshtein: handles empty strings", () => {
    strict_1.default.equal((0, schema_cypher_parser_js_1.levenshtein)("", "abc"), 3);
    strict_1.default.equal((0, schema_cypher_parser_js_1.levenshtein)("abc", ""), 3);
    strict_1.default.equal((0, schema_cypher_parser_js_1.levenshtein)("", ""), 0);
});
(0, node_test_1.default)("nearestLabel: finds the closest match", () => {
    const candidates = ["Person", "LocalBusiness", "AdminUser"];
    strict_1.default.equal((0, schema_cypher_parser_js_1.nearestLabel)("LocaIBusiness", candidates), "LocalBusiness");
    strict_1.default.equal((0, schema_cypher_parser_js_1.nearestLabel)("AdminUsr", candidates), "AdminUser");
});
(0, node_test_1.default)("nearestLabel: returns null when no match within maxDistance", () => {
    const candidates = ["Person", "LocalBusiness"];
    strict_1.default.equal((0, schema_cypher_parser_js_1.nearestLabel)("Quokka", candidates), null);
    // Default maxDistance is 3; "abcde" is too far from any candidate.
    strict_1.default.equal((0, schema_cypher_parser_js_1.nearestLabel)("abcde", candidates, 1), null);
});
(0, node_test_1.default)("nearestLabel: empty candidates returns null", () => {
    strict_1.default.equal((0, schema_cypher_parser_js_1.nearestLabel)("Person", []), null);
});
//# sourceMappingURL=schema-cypher-parser.test.js.map