Docs/Skills and code/tests/
tests/discovery-v2.test.js
import test from 'node:test';
import assert from 'node:assert/strict';
import { normalizeQuery, uniqueQueries, videoToChannelUrl, scoreDiscoveryEvidence } from '../src/discovery/v2-utils.js';
test('normalizes and deduplicates queries case-insensitively',()=>{
assert.equal(normalizeQuery(' technology\n education '),'technology education');
const q=uniqueQueries(['Technology Education','technology education','', 'Ada Lovelace analysis'],10);
assert.deepEqual(q.map(x=>x.query),['Technology Education','Ada Lovelace analysis']);
});
test('accepts YouTube channel URLs and rejects missing URLs',()=>{
assert.equal(videoToChannelUrl({channel_url:'https://www.youtube.com/@Example/'}),'https://www.youtube.com/@Example');
assert.equal(videoToChannelUrl({channel_url:null}),null);
});
test('discovery score rewards observed reach and relevant repeated evidence',()=>{
const small=scoreDiscoveryEvidence({max_video_views:10000,found_videos:4,subscriber_count:500,video_count:20,classification:'core'});
const weak=scoreDiscoveryEvidence({max_video_views:20,found_videos:1,subscriber_count:50,video_count:1200,classification:'unknown'});
assert.ok(small.score>weak.score);
assert.equal(small.confidence,'moderate');
assert.equal(weak.confidence,'very_low');
});
test('missing subscriber data stays explicitly unknown in score evidence',()=>{
const result=scoreDiscoveryEvidence({max_video_views:1000,found_videos:2,subscriber_count:null,video_count:null,classification:'adjacent'});
assert.equal(result.viewsPerSubscriber,null);
assert.equal(result.confidence,'low');
assert.equal(result.components.smallChannelUpside,null);
});
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.