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

test.group('NotIncludesAssertion constructor()', () => {
  test('initializes from values', () => {
    const instance = new NotIncludesAssertion('test-value')
    assert.equal(instance.value, 'test-value')
    assert.isTrue(instance.enabled)
  })

  test('initializes from the schema', () => {
    const instance = new NotIncludesAssertion({
      kind: NotIncludesAssertionKind,
      value: 'test-value',
      enabled: false,
    })
    assert.equal(instance.value, 'test-value')
    assert.isFalse(instance.enabled)
  })

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

test.group('NotIncludesAssertion checkValidity()', () => {
  test('returns true when has the value', () => {
    const instance = new NotIncludesAssertion('test-value')
    assert.isTrue(instance.checkValidity())
  })

  test('returns false when has no value', () => {
    const instance = new NotIncludesAssertion()
    assert.isFalse(instance.checkValidity())
  })
})

test.group('NotIncludesAssertion toJSON()', () => {
  test('serializes the kind', () => {
    const instance = new NotIncludesAssertion('test-value')
    assert.equal(instance.kind, NotIncludesAssertionKind)
  })

  test('serializes the value when set', () => {
    const instance = new NotIncludesAssertion('test-value')
    assert.equal(instance.value, 'test-value')
  })

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

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

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