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

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

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

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

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

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

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