Create get-short-address.test.ts

This commit is contained in:
plebeius
2026-03-08 13:09:06 +08:00
parent eda5af7bf2
commit 725da9c33e
@@ -0,0 +1,18 @@
import { describe, expect, it } from 'vitest';
import getShortAddress from '../get-short-address';
describe('getShortAddress', () => {
it('returns an empty string for falsy or too-short non-domain addresses', () => {
expect(getShortAddress('')).toBe('');
expect(getShortAddress('short-address')).toBe('');
});
it('returns domain-style addresses unchanged', () => {
expect(getShortAddress('music-posting.eth')).toBe('music-posting.eth');
expect(getShortAddress('music-posting.bso')).toBe('music-posting.bso');
});
it('returns the middle slice for long hexadecimal addresses', () => {
expect(getShortAddress('0x1234567890abcdef1234567890abcdef12345678')).toBe('7890abcdef12');
});
});