c41e5063b7
Removed entire kbx-foundation-v36 directory as it's been replaced by the new KBX Foundation v4 patterns implemented in this session: - Registry-driven screen definitions - Density-aware UI adapter components - Feature module templates (ShadowRun, Models) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
27 lines
1.2 KiB
TypeScript
27 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { isKbxBarcodeDuplicate, normalizeKbxBarcode } from '@kbx/ui'
|
|
|
|
describe('KbxBarcodeCapture contract', () => {
|
|
it('normalizes scanner text but never invents another barcode', () => {
|
|
expect(normalizeKbxBarcode(' 8801234567890 ', 'keyboard-wedge', 3, 256, 1)).toEqual({
|
|
rawValue: ' 8801234567890 ',
|
|
normalizedValue: '8801234567890',
|
|
source: 'keyboard-wedge',
|
|
occurredAt: 1,
|
|
})
|
|
})
|
|
|
|
it('rejects implausibly short and oversized scanner buffers', () => {
|
|
expect(normalizeKbxBarcode('A', 'keyboard-wedge', 3, 256, 1)).toBeNull()
|
|
expect(normalizeKbxBarcode('123456', 'keyboard-wedge', 3, 5, 1)).toBeNull()
|
|
})
|
|
|
|
it('ignores only the same barcode inside the short device debounce window', () => {
|
|
const last=normalizeKbxBarcode('ABC001','keyboard-wedge',3,256,1000)!
|
|
const duplicate=normalizeKbxBarcode('ABC001','keyboard-wedge',3,256,1100)!
|
|
const legitimateLaterScan=normalizeKbxBarcode('ABC001','keyboard-wedge',3,256,1400)!
|
|
expect(isKbxBarcodeDuplicate(duplicate,last,180)).toBe(true)
|
|
expect(isKbxBarcodeDuplicate(legitimateLaterScan,last,180)).toBe(false)
|
|
})
|
|
})
|