import { test } from '@japa/runner'
import { assert } from '@esm-bundle/chai'
import { OkAssertion, OkAssertionKind } from '../../../../../src/models/http-flows/steps/assertion/OkAssertion.js'

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

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

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

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

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

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