refactor: split validation handler responsibilities
This commit is contained in:
16
tests/unit/production-input-service.test.ts
Normal file
16
tests/unit/production-input-service.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { identifyInputType } from '../../src/main/services/validation/production-input-service'
|
||||
|
||||
describe('production-input-service', () => {
|
||||
it('identifies order numbers', () => {
|
||||
expect(identifyInputType('SC12345678901234')).toBe('order_number')
|
||||
})
|
||||
|
||||
it('identifies production ids', () => {
|
||||
expect(identifyInputType('26A1234')).toBe('production_id')
|
||||
})
|
||||
|
||||
it('returns unknown for unsupported formats', () => {
|
||||
expect(identifyInputType('invalid-value')).toBe('unknown')
|
||||
})
|
||||
})
|
||||
31
tests/unit/shared-production-ids-store.test.ts
Normal file
31
tests/unit/shared-production-ids-store.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { SharedProductionIdsStore } from '../../src/main/services/validation/shared-production-ids-store'
|
||||
|
||||
describe('SharedProductionIdsStore', () => {
|
||||
it('stores unique ids per sender', () => {
|
||||
const store = new SharedProductionIdsStore()
|
||||
|
||||
store.set(1, ['A', 'B', 'A'])
|
||||
|
||||
expect(store.get(1)).toEqual(['A', 'B'])
|
||||
})
|
||||
|
||||
it('keeps sender scopes isolated', () => {
|
||||
const store = new SharedProductionIdsStore()
|
||||
|
||||
store.set(1, ['A'])
|
||||
store.set(2, ['B'])
|
||||
|
||||
expect(store.get(1)).toEqual(['A'])
|
||||
expect(store.get(2)).toEqual(['B'])
|
||||
})
|
||||
|
||||
it('clears sender data', () => {
|
||||
const store = new SharedProductionIdsStore()
|
||||
|
||||
store.set(1, ['A'])
|
||||
store.clear(1)
|
||||
|
||||
expect(store.get(1)).toEqual([])
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user