import { test } from '@japa/runner'
import {
  createGeospatialCoordinatesSemantic,
  isGeospatialCoordinatesSemantic,
  DEFAULT_GEOSPATIAL_CONFIG,
  type GeospatialCoordinatesConfig,
  GeospatialCoordinateFormat,
  GeospatialDistanceUnit,
  GeospatialSpatialReferenceSystem,
} from '../../../../src/modeling/definitions/GeospatialCoordinates.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: GeospatialCoordinatesConfig = {
      format: GeospatialCoordinateFormat.LatLon,
      defaultDistanceUnit: GeospatialDistanceUnit.Kilometers,
      spatialReferenceSystem: GeospatialSpatialReferenceSystem.WGS84,
    }
    const semantic = createGeospatialCoordinatesSemantic(config)
    assert.equal(semantic.id, SemanticType.GeospatialCoordinates)
    assert.deepEqual(semantic.config, { ...DEFAULT_GEOSPATIAL_CONFIG, ...config })
  })

  test('should identify geospatial semantic', ({ assert }) => {
    const semantic = createGeospatialCoordinatesSemantic()
    assert.isTrue(isGeospatialCoordinatesSemantic(semantic))
  })

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