Remove some unneeded duplication and fix up reconnection management

This commit is contained in:
Jack Kingsman
2026-01-30 21:03:58 -08:00
parent b6c3e13234
commit 1ea809c4e3
16 changed files with 50 additions and 152 deletions
+2 -17
View File
@@ -4,13 +4,12 @@ import {
findContactsByPrefix,
calculateDistance,
sortContactsByDistance,
getHopCount,
resolvePath,
formatDistance,
formatHopCounts,
} from '../utils/pathUtils';
import type { Contact, RadioConfig } from '../types';
import { CONTACT_TYPE_REPEATER, CONTACT_TYPE_CLIENT } from '../types';
import { CONTACT_TYPE_REPEATER } from '../types';
// Helper to create mock contacts
function createContact(overrides: Partial<Contact> = {}): Contact {
@@ -90,7 +89,7 @@ describe('findContactsByPrefix', () => {
createContact({
public_key: '1ACCCC' + 'C'.repeat(52),
name: 'Client1',
type: CONTACT_TYPE_CLIENT,
type: 1, // client
}),
];
@@ -195,20 +194,6 @@ describe('sortContactsByDistance', () => {
});
});
describe('getHopCount', () => {
it('returns 0 for null/empty', () => {
expect(getHopCount(null)).toBe(0);
expect(getHopCount(undefined)).toBe(0);
expect(getHopCount('')).toBe(0);
});
it('counts hops correctly', () => {
expect(getHopCount('1A')).toBe(1);
expect(getHopCount('1A2B')).toBe(2);
expect(getHopCount('1A2B3C')).toBe(3);
});
});
describe('resolvePath', () => {
const repeater1 = createContact({
public_key: '1A' + 'A'.repeat(62),