import { test } from '@japa/runner'
import {
  createPhoneSemantic,
  isPhoneSemantic,
  DEFAULT_PHONE_CONFIG,
  type PhoneConfig,
} from '../../../../src/modeling/definitions/Phone.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

test.group('Phone Semantic Configuration', () => {
  test('should create semantic with default config', ({ assert }) => {
    const semantic = createPhoneSemantic()
    assert.equal(semantic.id, SemanticType.Phone)
    assert.deepEqual(semantic.config, DEFAULT_PHONE_CONFIG)
  })

  test('should create semantic with custom config', ({ assert }) => {
    const config: PhoneConfig = {
      allowedCountries: ['US', 'CA'],
      format: 'E.164',
      requireVerification: true,
    }
    const semantic = createPhoneSemantic(config)
    assert.equal(semantic.id, SemanticType.Phone)
    assert.deepEqual(semantic.config, { ...DEFAULT_PHONE_CONFIG, ...config })
  })

  test('should identify phone semantic', ({ assert }) => {
    const semantic = createPhoneSemantic()
    assert.isTrue(isPhoneSemantic(semantic))
  })

  test('should not identify non-phone semantic', ({ assert }) => {
    // Simulate a different semantic
    const fakeSemantic: AppliedDataSemantic = { id: SemanticType.Email, config: {} }
    assert.isFalse(isPhoneSemantic(fakeSemantic))
  })
})
