import {
  SearchHandler,
  filterIsoforms
} from "./chunk-CC3GFVV6.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 {
  ISOFORM_EXPRESSION
} from "./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/isoformExpression.unit.spec.ts
var import_tape = __toESM(require_tape(), 1);
function mockGm(isoform) {
  return { isoform, chr: "chr1", start: 0, stop: 100, exon: [[0, 100]] };
}
(0, import_tape.default)("\n", function(test) {
  test.comment("-***- termdb/handlers/isoformExpression -***-");
  test.end();
});
(0, import_tape.default)("selectIsoform() should call callback with configured unit from termdbConfig", (test) => {
  const handler = new SearchHandler();
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  handler.app = {
    vocabApi: {
      termdbConfig: {
        queries: {
          isoformExpression: { unit: "TPM" }
        }
      }
    }
  };
  handler.selectIsoform("ENST00000269305", "TP53");
  test.equal(selected?.isoform, "ENST00000269305", "Should pass selected isoform");
  test.equal(selected?.gene, "TP53", "Should pass gene");
  test.equal(selected?.name, "ENST00000269305 TPM", "Should include configured unit in term name");
  test.equal(selected?.type, ISOFORM_EXPRESSION, "Should set type to isoformExpression");
  test.end();
});
(0, import_tape.default)("selectIsoform() should use default unit when not configured", (test) => {
  const handler = new SearchHandler();
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  handler.app = {
    vocabApi: {
      termdbConfig: {
        queries: {}
      }
    }
  };
  handler.selectIsoform("ENST00000269305", "TP53");
  test.equal(selected?.isoform, "ENST00000269305", "Should pass selected isoform");
  test.equal(selected?.name, "ENST00000269305 TPM", "Should use default unit TPM");
  test.equal(selected?.type, ISOFORM_EXPRESSION, "Should set type to isoformExpression");
  test.end();
});
(0, import_tape.default)("selectCollection() should create a custom termCollection from multiple isoforms", (test) => {
  const handler = new SearchHandler();
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  handler.app = {
    vocabApi: {
      termdbConfig: {
        queries: {
          isoformExpression: { unit: "TPM" }
        }
      }
    }
  };
  handler.selectCollection([mockGm("ENST00000256078"), mockGm("ENST00000311936")], "KRAS");
  test.equal(selected?.type, "termCollection", "Should set type to termCollection");
  test.equal(selected?.isCustom, true, "Should set isCustom flag");
  test.equal(selected?.memberType, "numeric", "Should set memberType to numeric");
  test.equal(selected?.name, "KRAS Isoforms (TPM)", "Should include gene and unit in name");
  test.equal(selected?.isleaf, true, "Should set isleaf");
  test.deepEqual(selected?.propsByTermId, {}, "Should have empty propsByTermId");
  test.equal(selected?.termlst?.length, 2, "Should have 2 member terms");
  const mt = selected.termlst[0];
  test.equal(mt.id, "ENST00000256078", "Member term id should be the isoform ID");
  test.equal(mt.name, "ENST00000256078", "Member term name should be the isoform ID");
  test.equal(mt.type, "isoformExpression", "Member term type should be isoformExpression");
  test.equal(mt.isoform, "ENST00000256078", "Member term should carry isoform field");
  test.end();
});
(0, import_tape.default)("selectCollection() should use default unit when not configured", (test) => {
  const handler = new SearchHandler();
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  handler.app = {
    vocabApi: {
      termdbConfig: {
        queries: {}
      }
    }
  };
  handler.selectCollection([mockGm("ENST00000256078"), mockGm("ENST00000311936")], "KRAS");
  test.equal(selected?.name, "KRAS Isoforms (TPM)", "Should use default unit TPM");
  test.end();
});
(0, import_tape.default)("showIsoforms multi-select: single isoform calls selectIsoform, multiple calls selectCollection", (test) => {
  const handler = new SearchHandler();
  const calls = [];
  handler.app = {
    vocabApi: {
      termdbConfig: {
        queries: {
          isoformExpression: { unit: "TPM" }
        }
      }
    }
  };
  handler.selectIsoform = (isoform, gene) => {
    calls.push({ method: "selectIsoform", args: { isoform, gene } });
  };
  handler.selectCollection = (gms, gene) => {
    calls.push({ method: "selectCollection", args: { gms, gene } });
  };
  const onMultiSelect1 = (selected) => {
    if (selected.length === 1) handler.selectIsoform(selected[0].isoform, "TP53");
    else handler.selectCollection(selected, "TP53");
  };
  onMultiSelect1([mockGm("ENST00000269305")]);
  test.equal(calls.length, 1, "Should have one call");
  test.equal(calls[0].method, "selectIsoform", "Single isoform should call selectIsoform");
  const onMultiSelect2 = (selected) => {
    if (selected.length === 1) handler.selectIsoform(selected[0].isoform, "KRAS");
    else handler.selectCollection(selected, "KRAS");
  };
  onMultiSelect2([mockGm("ENST00000256078"), mockGm("ENST00000311936")]);
  test.equal(calls.length, 2, "Should have two calls total");
  test.equal(calls[1].method, "selectCollection", "Multiple isoforms should call selectCollection");
  test.equal(calls[1].args.gms.length, 2, "Should pass both gene models");
  test.end();
});
(0, import_tape.default)("filterIsoforms() should return only ENST isoforms present in availableItems", (test) => {
  const gmlst = [mockGm("ENST00000269305"), mockGm("ENST00000413465"), mockGm("NM_000546"), mockGm("ENST00000359597")];
  const availableItems = ["ENST00000269305", "ENST00000359597"];
  const result = filterIsoforms(gmlst, availableItems);
  test.equal(result.length, 2, "Should return 2 matching isoforms");
  test.equal(result[0].isoform, "ENST00000269305", "First match correct");
  test.equal(result[1].isoform, "ENST00000359597", "Second match correct");
  test.end();
});
(0, import_tape.default)("filterIsoforms() should exclude non-ENST isoforms even if in availableItems", (test) => {
  const gmlst = [mockGm("NM_000546"), mockGm("NR_176326"), mockGm("ENST00000269305")];
  const availableItems = ["NM_000546", "ENST00000269305"];
  const result = filterIsoforms(gmlst, availableItems);
  test.equal(result.length, 1, "Should only return ENST isoform");
  test.equal(result[0].isoform, "ENST00000269305", "Should be the ENST match");
  test.end();
});
(0, import_tape.default)("filterIsoforms() should return all ENST isoforms when availableItems is empty", (test) => {
  const gmlst = [mockGm("ENST00000269305"), mockGm("ENST00000413465"), mockGm("NM_000546")];
  const result = filterIsoforms(gmlst, []);
  test.equal(result.length, 2, "Should return all ENST isoforms when no filter");
  test.equal(result[0].isoform, "ENST00000269305", "First ENST correct");
  test.equal(result[1].isoform, "ENST00000413465", "Second ENST correct");
  test.end();
});
(0, import_tape.default)("filterIsoforms() should return empty array when no ENST isoforms match", (test) => {
  const gmlst = [mockGm("ENST00000269305"), mockGm("ENST00000413465")];
  const availableItems = ["ENST00000999999"];
  const result = filterIsoforms(gmlst, availableItems);
  test.equal(result.length, 0, "Should return empty when no matches");
  test.end();
});
//# sourceMappingURL=isoformExpression.unit.spec-7T2GOHH3.js.map
