More APRS enhancements
This commit is contained in:
64
ui/src/libs/callsignMapper.test.ts
Normal file
64
ui/src/libs/callsignMapper.test.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { getCountryCodeFromCallsign } from './callsignMapper';
|
||||
|
||||
describe('getCountryCodeFromCallsign', () => {
|
||||
it('should return US for K prefix', () => {
|
||||
expect(getCountryCodeFromCallsign('K6ABC')).toBe('US');
|
||||
expect(getCountryCodeFromCallsign('KA1ABC')).toBe('US');
|
||||
expect(getCountryCodeFromCallsign('W1AW')).toBe('US');
|
||||
expect(getCountryCodeFromCallsign('N0CALL')).toBe('US');
|
||||
});
|
||||
|
||||
it('should handle callsigns with SSID', () => {
|
||||
expect(getCountryCodeFromCallsign('K6ABC-5')).toBe('US');
|
||||
expect(getCountryCodeFromCallsign('PA0MZ-9')).toBe('NL');
|
||||
});
|
||||
|
||||
it('should return NL for PA prefix', () => {
|
||||
expect(getCountryCodeFromCallsign('PA0MZ')).toBe('NL');
|
||||
expect(getCountryCodeFromCallsign('PD0ABC')).toBe('NL');
|
||||
});
|
||||
|
||||
it('should return GB for G and M prefixes', () => {
|
||||
expect(getCountryCodeFromCallsign('G4ABC')).toBe('GB');
|
||||
expect(getCountryCodeFromCallsign('M0XYZ')).toBe('GB');
|
||||
});
|
||||
|
||||
it('should return DE for D prefix', () => {
|
||||
expect(getCountryCodeFromCallsign('DL1ABC')).toBe('DE');
|
||||
expect(getCountryCodeFromCallsign('DJ5XY')).toBe('DE');
|
||||
});
|
||||
|
||||
it('should return FR for F prefix', () => {
|
||||
expect(getCountryCodeFromCallsign('F6ABC')).toBe('FR');
|
||||
});
|
||||
|
||||
it('should return JP for JA prefix', () => {
|
||||
expect(getCountryCodeFromCallsign('JA1ABC')).toBe('JP');
|
||||
});
|
||||
|
||||
it('should return CA for VE prefix', () => {
|
||||
expect(getCountryCodeFromCallsign('VE3ABC')).toBe('CA');
|
||||
});
|
||||
|
||||
it('should handle lowercase callsigns', () => {
|
||||
expect(getCountryCodeFromCallsign('k6abc')).toBe('US');
|
||||
expect(getCountryCodeFromCallsign('pa0mz')).toBe('NL');
|
||||
});
|
||||
|
||||
it('should return null for invalid or unknown callsigns', () => {
|
||||
expect(getCountryCodeFromCallsign('')).toBe(null);
|
||||
expect(getCountryCodeFromCallsign(undefined)).toBe(null);
|
||||
expect(getCountryCodeFromCallsign('???')).toBe(null);
|
||||
});
|
||||
|
||||
it('should handle numeric prefixes', () => {
|
||||
expect(getCountryCodeFromCallsign('9A1ABC')).toBe('HR'); // Croatia
|
||||
expect(getCountryCodeFromCallsign('4X1AB')).toBe('IL'); // Israel
|
||||
});
|
||||
|
||||
it('should match longest prefix first', () => {
|
||||
// Make sure it tries 3-char, then 2-char, then 1-char prefixes
|
||||
expect(getCountryCodeFromCallsign('PA0MZ')).toBe('NL'); // Should match PA, not P
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user