import { test } from '@japa/runner'
import {
  createStatusSemantic,
  isStatusSemantic,
  DEFAULT_STATUS_CONFIG,
  type StatusConfig,
} from '../../../../src/modeling/definitions/Status.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: StatusConfig = {
      allowedStates: ['active', 'inactive'],
      defaultState: 'active',
    }
    const semantic = createStatusSemantic(config)
    assert.equal(semantic.id, SemanticType.Status)
    assert.deepEqual(semantic.config, { ...DEFAULT_STATUS_CONFIG, ...config })
  })

  test('should identify status semantic', ({ assert }) => {
    const semantic = createStatusSemantic()
    assert.isTrue(isStatusSemantic(semantic))
  })

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