mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-08 02:25:36 +08:00
refactor(live-atc): extract normalizeManualFreq to shared/utils, add tests
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
26
tests/shared/frequency.test.ts
Normal file
26
tests/shared/frequency.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { normalizeManualFreq } from '../../shared/utils/frequency.ts'
|
||||
|
||||
test('normalizeManualFreq pads a bare integer to three decimals', () => {
|
||||
assert.equal(normalizeManualFreq('121'), '121.000')
|
||||
})
|
||||
|
||||
test('normalizeManualFreq accepts a comma decimal separator', () => {
|
||||
assert.equal(normalizeManualFreq('121,3'), '121.300')
|
||||
})
|
||||
|
||||
test('normalizeManualFreq rejects values outside the VHF airband', () => {
|
||||
assert.equal(normalizeManualFreq('99.000'), null)
|
||||
assert.equal(normalizeManualFreq('110.000'), null)
|
||||
assert.equal(normalizeManualFreq('140.000'), null)
|
||||
})
|
||||
|
||||
test('normalizeManualFreq accepts the lower airband boundary', () => {
|
||||
assert.equal(normalizeManualFreq('118'), '118.000')
|
||||
})
|
||||
|
||||
test('normalizeManualFreq rejects garbage input', () => {
|
||||
assert.equal(normalizeManualFreq('abc'), null)
|
||||
assert.equal(normalizeManualFreq(''), null)
|
||||
})
|
||||
Reference in New Issue
Block a user