import { test } from '@japa/runner'
import {
  createURLSemantic,
  isURLSemantic,
  DEFAULT_URL_CONFIG,
  type URLConfig,
} from '../../../../src/modeling/definitions/URL.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: URLConfig = {
      allowedDomains: ['example.com'],
      requireHTTPS: true,
    }
    const semantic = createURLSemantic(config)
    assert.equal(semantic.id, SemanticType.URL)
    assert.deepEqual(semantic.config, { ...DEFAULT_URL_CONFIG, ...config })
  })

  test('should identify URL semantic', ({ assert }) => {
    const semantic = createURLSemantic()
    assert.isTrue(isURLSemantic(semantic))
  })

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