import { test } from '@japa/runner'
import { assert } from '@esm-bundle/chai'
import {
  AsUpperCaseStep,
  AsUpperCaseStepKind,
} from '../../../../../src/models/http-flows/steps/transformation/AsUpperCaseStep.js'

test.group('AsUpperCaseStep constructor()', () => {
  test('initializes from the schema', () => {
    const instance = new AsUpperCaseStep({
      kind: AsUpperCaseStepKind,
      enabled: false,
    })
    assert.isFalse(instance.enabled)
  })

  test('initializes empty class', () => {
    const instance = new AsUpperCaseStep()
    assert.equal(instance.kind, AsUpperCaseStepKind)
    assert.isUndefined(instance.enabled)
  })
})

test.group('AsUpperCaseStep checkValidity()', () => {
  test('returns true', () => {
    const instance = new AsUpperCaseStep()
    assert.isTrue(instance.checkValidity())
  })
})

test.group('AsUpperCaseStep toJSON()', () => {
  test('serializes the kind', () => {
    const instance = new AsUpperCaseStep()
    assert.equal(instance.kind, AsUpperCaseStepKind)
  })

  test('serializes the enabled when set', () => {
    const instance = new AsUpperCaseStep()
    instance.enabled = true
    assert.isTrue(instance.enabled)
  })

  test('ignores the enabled when not set', () => {
    const instance = new AsUpperCaseStep()
    assert.isUndefined(instance.enabled)
  })
})
