import {describe, expect, test} from 'bun:test' import {nameOf, speaker} from '@/lib/names' import {$s} from '@/lib/store' describe('names', () => { test('a session goes by its label, then its branch, then its worktree', () => { $s.names = { 'bridge-cse_01AB': {label: 'can we have a web page', branch: 'worktree-bridge-cse_01AB', link: null}, 'readme-sheet': {label: null, branch: 'docs/readme-sheet', link: null}, } expect(nameOf('bridge-cse_01AB')).toEqual({ title: 'can we have a web page', sub: 'bridge-cse_01AB', link: 'https://claude.ai/code/session_01AB', owner: 'bridge-cse_01AB', }) expect(nameOf('readme-sheet')).toMatchObject({title: 'docs/readme-sheet', sub: 'readme-sheet', link: null}) expect(nameOf('gate-readme-sheet').title).toBe('docs/readme-sheet (landing gate)') expect(nameOf('unknown')).toMatchObject({title: 'unknown', sub: null}) }) test('a speaker: midas, a person on the page, a session behind its caller', () => { $s.names = {'bridge-cse_01AB': {label: 'can we have a web page', branch: null, link: null}} expect(speaker('hub').title).toBe('midas') expect(speaker('web:sam').title).toBe('sam') expect(speaker('workstation:midas').title).toBe('midas') expect(speaker('agent:bridge-cse_01AB').title).toBe('can we have a web page') expect(speaker('bridge-cse_01AB').title).toBe('can we have a web page') }) })