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

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

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

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

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

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

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