import { test } from '@japa/runner'
import {
  createEmailSemantic,
  isEmailSemantic,
  DEFAULT_EMAIL_CONFIG,
  type EmailConfig,
} from '../../../../src/modeling/definitions/Email.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: EmailConfig = {
      allowedDomains: ['example.com'],
      requireVerification: true,
    }
    const semantic = createEmailSemantic(config)
    assert.equal(semantic.id, SemanticType.Email)
    assert.deepEqual(semantic.config, { ...DEFAULT_EMAIL_CONFIG, ...config })
  })

  test('should identify email semantic', ({ assert }) => {
    const semantic = createEmailSemantic()
    assert.isTrue(isEmailSemantic(semantic))
  })

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