import {
  SearchHandler
} from "./chunk-4DXZGZOB.js";
import {
  require_tape
} from "./chunk-QWOE5YTB.js";
import "./chunk-SA7APTJR.js";
import "./chunk-HJ6L54YS.js";
import "./chunk-LSEFWW72.js";
import "./chunk-SKREEF3H.js";
import "./chunk-HYOEWQ5P.js";
import "./chunk-HBW42TDT.js";
import "./chunk-G6O3URDN.js";
import "./chunk-FN5XPUPH.js";
import "./chunk-IIT367QZ.js";
import "./chunk-RZGEKL77.js";
import "./chunk-UI7OCM2A.js";
import "./chunk-YZK37YCC.js";
import "./chunk-7EMWHCVW.js";
import "./chunk-7IYJZZQI.js";
import "./chunk-M3J4MINX.js";
import "./chunk-PF4DSFDR.js";
import "./chunk-QH6W3NVF.js";
import "./chunk-NOEAT6CX.js";
import "./chunk-4UWS5Y3N.js";
import "./chunk-DD4R5P6W.js";
import "./chunk-JNITUVXP.js";
import "./chunk-KSGA62R2.js";
import "./chunk-LOZEKOES.js";
import "./chunk-TOU7EVFQ.js";
import "./chunk-OAWQ6LOO.js";
import "./chunk-TLT4YIG3.js";
import "./chunk-KYBIQBXE.js";
import "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import {
  __toESM
} from "./chunk-HFNDKYVF.js";

// termdb/handlers/test/snp.unit.spec.ts
var import_tape = __toESM(require_tape(), 1);
function getGeneSearchWithCoordinates(overrides = {}) {
  return {
    chr: "chr17",
    ref: "G",
    alt: "A",
    fromWhat: "rs1234567",
    start: 7670618,
    stop: 7670619,
    ...overrides
  };
}
function getGeneSearchWithPos(overrides = {}) {
  return {
    chr: "chr13",
    ref: "T",
    alt: "C",
    fromWhat: "BRCA2:c.68_69delAA",
    pos: 32889612,
    ...overrides
  };
}
(0, import_tape.default)("\n", function(test) {
  test.comment("-***- termdb/handlers/snp -***-");
  test.end();
});
(0, import_tape.default)("selectSnp() should throw when required fields are missing", async (test) => {
  const handler = new SearchHandler();
  handler.callback = () => {
  };
  try {
    await handler.selectSnp({ chr: "chr1", ref: "A", alt: "T" });
    test.fail("Should throw when fromWhat is missing");
  } catch (e) {
    test.match(String(e), /missing chr, ref, alt, or fromWhat/, "Should throw when fromWhat is missing");
  }
  try {
    await handler.selectSnp({ ref: "A", alt: "T", fromWhat: "rs123" });
    test.fail("Should throw when chr is missing");
  } catch (e) {
    test.match(String(e), /missing chr, ref, alt, or fromWhat/, "Should throw when chr is missing");
  }
  try {
    await handler.selectSnp({ chr: "chr1", alt: "T", fromWhat: "rs123" });
    test.fail("Should throw when ref is missing");
  } catch (e) {
    test.match(String(e), /missing chr, ref, alt, or fromWhat/, "Should throw when ref is missing");
  }
  try {
    await handler.selectSnp({ chr: "chr1", ref: "A", fromWhat: "rs123" });
    test.fail("Should throw when alt is missing");
  } catch (e) {
    test.match(String(e), /missing chr, ref, alt, or fromWhat/, "Should throw when alt is missing");
  }
  test.end();
});
(0, import_tape.default)("selectSnp() should throw when coordinate is missing", async (test) => {
  const handler = new SearchHandler();
  handler.callback = () => {
  };
  try {
    await handler.selectSnp({
      chr: "chr17",
      ref: "G",
      alt: "A",
      fromWhat: "rs1234567"
    });
    test.fail("Should throw when coordinate is missing");
  } catch (e) {
    test.match(String(e), /missing coordinate of snp/, "Should throw expected message for missing coordinate");
  }
  test.end();
});
(0, import_tape.default)("selectSnp() should call callback with term object using start/stop coordinates", async (test) => {
  const handler = new SearchHandler();
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  const geneSearch = getGeneSearchWithCoordinates();
  await handler.selectSnp(geneSearch);
  test.equal(selected?.id, "rs1234567", "Should set id to fromWhat");
  test.equal(selected?.chr, "chr17", "Should pass chr");
  test.equal(selected?.start, 7670618, "Should pass start coordinate");
  test.equal(selected?.stop, 7670619, "Should pass stop coordinate");
  test.equal(selected?.ref, "G", "Should pass ref");
  test.deepEqual(selected?.alt, ["A"], "Should convert alt string to array");
  test.equal(selected?.name, "rs1234567", "Should set name to fromWhat");
  test.equal(selected?.type, "snp", "Should set type to snp");
  test.end();
});
(0, import_tape.default)("selectSnp() should call callback with term object using pos coordinate", async (test) => {
  const handler = new SearchHandler();
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  const geneSearch = getGeneSearchWithPos();
  await handler.selectSnp(geneSearch);
  test.equal(selected?.id, "BRCA2:c.68_69delAA", "Should set id to fromWhat");
  test.equal(selected?.chr, "chr13", "Should pass chr");
  test.equal(selected?.start, 32889611, "Should convert pos-1 to start");
  test.equal(selected?.stop, 32889612, "Should set stop to pos");
  test.equal(selected?.ref, "T", "Should pass ref");
  test.deepEqual(selected?.alt, ["C"], "Should convert alt string to array");
  test.equal(selected?.name, "BRCA2:c.68_69delAA", "Should set name to fromWhat");
  test.equal(selected?.type, "snp", "Should set type to snp");
  test.end();
});
(0, import_tape.default)("selectSnp() should handle alt as array when already in array format", async (test) => {
  const handler = new SearchHandler();
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  const geneSearch = getGeneSearchWithCoordinates({ alt: ["A", "T"] });
  await handler.selectSnp(geneSearch);
  test.deepEqual(selected?.alt, ["A", "T"], "Should preserve alt array when provided as array");
  test.end();
});
(0, import_tape.default)("selectSnp() should handle various chromosome formats", async (test) => {
  const handler = new SearchHandler();
  const chromosomes = ["chr1", "chr22", "chrX", "chrY", "chrM"];
  for (const chr of chromosomes) {
    let selected;
    handler.callback = (t) => {
      selected = t;
    };
    const geneSearch = getGeneSearchWithCoordinates({ chr });
    await handler.selectSnp(geneSearch);
    test.equal(selected?.chr, chr, `Should handle chromosome ${chr}`);
  }
  test.end();
});
//# sourceMappingURL=snp.unit.spec-ISXCLMWW.js.map
