feat(frontend): add card-to-iban interface
This commit is contained in:
23
frontend/app/utils/card.test.ts
Normal file
23
frontend/app/utils/card.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { formatCard, normalizeCard, validCard } from './card'
|
||||
|
||||
describe('card utilities', () => {
|
||||
it('normalizes Persian and Arabic digits with common separators', () => {
|
||||
expect(normalizeCard('۶۰۳۷ ٩٩۷۵-۱۲۳۴ ۵۶۷۸')).toBe('6037997512345678')
|
||||
})
|
||||
|
||||
it('keeps unexpected characters so validation can report them', () => {
|
||||
expect(normalizeCard('6037 ABC 1234')).toBe('6037ABC1234')
|
||||
})
|
||||
|
||||
it('accepts only sixteen ASCII digits', () => {
|
||||
expect(validCard('6037997512345678')).toBe(true)
|
||||
expect(validCard('603799751234567')).toBe(false)
|
||||
expect(validCard('603799ABC2345678')).toBe(false)
|
||||
})
|
||||
|
||||
it('groups a normalized card for display', () => {
|
||||
expect(formatCard('6037997512345678')).toBe('6037 9975 1234 5678')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user