Docs/Skills and code/tests/

tests/channel-qualification-store.test.js

Code32 lines1.8 KBtests/

import test from "node:test";
import assert from "node:assert/strict";
import { normalizeLlmClassification, normalizeLlmResult, qualificationPrompt } from "../src/analysis/channel-qualification-store.js";

const url = "https://youtube.com/@systems";
test("normalizes supported classification labels without silently inventing a class", () => {
  assert.equal(normalizeLlmClassification("Core"), "core");
  assert.equal(normalizeLlmClassification("adjacent relevant"), "adjacent");
  assert.equal(normalizeLlmClassification("unrelated"), "irrelevant");
  assert.equal(normalizeLlmClassification("maybe nonsense"), null);
});

test("validates exact URL and normalizes LLM result fields", () => {
  const row = normalizeLlmResult({ channel_url: url, classification: "core", confidence: 0.92, relevance_score: 96, focus_specificity: 82,
    supporting_evidence: ["Description says technology education"], topic_tags: ["systems design", "distributed systems"], formats: ["video essays"] }, url);
  assert.equal(row.classification, "core");
  assert.equal(row.confidence, 0.92);
  assert.equal(row.relevance_score, 96);
  assert.deepEqual(row.topic_tags, ["systems design", "distributed systems"]);
  assert.throws(() => normalizeLlmResult({ channel_url: "https://youtube.com/@wrong", classification: "core", confidence: 0.9 }, url), /mismatch/);
  assert.throws(() => normalizeLlmResult({ channel_url: url, classification: "maybe", confidence: 0.9 }, url), /Invalid classification/);
});

test("qualification prompt contains configurable decision rules and conservative unknown criteria", () => {
  const prompt = qualificationPrompt();
  assert.match(prompt, /CORE:/);
  assert.match(prompt, /ADJACENT:/);
  assert.match(prompt, /UNKNOWN:/);
  assert.match(prompt, /IRRELEVANT:/);
  assert.match(prompt, /do not change URLs/i);
});

Shown as it is in the repository at build time (2026-11-03); the home directory appears as <home>. If this page and the file differ, the file is right. Back to the catalogue.