import { test } from '@japa/runner'
import { ApiSchemaGenerator } from '../../../src/amf/ApiSchemaGenerator.js'
import { AmfLoader } from './AmfLoader.js'
import { IAmfDocument } from '../../../src/amf/definitions/Amf.js'

const loader = new AmfLoader()

test.group('unknown media type', (group) => {
  const unknownMime = 'any/text'

  let model: IAmfDocument

  group.setup(async () => {
    model = await loader.getGraph('schema-api')
  })

  test('does not set the generator property', async ({ assert }) => {
    const inst = new ApiSchemaGenerator(unknownMime)
    assert.isUndefined(inst.generator)
  })

  test('returns undefined on generate() ', async ({ assert }) => {
    const shape = loader.getShape(model, 'ScalarType')
    const inst = new ApiSchemaGenerator(unknownMime)
    const result = inst.generate(shape)
    assert.isUndefined(result)
  })

  test('returns undefined on toValue() ', async ({ assert }) => {
    const shape = loader.getShape(model, 'ScalarType')
    const inst = new ApiSchemaGenerator(unknownMime)
    const result = inst.generate(shape)
    assert.isUndefined(result)
  })

  test('returns undefined on toExample() ', async ({ assert }) => {
    const shape = loader.getShape(model, 'ScalarType')
    const inst = new ApiSchemaGenerator(unknownMime)
    const result = inst.toExample(shape)
    assert.isUndefined(result)
  })
})
