import { test } from '@japa/runner'
import {
  createCategoriesSemantic,
  isCategoriesSemantic,
  DEFAULT_CATEGORIES_CONFIG,
  type CategoriesConfig,
} from '../../../../src/modeling/definitions/Categories.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: CategoriesConfig = {
      maxCategories: 5,
      allowMultiple: true,
      predefinedCategories: ['feature', 'bug', 'enhancement'],
    }
    const semantic = createCategoriesSemantic(config)
    assert.equal(semantic.id, SemanticType.Categories)
    assert.deepEqual(semantic.config, { ...DEFAULT_CATEGORIES_CONFIG, ...config })
  })

  test('should identify categories semantic', ({ assert }) => {
    const semantic = createCategoriesSemantic()
    assert.isTrue(isCategoriesSemantic(semantic))
  })

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