mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-27 01:11:40 +00:00
- providers.ts: drop the `dup` intermediate, fold the ternary inline - paths.ts (fmtCwdBranch): inline `b` into the `tag` template - prompts.tsx (ConfirmPrompt): hoist a single `lower = ch.toLowerCase()`, collapse the three early-return branches into two, drop the redundant bounds checks on arrow-key handlers (setSel is idempotent at 0/1), inline the `confirmLabel`/`cancelLabel` defaults at the use site - modelPicker.tsx / config/env.ts / providers.test.ts: auto-formatter reflows picked up by `npm run fix` - useInputHandlers.ts: drop the stray blank line that was tripping perfectionist/sort-imports (pre-existing lint error)
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { providerDisplayNames } from '../domain/providers.js'
|
|
|
|
describe('providerDisplayNames', () => {
|
|
it('returns bare names when all are unique', () => {
|
|
expect(
|
|
providerDisplayNames([
|
|
{ name: 'Anthropic', slug: 'anthropic' },
|
|
{ name: 'OpenAI', slug: 'openai' }
|
|
])
|
|
).toEqual(['Anthropic', 'OpenAI'])
|
|
})
|
|
|
|
it('appends slug to every collision so the disambiguation is symmetric', () => {
|
|
expect(
|
|
providerDisplayNames([
|
|
{ name: 'Kimi For Coding', slug: 'kimi-coding' },
|
|
{ name: 'Kimi For Coding', slug: 'kimi-coding-cn' }
|
|
])
|
|
).toEqual(['Kimi For Coding (kimi-coding)', 'Kimi For Coding (kimi-coding-cn)'])
|
|
})
|
|
|
|
it('only disambiguates the colliding group', () => {
|
|
expect(
|
|
providerDisplayNames([
|
|
{ name: 'Anthropic', slug: 'anthropic' },
|
|
{ name: 'Foo', slug: 'foo-a' },
|
|
{ name: 'Foo', slug: 'foo-b' }
|
|
])
|
|
).toEqual(['Anthropic', 'Foo (foo-a)', 'Foo (foo-b)'])
|
|
})
|
|
|
|
it('falls back to plain name if slug is empty', () => {
|
|
expect(
|
|
providerDisplayNames([
|
|
{ name: 'Foo', slug: '' },
|
|
{ name: 'Foo', slug: '' }
|
|
])
|
|
).toEqual(['Foo', 'Foo'])
|
|
})
|
|
|
|
it('skips disambiguation when slug equals name', () => {
|
|
expect(
|
|
providerDisplayNames([
|
|
{ name: 'foo', slug: 'foo' },
|
|
{ name: 'foo', slug: 'foo' }
|
|
])
|
|
).toEqual(['foo', 'foo'])
|
|
})
|
|
|
|
it('handles empty input', () => {
|
|
expect(providerDisplayNames([])).toEqual([])
|
|
})
|
|
|
|
it('preserves order', () => {
|
|
const input = [
|
|
{ name: 'Z', slug: 'z' },
|
|
{ name: 'A', slug: 'a1' },
|
|
{ name: 'A', slug: 'a2' }
|
|
]
|
|
|
|
expect(providerDisplayNames(input)).toEqual(['Z', 'A (a1)', 'A (a2)'])
|
|
})
|
|
})
|