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

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

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

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

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

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

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