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

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

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

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

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

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

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