import { test } from '@japa/runner'
import {
  createTagsSemantic,
  isTagsSemantic,
  DEFAULT_TAGS_CONFIG,
  type TagsConfig,
} from '../../../../src/modeling/definitions/Tags.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: TagsConfig = {
      maxTags: 10,
      allowCustomTags: true,
      predefinedTags: ['urgent', 'important'],
    }
    const semantic = createTagsSemantic(config)
    assert.equal(semantic.id, SemanticType.Tags)
    assert.deepEqual(semantic.config, { ...DEFAULT_TAGS_CONFIG, ...config })
  })

  test('should identify tags semantic', ({ assert }) => {
    const semantic = createTagsSemantic()
    assert.isTrue(isTagsSemantic(semantic))
  })

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