import { test } from '@japa/runner'
import {
  createHTMLSemantic,
  isHTMLSemantic,
  DEFAULT_HTML_CONFIG,
  type HTMLConfig,
} from '../../../../src/modeling/definitions/HTML.js'
import { SemanticType, type AppliedDataSemantic } from '../../../../src/modeling/Semantics.js'

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

  test('should create semantic with custom config', ({ assert }) => {
    const config: HTMLConfig = {
      renderAsHTML: true,
      allowedTags: ['p', 'div', 'span'],
      sanitize: true,
    }
    const semantic = createHTMLSemantic(config)
    assert.equal(semantic.id, SemanticType.HTML)
    assert.deepEqual(semantic.config, { ...DEFAULT_HTML_CONFIG, ...config })
  })

  test('should identify HTML semantic', ({ assert }) => {
    const semantic = createHTMLSemantic()
    assert.isTrue(isHTMLSemantic(semantic))
  })

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