Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124/** Unit tests for model pattern parsing helpers. @module */
import { describe, expect, it,} from '@monochromatic-dev/module-test/ts';
import { hasDateSuffix, isAlias, isThinkingLevel, parseModelPattern, patternHasGlob, splitThinkingSuffix,} from '../dist/final/node/index.mjs';import { fixtureModel, } from './test-fixtures.ts';
//region Fixtures
/** Alias model fixture preferred by fuzzy matching. */const aliasModel = fixtureModel({ provider: 'anthropic', id: 'claude-sonnet-latest', name: 'Claude Sonnet Latest',},);
/** Dated model fixture used to test alias preference. */const datedModel = fixtureModel({ provider: 'anthropic', id: 'claude-sonnet-20251001', name: 'Claude Sonnet Snapshot',},);
/** Models available to pattern tests. */const availableModels = [ datedModel, aliasModel,] as const;
//endregion Fixtures
await describe({ name: '', children: [ describe({ name: parseModelPattern.name, children: [ it({ name: 'matches fuzzy aliases and carries thinking suffixes', fn: async function testFuzzyAliasThinking() { const result = parseModelPattern({ pattern: 'sonnet:high', availableModels, },); expect(result.model,).toBe(aliasModel,); expect(result.thinkingLevel,).toBe('high',); }, },), it({ name: 'strips invalid suffixes iteratively', fn: async function testInvalidSuffixStripping() { const result = parseModelPattern({ pattern: 'sonnet:not-a-level', availableModels, },); expect(result.model,).toBe(aliasModel,); expect(result.thinkingLevel,).toBeUndefined(); }, },), ], },), describe({ name: splitThinkingSuffix.name, children: [ it({ name: 'splits valid thinking suffixes only', fn: async function testSplitThinkingSuffix() { expect(splitThinkingSuffix('anthropic/*:xhigh',),).toEqual({ pattern: 'anthropic/*', thinkingLevel: 'xhigh', },); expect(splitThinkingSuffix('anthropic/*:custom',),).toEqual({ pattern: 'anthropic/*:custom', },); }, },), ], },), describe({ name: patternHasGlob.name, children: [ it({ name: 'detects glob tokens', fn: async function testPatternHasGlob() { expect(patternHasGlob('anthropic/*',),).toBe(true,); expect(patternHasGlob('anthropic/claude',),).toBe(false,); }, },), ], },), describe({ name: 'low-level helpers', children: [ it({ name: 'detects thinking levels, aliases, and date suffixes', fn: async function testLowLevelHelpers() { expect(isThinkingLevel('minimal',),).toBe(true,); expect(isThinkingLevel('custom',),).toBe(false,); expect(hasDateSuffix('claude-20251001',),).toBe(true,); expect(hasDateSuffix('claude-2025x001',),).toBe(false,); expect(isAlias('claude-sonnet-latest',),).toBe(true,); expect(isAlias('claude-sonnet-20251001',),).toBe(false,); }, },), ], },), ],},);