import {
  SearchHandler
} from "./chunk-EVN6KWPN.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 {
  SINGLECELL_GENE_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 {
  select_default
} from "./chunk-I6Y4O3RR.js";
import "./chunk-OMR2DT66.js";
import "./chunk-DQC5FFGV.js";
import {
  __toESM
} from "./chunk-HFNDKYVF.js";

// termdb/handlers/test/singleCellGeneExpression.unit.spec.ts
var import_tape = __toESM(require_tape(), 1);
function getHolder() {
  return select_default("body").append("div");
}
function getUsecase(sample = { id: "sample-A" }) {
  return {
    target: "sampleScatter",
    detail: "term",
    specialCase: {
      config: { sample }
    }
  };
}
(0, import_tape.default)("\n", function(test) {
  test.comment("-***- termdb/handlers/singleCellGeneExpression -***-");
  test.end();
});
(0, import_tape.default)("validateOpts() should require callback, app, holder, genomeObj, and usecase.specialCase.config.sample", (test) => {
  const handler = new SearchHandler();
  const holder = getHolder();
  test.throws(
    () => handler.validateOpts({
      holder,
      app: { vocabApi: { termdbConfig: { queries: { singleCell: { geneExpression: {} } } } } },
      genomeObj: {},
      usecase: getUsecase()
    }),
    /callback is required/,
    "Should throw when callback is missing"
  );
  test.throws(
    () => handler.validateOpts({
      holder,
      callback: () => {
      },
      genomeObj: {},
      usecase: getUsecase()
    }),
    /app is required/,
    "Should throw when app is missing"
  );
  test.throws(
    () => handler.validateOpts({
      callback: () => {
      },
      app: { vocabApi: { termdbConfig: {} } },
      genomeObj: {},
      usecase: getUsecase()
    }),
    /holder is required/,
    "Should throw when holder is missing"
  );
  test.throws(
    () => handler.validateOpts({
      holder,
      callback: () => {
      },
      app: { vocabApi: { termdbConfig: {} } },
      usecase: getUsecase()
    }),
    /genomeObj is required/,
    "Should throw when genomeObj is missing"
  );
  if (test["_ok"]) holder.remove();
  test.end();
});
(0, import_tape.default)("selectGene() should throw when no gene is selected", async (test) => {
  const handler = new SearchHandler();
  handler.app = { vocabApi: { termdbConfig: {} } };
  handler.callback = () => {
  };
  try {
    await handler.selectGene(void 0, { id: "sample-A" });
    test.fail("Should throw when no gene is selected");
  } catch (e) {
    test.match(String(e), /No gene selected/, "Should throw expected message when gene is missing");
  }
  test.end();
});
(0, import_tape.default)("selectGene() should call callback with configured unit and default unit fallback", async (test) => {
  const handler = new SearchHandler();
  const sample = { id: "sample-A", type: "tumor" };
  let selected;
  handler.callback = (t) => {
    selected = t;
  };
  handler.app = {
    vocabApi: {
      termdbConfig: {
        queries: {
          singleCell: {
            geneExpression: { unit: "log2 CPM" }
          }
        }
      }
    }
  };
  await handler.selectGene("TP53", sample);
  test.equal(selected?.gene, "TP53", "Should pass selected gene");
  test.equal(selected?.name, "TP53 log2 CPM", "Should include configured unit in term name");
  test.equal(selected?.type, SINGLECELL_GENE_EXPRESSION, "Should set type to singleCellGeneExpression");
  test.deepEqual(selected?.sample, sample, "Should pass through selected sample");
  handler.app = { vocabApi: { termdbConfig: { queries: { singleCell: { geneExpression: {} } } } } };
  await handler.selectGene("GATA3", sample);
  test.equal(selected?.name, "GATA3 Gene Expression", "Should use default unit when config unit is not provided");
  test.end();
});
//# sourceMappingURL=singleCellGeneExpression.unit.spec-4ZTBG37H.js.map
