import { describe, expect, it } from 'vitest' import { short } from './search' /** * What a row does to an identifier before drawing it. * * The abbreviation is the only thing in the finder that alters what a venue * said, so the rule it follows is stated: enough of both ends to check against * something already in hand, and nothing done at all to a key that was short to * begin with. */ describe('short', () => { it('keeps both ends of a long identifier', () => { expect(short('0xce15a1b96a1ee7a2b3f0d4c5e6f7a8b9c0d1e2fe36')).toBe('0xce15...fe36') }) it('draws one whole where abbreviating it would not shorten it', () => { // Fourteen abbreviates to thirteen. Thirteen would abbreviate to thirteen, // so it is drawn as it is. expect(short('0xce15a1b96a1e2')).toBe('0xce15...a1e2') expect(short('0xce15a1b96a1')).toBe('0xce15a1b96a1') expect(short('LUX')).toBe('LUX') }) it('elides in three periods, which is what a reader copies out', () => { // Not U+2026: a character that looks alike at a glance is a different // character in every string somebody pastes somewhere else. expect(short('0'.repeat(40))).toContain('...') expect(short('0'.repeat(40))).not.toContain('…') }) })