- Address field on member table (jsonb, same format as account) - Members inherit email, phone, address from account when not provided - State normalization: "Texas" → "TX", "california" → "CA" via shared util - Member form drops zodResolver to fix optional field validation flashing - Account name auto-format: "First Last - Account" - US state lookup with full name + code support
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { describe, it, expect } from 'bun:test'
|
|
import { normalizeStateCode, isValidStateCode } from '../../src/utils/states.js'
|
|
|
|
describe('normalizeStateCode', () => {
|
|
it('normalizes two-letter codes', () => {
|
|
expect(normalizeStateCode('tx')).toBe('TX')
|
|
expect(normalizeStateCode('TX')).toBe('TX')
|
|
expect(normalizeStateCode('Tx')).toBe('TX')
|
|
expect(normalizeStateCode(' ca ')).toBe('CA')
|
|
})
|
|
|
|
it('normalizes full state names', () => {
|
|
expect(normalizeStateCode('Texas')).toBe('TX')
|
|
expect(normalizeStateCode('texas')).toBe('TX')
|
|
expect(normalizeStateCode('CALIFORNIA')).toBe('CA')
|
|
expect(normalizeStateCode('New York')).toBe('NY')
|
|
expect(normalizeStateCode('north carolina')).toBe('NC')
|
|
})
|
|
|
|
it('returns null for invalid input', () => {
|
|
expect(normalizeStateCode('ZZ')).toBeNull()
|
|
expect(normalizeStateCode('Narnia')).toBeNull()
|
|
expect(normalizeStateCode('')).toBeNull()
|
|
})
|
|
|
|
it('handles territories', () => {
|
|
expect(normalizeStateCode('DC')).toBe('DC')
|
|
expect(normalizeStateCode('Puerto Rico')).toBe('PR')
|
|
expect(normalizeStateCode('GU')).toBe('GU')
|
|
})
|
|
})
|
|
|
|
describe('isValidStateCode', () => {
|
|
it('returns true for valid codes', () => {
|
|
expect(isValidStateCode('TX')).toBe(true)
|
|
expect(isValidStateCode('ca')).toBe(true)
|
|
})
|
|
|
|
it('returns false for invalid codes', () => {
|
|
expect(isValidStateCode('ZZ')).toBe(false)
|
|
expect(isValidStateCode('Texas')).toBe(false)
|
|
})
|
|
})
|