import { test } from '@japa/runner'
import {
  createMarkdownSemantic,
  isMarkdownSemantic,
  DEFAULT_MARKDOWN_CONFIG,
  type MarkdownConfig,
} from '../../../../src/modeling/definitions/Markdown.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: MarkdownConfig = {
      renderToHTML: true,
      allowedTags: ['p', 'h1', 'h2'],
      sanitize: true,
    }
    const semantic = createMarkdownSemantic(config)
    assert.equal(semantic.id, SemanticType.Markdown)
    assert.deepEqual(semantic.config, { ...DEFAULT_MARKDOWN_CONFIG, ...config })
  })

  test('should identify markdown semantic', ({ assert }) => {
    const semantic = createMarkdownSemantic()
    assert.isTrue(isMarkdownSemantic(semantic))
  })

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