import { HttpStep, IHttpStep } from '../../HttpStep.js'

export const OkAssertionKind = 'HttpAction#OkAssertion'

/**
 * An assertion that makes sure the input has a truly value.
 */
export interface IOkAssertion extends IHttpStep {
  kind: typeof OkAssertionKind
}

/**
 * An assertion that makes sure the input has a truly value.
 */
export class OkAssertion extends HttpStep {
  override kind = OkAssertionKind

  constructor(init?: IOkAssertion) {
    super()
    if (typeof init === 'object') {
      this.new(init)
    }
  }

  override new(init: IOkAssertion): void {
    super.new(init)
    this.kind = OkAssertionKind
  }

  checkValidity(): boolean {
    return true
  }

  override toJSON(): IOkAssertion {
    const result: IOkAssertion = {
      ...super.toJSON(),
      kind: OkAssertionKind,
    }
    return result
  }
}
